diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-12-05 02:11:39 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-12-05 02:11:39 +0100 |
commit | 92ebfee050d360d1e4c2ad7247338f68eb0db489 (patch) | |
tree | 5b8af2c90c0f60729e06462a2abbd77cc8a196a5 /Editor | |
parent | ae6c183475dbc3211b063ed72ad38961fe6e765e (diff) | |
download | serenity-92ebfee050d360d1e4c2ad7247338f68eb0db489.zip |
Add vi-like 'A' command.
Diffstat (limited to 'Editor')
-rw-r--r-- | Editor/Editor.cpp | 7 | ||||
-rw-r--r-- | Editor/Editor.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index f464dfbead..33a714146a 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -150,6 +150,7 @@ int Editor::exec() case 'k': move_up(); break; case 'l': move_right(); break; case 'i': set_mode(EditingDocument); break; + case 'A': move_to_end_of_line(); set_mode(EditingDocument); break; case 'a': move_right(); set_mode(EditingDocument); break; case 'q': m_should_quit = true; break; case '\\': set_mode(EditingCommand); break; @@ -226,6 +227,12 @@ void Editor::move_right() update_scroll_position_if_needed(); } +void Editor::move_to_end_of_line() +{ + m_cursor.move_to(m_cursor.line(), m_document->line(m_cursor.line()).length()); + 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 db5530ecbc..7d65b38834 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -42,6 +42,7 @@ private: void move_down(); void move_up(); void move_right(); + void move_to_end_of_line(); size_t max_line() const; size_t max_column() const; |