Add vi-like 'A' command.

This commit is contained in:
Andreas Kling 2018-12-05 02:11:39 +01:00
parent ae6c183475
commit 92ebfee050
Notes: sideshowbarker 2024-07-19 16:08:29 +09:00
2 changed files with 8 additions and 0 deletions

View file

@ -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;

View file

@ -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;