Add cursor movements to move to SOL and EOL.
This commit is contained in:
1 parent
c2166b4bd1
commit
f876b68bd0
4 files changed
+39
-4
No files matched your search
@@ -234,6 +234,12 @@ void Window::handle_key(uint32_t scancode, uint32_t mod)
|
||||
case SDL_SCANCODE_ESCAPE:
|
||||
m_exit_requested = true;
|
||||
break;
|
||||
case SDL_SCANCODE_0:
|
||||
cursor_move(CURSOR_SOL);
|
||||
break;
|
||||
case SDL_SCANCODE_9:
|
||||
cursor_move(CURSOR_EOL);
|
||||
break;
|
||||
case SDL_SCANCODE_H:
|
||||
cursor_move(CURSOR_LEFT);
|
||||
break;
|
||||
@@ -269,6 +275,12 @@ void Window::cursor_move(int which)
|
||||
case CURSOR_DOWN:
|
||||
success = m_cursor->go_down(1, m_cursor->column);
|
||||
break;
|
||||
case CURSOR_SOL:
|
||||
success = m_cursor->go_start_of_line();
|
||||
break;
|
||||
case CURSOR_EOL:
|
||||
success = m_cursor->go_end_of_line();
|
||||
break;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
@@ -293,6 +305,16 @@ void Window::cursor_move(int which)
|
||||
row_offset = c.column / m_columns - current_row_offset + 1 + m_cursor->column / m_columns;
|
||||
}
|
||||
break;
|
||||
case CURSOR_SOL:
|
||||
row_offset = -current_row_offset;
|
||||
break;
|
||||
case CURSOR_EOL:
|
||||
{
|
||||
PieceTable::Cursor c = *m_cursor;
|
||||
c.go_end_of_line();
|
||||
row_offset = c.column / m_columns - current_row_offset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
update_cursor_row(m_cursor_row + row_offset);
|
||||
redraw();
|
||||
|
||||
@@ -22,6 +22,8 @@ protected:
|
||||
CURSOR_RIGHT,
|
||||
CURSOR_UP,
|
||||
CURSOR_DOWN,
|
||||
CURSOR_SOL,
|
||||
CURSOR_EOL,
|
||||
};
|
||||
|
||||
void resize();
|
||||
|
||||
Reference in new issue
Block a user