diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-12-05 02:28:29 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-12-05 02:28:29 +0100 |
commit | eb4bbc337fd4bb9a4407b1ce2732f0712abf71a7 (patch) | |
tree | 634a5fb78e77dd2298b2aee83f8a6ef5d57861b4 /Editor | |
parent | 92ebfee050d360d1e4c2ad7247338f68eb0db489 (diff) | |
download | serenity-eb4bbc337fd4bb9a4407b1ce2732f0712abf71a7.zip |
Add some more vi-like movements.
Diffstat (limited to 'Editor')
-rw-r--r-- | Editor/Editor.cpp | 10 | ||||
-rw-r--r-- | Editor/Editor.h | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 33a714146a..e1a539f7bb 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -150,9 +150,11 @@ int Editor::exec() case 'k': move_up(); break; case 'l': move_right(); break; case 'i': set_mode(EditingDocument); break; + case 'I': move_to_start_of_line(); set_mode(EditingDocument); break; case 'A': move_to_end_of_line(); set_mode(EditingDocument); break; + case '0': move_to_start_of_line(); break; + case '$': move_to_end_of_line(); break; case 'a': move_right(); set_mode(EditingDocument); break; - case 'q': m_should_quit = true; break; case '\\': set_mode(EditingCommand); break; } } @@ -233,6 +235,12 @@ void Editor::move_to_end_of_line() update_scroll_position_if_needed(); } +void Editor::move_to_start_of_line() +{ + m_cursor.move_to(m_cursor.line(), 0); + update_scroll_position_if_needed(); +} + size_t Editor::max_line() const { return m_document->line_count() - 1; diff --git a/Editor/Editor.h b/Editor/Editor.h index 7d65b38834..ff637fd667 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -43,6 +43,7 @@ private: void move_up(); void move_right(); void move_to_end_of_line(); + void move_to_start_of_line(); size_t max_line() const; size_t max_column() const; |