summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/EditingEngine.h
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-04-18 02:32:42 +0000
committerAndreas Kling <kling@serenityos.org>2021-04-25 10:41:16 +0200
commit53aec3e06dce4a42980d89b764db46b4632d8bd1 (patch)
tree6fe70c77cbdc26244e7a6d69ab80872bb837cc56 /Userland/Libraries/LibGUI/EditingEngine.h
parentbb096429ad1d0459b8f3bd5a33847a37c4e2c9c2 (diff)
downloadserenity-53aec3e06dce4a42980d89b764db46b4632d8bd1.zip
LibGUI: Implement Vim motion system
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.
Diffstat (limited to 'Userland/Libraries/LibGUI/EditingEngine.h')
-rw-r--r--Userland/Libraries/LibGUI/EditingEngine.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/EditingEngine.h b/Userland/Libraries/LibGUI/EditingEngine.h
index c718bfe6a1..83c89ca124 100644
--- a/Userland/Libraries/LibGUI/EditingEngine.h
+++ b/Userland/Libraries/LibGUI/EditingEngine.h
@@ -29,6 +29,12 @@ public:
void attach(TextEditor& editor);
void detach();
+ TextEditor& editor()
+ {
+ VERIFY(!m_editor.is_null());
+ return *m_editor.unsafe_ptr();
+ }
+
virtual bool on_key(const KeyEvent& event);
protected: