From e8267b765b00f062b6e31601a70b3356d308f290 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 21 Nov 2017 22:09:53 -0500 Subject: [PATCH] BufferView: Use Buffer::Iterator functions for moving forward/backward in line --- src/core/BufferView.cc | 82 +++--------------------------------------- src/core/BufferView.h | 4 --- 2 files changed, 4 insertions(+), 82 deletions(-) diff --git a/src/core/BufferView.cc b/src/core/BufferView.cc index f4c65d0..2c2f950 100644 --- a/src/core/BufferView.cc +++ b/src/core/BufferView.cc @@ -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()) diff --git a/src/core/BufferView.h b/src/core/BufferView.h index 8b9dbc4..c19f3e7 100644 --- a/src/core/BufferView.h +++ b/src/core/BufferView.h @@ -132,10 +132,6 @@ protected: void move_forward_to_screen_position( std::shared_ptr 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); };