1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:17:44 +00:00

Add some more vi-like movements.

This commit is contained in:
Andreas Kling 2018-12-05 02:28:29 +01:00
parent 92ebfee050
commit eb4bbc337f
2 changed files with 10 additions and 1 deletions

View file

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

View file

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