diff --git a/src/gui/BufferPane.cc b/src/gui/BufferPane.cc index fef6ca1..032d0d3 100644 --- a/src/gui/BufferPane.cc +++ b/src/gui/BufferPane.cc @@ -608,6 +608,30 @@ void BufferPane::enter_insert_mode(Window::EnterInsertModeMode which) m_window->request_redraw(); } +void BufferPane::scroll_window_up() +{ + const int lines_to_scroll = 3; + int so = effective_scroll_offset(); + int lines_to_move_cursor = (so + lines_to_scroll) - (m_rows - m_cursor_screen_row - 1); + while (lines_to_move_cursor-- > 0) + { + move_cursor_screen_row_up(); + } + m_cursor_screen_row += lines_to_scroll; +} + +void BufferPane::scroll_window_down() +{ + const int lines_to_scroll = 3; + int so = effective_scroll_offset(); + int lines_to_move_cursor = (so + lines_to_scroll) - m_cursor_screen_row; + while (lines_to_move_cursor-- > 0) + { + move_cursor_screen_row_down(); + } + m_cursor_screen_row -= lines_to_scroll; +} + void BufferPane::forward_to_column(int column, bool allow_eol) { Buffer::Iterator start_of_line = *m_iterator; diff --git a/src/gui/BufferPane.h b/src/gui/BufferPane.h index 782e1ce..6eb92c1 100644 --- a/src/gui/BufferPane.h +++ b/src/gui/BufferPane.h @@ -21,6 +21,8 @@ public: void kill_character_at_cursor(); void write_file(); bool insert_mode() const { return m_buffer->insert_mode(); } + void scroll_window_up(); + void scroll_window_down(); protected: int effective_scroll_offset()