start to do some cursor movement again

This commit is contained in:
Josh Holtrop 2016-12-21 21:11:29 -05:00
parent 08dab099a7
commit 8c834c9d7c

View File

@ -291,72 +291,31 @@ void BufferPane::handle_key(uint32_t keyval)
void BufferPane::cursor_move(CursorMovement which) void BufferPane::cursor_move(CursorMovement which)
{ {
#if 0
bool moved = false; bool moved = false;
int current_row_offset = m_cursor->column / m_columns;
int row_offset = 0;
switch (which) switch (which)
{ {
case CursorMovement::LEFT: case CursorMovement::LEFT:
moved = m_cursor->check_go_left(1); moved = m_iterator->go_left_in_line();
m_target_column = m_cursor->column;
break; break;
case CursorMovement::RIGHT: case CursorMovement::RIGHT:
moved = m_cursor->check_go_right(1, false); moved = m_iterator->go_right_in_line(false);
m_target_column = m_cursor->column;
break; break;
case CursorMovement::UP: case CursorMovement::UP:
moved = m_cursor->check_go_up(1, m_target_column); moved = m_iterator->go_previous_line();
break; break;
case CursorMovement::DOWN: case CursorMovement::DOWN:
moved = m_cursor->check_go_down(1, m_target_column); moved = m_iterator->go_next_line();
break; break;
case CursorMovement::SOL: case CursorMovement::SOL:
moved = m_cursor->check_go_start_of_line(); moved = m_iterator->go_start_of_line();
m_target_column = 0u;
break; break;
case CursorMovement::EOL: case CursorMovement::EOL:
moved = m_cursor->check_go_end_of_line(false); moved = m_iterator->go_end_of_line(false);
m_target_column = 0x7FFFFFFFu;
break; break;
} }
if (moved) if (moved)
{ {
switch (which) m_window->request_redraw();
{
case CursorMovement::LEFT:
case CursorMovement::RIGHT:
row_offset = m_cursor->column / m_columns - current_row_offset;
break;
case CursorMovement::UP:
{
PieceTable::Cursor c = *m_cursor;
c.go_end_of_line(false);
row_offset = m_cursor->column / m_columns - c.column / m_columns - 1 - current_row_offset;
}
break;
case CursorMovement::DOWN:
{
PieceTable::Cursor c = *m_cursor;
c.go_up(1, 0u);
c.go_end_of_line(false);
row_offset = c.column / m_columns - current_row_offset + 1 + m_cursor->column / m_columns;
}
break;
case CursorMovement::SOL:
row_offset = -current_row_offset;
break;
case CursorMovement::EOL:
{
PieceTable::Cursor c = *m_cursor;
c.go_end_of_line(false);
row_offset = c.column / m_columns - current_row_offset;
}
break;
}
update_cursor_row(m_cursor_row + row_offset);
redraw();
} }
#endif
} }