This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).
This commit is auto-generated:
$ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
Meta Ports Ladybird Tests Kernel)
$ perl -pie 's/\bDeprecatedString\b/ByteString/g;
s/deprecated_string/byte_string/g' $xs
$ clang-format --style=file -i \
$(git diff --name-only | grep \.cpp\|\.h)
$ gn format $(git ls-files '*.gn' '*.gni')
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.
One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
When in normal mode pressing Shift+D will delete from the current cursor
position to the end of the line. Leaving the cursor on the character
before where the cursor was when the deletion took place.
Applications using the Vim emulation engine now support line-wise text
selection.
We already have support for character-wise text selection, by pressing
`v` from normal mode.
However now can also trigger line-wise text selection by pressing
`shift+v` from normal mode, and then using vertical motion commands
(e.g. `j` or `k`) to expand the selection. This is a standard vim
feature.
In visual line mode the following operations are supported:
* `escape`: back to normal mode
* `u`: convert to lowercase
* `U`: convert to uppercase
* `~`: toggle case
* `ctrl+d`: move down by 50% of page height
* `ctrl+u`: move up by 50% of page height
* `d` or `x`: delete selection
* `c`: change selection
* `y`: copy selection
* `page up`: move up by 100% of page height
* `page down`: move down by 100% of page height
Notably I didn't implement pressing `v` to go to regular
(character-wise) visual mode straight from visual line mode. This is
tricky to implement in the current code base, and there's an
alternative, which is to take a detour via normal mode.
Allows the passing of a Casing enum, Lowercase or Uppercase, and
converts the selected text accordingly. If Lowercase is passed as the
parameter, it converts the selected text to lowercase. If Uppercase is
passed as the parameter, it converts the selected text to uppercase.
Clang is a bit more pedantic than GCC when diagnosing implicit
fallthroughs, and doesn't care if the succeeding label only contains a
single break statement.
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.
In Vim, Ctrl-H is effectively equivalent to backspace in insert mode, as
it deletes the previous character.
This commit implements method delete_previous_char() to TextEditor.
delete_char() already exists in EditingEngine, but it deletes the
next character rather than the previous. delete_previous_char() is then
called from within VimEditingEngine.
In Vim's insert mode, Ctrl-W deletes the word before the cursor, like
Ctrl-Backspace. Unlike Ctrl-Backspace, if only whitespace exists between
the end of the word and the cursor, the word will be deleted with the
whitespace.
To do so, this commit introduces two methods: delete_previous_word() for
TextEditor and first_word_before() for TextDocument, where the former
depends on the latter. delete_previous_word() is then called in
VimEditingEngine.
In the normal editing engine keys like Home, End etc work on visual
lines, but vim operates on real ones. Eg if you have a really long line
and wrapping is on then in normal editing Home would take you to the
beginning of the wrapped line, but 'I' would put you insert mode at the
beginning of the real line in vim.
This patch fixes the visual selection of endline characters in the
VimEditingEngine. When the visual mode is disabled and the cursor
is located on the endline character, it is shifted back to the last
character of the line.
This patch adds handling of the arrow, Home/End, and PageUp/PageDown
keys to the Vim emulation mode. Home acts as 0, End acts as $, arrow
keys act as their HJKL variants, and PageUp/Down behaves as you would
expect.
This patch also moves the default handling of the aforementioned keys
to insert mode, since regular EditingEngine semantics are more
appropriate there.
This patch moves selection updates outside movement functions in
EditingEngine. Previously, movement functions would automatically
update the selection based on whether the Shift key was pressed down
during movement. However, not all EditingEngine subclasses want that;
VimEditingEngine being a good example (because all selection is handled
in visual mode).
Therefore, this patch moves all selection updating to
EditingEngine::on_key(). Subclasses wishing to provide custom movement
and selection semantics should override it (and VimEditingEngine already
does).
This patch implements Vim motions. The VimMotion class will accept
keycodes from the editing engine to build up a motion, and will
signal when a motion is complete via VimMotion::is_complete(). The
editing engine can then call VimMotion::get_range() to obtain a
TextRange object which can be used to perform operations on the text,
or VimMotion::get_position() to obtain a TextPosition which is the
new position of the cursor after the motion.
Currently, the following motions are supported:
- h/j/k/l, regular Vim line and character movements
- 0/^/$, start/end of line and start of non-blank
- w/e/b/ge, word-related movements
- W/E/B/gE, WORD (anything non-blank) versions of the above motions
- gg/G, document related movements
- t/f, to/find character
All motions except gg/G accept a number prefix to repeat the motion that
many times.
This patch updates insert, normal and visual modes to use this motion
system for movement.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.
See: https://spdx.dev/resources/use/#identifiers
This was done with the `ambr` search and replace tool.
ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)
Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.
We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
Implemented move_to_beginning_of_next(), move_to_end_of_next(),
move_to_beginning_of_previous() and move_to_end_of_previous() functions
for more correct word jumping than the move_to_xxx_span() methods that
were previously used.