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)
{
#if 0
bool moved = false;
int current_row_offset = m_cursor->column / m_columns;
int row_offset = 0;
switch (which)
{
case CursorMovement::LEFT:
moved = m_cursor->check_go_left(1);
m_target_column = m_cursor->column;
moved = m_iterator->go_left_in_line();
break;
case CursorMovement::RIGHT:
moved = m_cursor->check_go_right(1, false);
m_target_column = m_cursor->column;
moved = m_iterator->go_right_in_line(false);
break;
case CursorMovement::UP:
moved = m_cursor->check_go_up(1, m_target_column);
moved = m_iterator->go_previous_line();
break;
case CursorMovement::DOWN:
moved = m_cursor->check_go_down(1, m_target_column);
moved = m_iterator->go_next_line();
break;
case CursorMovement::SOL:
moved = m_cursor->check_go_start_of_line();
m_target_column = 0u;
moved = m_iterator->go_start_of_line();
break;
case CursorMovement::EOL:
moved = m_cursor->check_go_end_of_line(false);
m_target_column = 0x7FFFFFFFu;
moved = m_iterator->go_end_of_line(false);
break;
}
if (moved)
{
switch (which)
{
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;
m_window->request_redraw();
}
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
}