From 92ebfee050d360d1e4c2ad7247338f68eb0db489 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 5 Dec 2018 02:11:39 +0100 Subject: [PATCH] Add vi-like 'A' command. --- Editor/Editor.cpp | 7 +++++++ Editor/Editor.h | 1 + 2 files changed, 8 insertions(+) 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;