add 'g' and 'G' commands to go to first and last line in buffer
This commit is contained in:
1 parent
8df75f5ab0
commit
237dbf9c2b
3 files changed
+40
-2
No files matched your search
@@ -333,6 +333,9 @@ void BufferPane::handle_key(uint32_t keyval)
|
||||
case '$':
|
||||
cursor_move(CursorMovement::EOL);
|
||||
break;
|
||||
case 'G':
|
||||
cursor_move(CursorMovement::LAST_LINE);
|
||||
break;
|
||||
case 'a':
|
||||
if (**m_iterator != '\n')
|
||||
{
|
||||
@@ -341,6 +344,9 @@ void BufferPane::handle_key(uint32_t keyval)
|
||||
m_buffer->enter_insert_mode(*m_iterator);
|
||||
m_window->request_redraw();
|
||||
break;
|
||||
case 'g':
|
||||
cursor_move(CursorMovement::FIRST_LINE);
|
||||
break;
|
||||
case 'h':
|
||||
cursor_move(CursorMovement::LEFT);
|
||||
break;
|
||||
@@ -419,6 +425,28 @@ void BufferPane::cursor_move(CursorMovement which)
|
||||
case CursorMovement::EOL:
|
||||
moved = m_iterator->go_end_of_line(m_buffer->insert_mode());
|
||||
break;
|
||||
case CursorMovement::FIRST_LINE:
|
||||
{
|
||||
auto it = m_buffer->begin();
|
||||
if (it != *m_iterator)
|
||||
{
|
||||
*m_iterator = it;
|
||||
moved = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CursorMovement::LAST_LINE:
|
||||
{
|
||||
auto it = m_buffer->end();
|
||||
it.go_back();
|
||||
it.go_start_of_line();
|
||||
if (it != *m_iterator)
|
||||
{
|
||||
*m_iterator = it;
|
||||
moved = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (moved)
|
||||
{
|
||||
@@ -446,6 +474,12 @@ void BufferPane::cursor_move(CursorMovement which)
|
||||
case CursorMovement::EOL:
|
||||
m_target_column = INT_MAX;
|
||||
break;
|
||||
case CursorMovement::FIRST_LINE:
|
||||
m_cursor_screen_row = 0;
|
||||
break;
|
||||
case CursorMovement::LAST_LINE:
|
||||
m_cursor_screen_row = m_rows;
|
||||
break;
|
||||
}
|
||||
m_cursor_screen_row = determine_new_cursor_screen_row();
|
||||
m_window->request_redraw();
|
||||
|
||||
@@ -25,6 +25,8 @@ protected:
|
||||
DOWN,
|
||||
SOL,
|
||||
EOL,
|
||||
FIRST_LINE,
|
||||
LAST_LINE,
|
||||
};
|
||||
|
||||
int effective_scroll_offset()
|
||||
|
||||
Reference in new issue
Block a user