BufferView: Use Buffer::Iterator functions for moving forward/backward in line
This commit is contained in:
parent
3c6b3bc49e
commit
e8267b765b
@ -164,16 +164,16 @@ bool BufferView::cursor_move(CursorMovement which, uint32_t c, bool allow_eol)
|
||||
moved = move_cursor_screen_row_down(allow_eol);
|
||||
break;
|
||||
case CursorMovement::FORWARD_UP_TO_CHAR:
|
||||
moved = move_cursor_forward_up_to_char(c);
|
||||
moved = m_iterator->go_forward_in_line_up_to_char(c);
|
||||
break;
|
||||
case CursorMovement::FORWARD_ON_TO_CHAR:
|
||||
moved = move_cursor_forward_on_to_char(c);
|
||||
moved = m_iterator->go_forward_in_line_on_to_char(c);
|
||||
break;
|
||||
case CursorMovement::BACK_UP_TO_CHAR:
|
||||
moved = move_cursor_backward_up_to_char(c);
|
||||
moved = m_iterator->go_backward_in_line_up_to_char(c);
|
||||
break;
|
||||
case CursorMovement::BACK_ON_TO_CHAR:
|
||||
moved = move_cursor_backward_on_to_char(c);
|
||||
moved = m_iterator->go_backward_in_line_on_to_char(c);
|
||||
break;
|
||||
}
|
||||
if (moved)
|
||||
@ -446,80 +446,6 @@ void BufferView::move_forward_to_screen_position(
|
||||
}
|
||||
}
|
||||
|
||||
bool BufferView::move_cursor_forward_up_to_char(uint32_t c)
|
||||
{
|
||||
Buffer::Iterator last_it = *m_iterator;
|
||||
Buffer::Iterator it = *m_iterator;
|
||||
while (it.go_right_in_line(false))
|
||||
{
|
||||
if (*it == c)
|
||||
{
|
||||
if (last_it != *m_iterator)
|
||||
{
|
||||
*m_iterator = last_it;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
last_it = it;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BufferView::move_cursor_forward_on_to_char(uint32_t c)
|
||||
{
|
||||
Buffer::Iterator it = *m_iterator;
|
||||
while (it.go_right_in_line(false))
|
||||
{
|
||||
if (*it == c)
|
||||
{
|
||||
*m_iterator = it;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BufferView::move_cursor_backward_up_to_char(uint32_t c)
|
||||
{
|
||||
Buffer::Iterator last_it = *m_iterator;
|
||||
Buffer::Iterator it = *m_iterator;
|
||||
while (it.go_left_in_line())
|
||||
{
|
||||
if (*it == c)
|
||||
{
|
||||
if (last_it != *m_iterator)
|
||||
{
|
||||
*m_iterator = last_it;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
last_it = it;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BufferView::move_cursor_backward_on_to_char(uint32_t c)
|
||||
{
|
||||
Buffer::Iterator it = *m_iterator;
|
||||
while (it.go_left_in_line())
|
||||
{
|
||||
if (*it == c)
|
||||
{
|
||||
*m_iterator = it;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int BufferView::calculate_rows_above_screen(int stop_at)
|
||||
{
|
||||
if (m_lines.empty())
|
||||
|
@ -132,10 +132,6 @@ protected:
|
||||
void move_forward_to_screen_position(
|
||||
std::shared_ptr<Buffer::Iterator> line, int target_row_offset,
|
||||
bool allow_eol);
|
||||
bool move_cursor_forward_up_to_char(uint32_t c);
|
||||
bool move_cursor_forward_on_to_char(uint32_t c);
|
||||
bool move_cursor_backward_up_to_char(uint32_t c);
|
||||
bool move_cursor_backward_on_to_char(uint32_t c);
|
||||
int calculate_rows_above_screen(int stop_at);
|
||||
int calculate_rows_below_screen(int stop_at);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user