diff --git a/src/core/BufferView.cc b/src/core/BufferView.cc index 8c9d92b..a075328 100644 --- a/src/core/BufferView.cc +++ b/src/core/BufferView.cc @@ -9,6 +9,8 @@ BufferView::BufferView(std::shared_ptr buffer, { m_width = 1; m_height = 1; + m_scroll_offset = 0; + m_cursor_screen_row = 0; } void BufferView::resize(int width, int height) @@ -17,6 +19,11 @@ void BufferView::resize(int width, int height) m_height = std::max(1, height); } +void BufferView::set_scroll_offset(int scroll_offset) +{ + m_scroll_offset = std::max(0, scroll_offset); +} + void BufferView::iter_cols(const Buffer::Iterator & start_of_line, std::function callback) { int row_offset = 0; diff --git a/src/core/BufferView.h b/src/core/BufferView.h index c19a1ac..5856afe 100644 --- a/src/core/BufferView.h +++ b/src/core/BufferView.h @@ -16,6 +16,8 @@ public: std::shared_ptr iterator, CharacterWidthDeterminer & character_width_determiner); void resize(int width, int height); + void set_scroll_offset(int scroll_offset); + void iter_lines(std::function callback); void iter_cols(const Buffer::Iterator & start_of_line, std::function callback); protected: @@ -24,6 +26,13 @@ protected: CharacterWidthDeterminer & m_character_width_determiner; int m_width; int m_height; + int m_scroll_offset; + int m_cursor_screen_row; + + int effective_scroll_offset() + { + return std::min(m_scroll_offset, (m_height - 1) / 2); + } }; #endif