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.
This is a helpful option to prevent unwanted side effects, distinguish
between user and programmatic input, etc. Sliders and SpinBoxes were
implementing it idiosyncratically, so let's generalize the API and
give Buttons and TextEditors the same ability.
Only one place used this argument and it was to hold on to a strong ref
for the object. Since we already do that now, there's no need to keep
this argument around since this can be easily captured.
This commit contains no changes.
This allows the address bar to "select all" when initially gaining focus
as Firefox and Chrome do. A future improvement on this would be for the
Widget class to mange and provide focus transition as part of the events
instead of the UrlBox class. Currently focus is updated before the event
is provided to the UrlBox class.
This ensures that the user can't copy/cut text from password boxes which
would reveal the password. It also makes sure that the undo/redo actions
stay disabled because it's difficult to reason about what these do
exactly without being able to see the result.
Anyone who inherits from `GUI::Clipboard::ClipboardClient` will receive
clipboard notifications via `clipboard_content_did_change()`.
Update ClipboardHistoryModel, TextEditor and TerminalWidget to inherit
from this class.
This prevents GUI::TextBox and the `Paste & Go` action in the browser
from trying to paste a bitmap. Also, the paste action is enabled
and disabled on clipboard change to reflect if the clipboard data
can be pasted.
While under insert mode, Ctrl-U deletes all characters between the first
non-blank character of the line and the cursor.
Implement delete_from_line_start_to_cursor() in TextEditor. Then, call
the method in VimEditingEngine via its pointer to an instance of
TextEditor.