If an icon exists and the horizontal scroll value is larger than 0,
translate the TextEditor painter by the icon size and padding.
The text would scroll over the icon when the text was long enough to
trigger a horizontal scroll.
Fixes#13669.
The issue was caused by the usage of the
selection_end_column_within_line variable as if it was the visual line.
This is fixed by taking the minimum between this value and the length of
a visual line.
This adds a search API to TextEditor.
The API that is similar to "find_text" of TextDocument (which is used
internally to do the search).
All search results (as well as the current one) are highlighted with
a "span collection", which is pretty neat :^)
TextDocument::set_spans() now also takes a "span collection index"
argument.
TextDocument keeps a map between a span collection index and its spans.
It merges the spans from all collections into a single set of spans
whenever set_spans() is called.
This allows us to style a document with multiple layers of spans, where
as previously we only supported a single layer of spans that was set
from the SyntaxHighlighter.
The last commit fixes a bug, but also exposes the fact that trailing
space highlighting isn't really supported on multiple lines. This patch
correct the wrong behavior by adding an offset to adjust rectangle's
position.
Before this patch the highlighted rectangle wasn't placed on the right
spot. Now the red highlighting is correctly placed at the end of the
line. This was due to a function called with a wrong argument.
Fonts now provide their preferred line height based on maximum
height and requested line gap. TTFs provide a preferred line gap
from table metrics while BitmapFonts are hardcoded at the previous
default for now.
Ruler needs to take into account spacing between glyphs for
proportional fonts as line count increases. This also replaces
the less accurate 'x' width estimate for widest character with
a '4'
And fix Line Highlighting's duplicate alt-menu shortcut.
Previously only text on the cursor's line was highlighted. This makes
discerning cursor focus on empty lines easier.
And simplify its construction.
The first visual line was being over-clipped vertically by an amount
equal to the frame's thickness. Selections and icons in TextBoxes and
the first line of Editors now display correctly.
This patch reintroduces the translation previously mistakenly removed
when adding support for different underline-styles.
Thanks for reporting the bug, kennethmyhra!
This commit should fix a bug where using leading whitespaces when a line
is wrapped results in a crash. Now it should correctly highlight the
leading whitespaces even when the leading whitespaces are longer than a
line.
The clipboard cannot reasonably contain the empty string. The clipboard
can be empty (i.e. cleared), sure, but that this check was about whether
the clipboard contained the empty string.
This cannot easily happen for two reasons:
- TextEditor GUI elements disable their copy actions when the selection
is empty.
- Clipboard::set_data, through which all text-copying operates,
implicitly forbids empty strings, because Process::sys$anon_create
forbids empty anonymous files.
- Even if it were sent (e.g. by creating a non-empty anonymous file and
sending it manually to the Clipboard server), it would not be
received, because decode(Decoder&, Core::AnonymousBuffer&) goes
through mmap() with a size of 0, which also is forbidden by the
Kernel.
In other words, if the clipboard is never the empty text, therefore
checking this condition is pointless, and we can save a roundtrip to the
Clipboard server.
Having the delete key handling be done via an action limits our ability
to support key modifiers (e.g. ctrl+delete deleting the word in front of
the cursor).
The fact that it was an action _did_ allow us to have a delete button in
the TextEditor UI. However, this is an odd choice in the first place
that isn't common in other text editors, so I just removed it.
Previously there was a situation where the autocomplete box would
appear to "jump" to the side. This was due to the following race
condition:
1. Start typing, thus triggering the autocomplete timer to start
2. Manually trigger autocomplete before the timer finishes
3. Continue typing
4. The autocomplete timer now fires
When the timer fires it causes the autocomplete box to show, which, if
it is already shown, has the effect of moving the box to the current
cursor position.
Previously the autocomplete box would always close after applying a
suggestion. This is the desired behavior in almost all cases, but there
are some situations (like autocompleting paths) where it would be nicer
to keep the autocomplete box open after applying the suggestion.
Moving the cursor to a different location, by any means, should
dismiss the autocomplete popup. This is the behavior of virtually
every editor/IDE out there, and it is really annoying (and
confusing) when our autocomplete doesn't behave like that.
Previously if there were no suggestions, we simply wouldn't show the
autocomplete popup at all. This is functional, but when there are no
resultes it does leave the user wondering if it actually worked.
Now, if the user requests autocomplete and we do have requests, it
behaves exactly as before, but if there' aren't any we now show a box
with the message "No suggestions" to show the user that we got the
request, there just isn't anything to suggest.
Showing the selection in non-focused text editors was not really useful,
since refocusing the widget would clear or change the selection
immediately anyway.
Note that TextEditors in inactive windows can still be the focused
widget within that window, and will still be painted with an "inactive"
looking selection.