BufferView: user must call update() after all changes and before vert_iter()

This commit is contained in:
josh committed 2017-09-03 17:34:41 -04:00
1 parent 5b35a35b24
commit 14e285041e
3 files changed
+13 -12

No files matched your search

+8 -11
View File
@@ -31,17 +31,6 @@ void BufferView::set_scroll_offset(int scroll_offset)
BufferView::Iterator BufferView::vert_iter()
{
if (m_iterator->valid())
{
/* TODO: user calls update() before vert_iter(). */
update();
}
else
{
m_cursor_screen_row = 0;
m_cursor_screen_column = 0;
m_cursor_virtual_column = 0;
}
return Iterator(*this);
}
@@ -94,6 +83,14 @@ void BufferView::update()
row_offset += ld.n_rows;
line_iterator->go_next_line();
}
/* Reset some fields if buffer becomes empty. */
if (!m_iterator->valid())
{
m_cursor_screen_row = 0;
m_cursor_screen_column = 0;
m_cursor_virtual_column = 0;
}
}
int BufferView::calculate_rows_in_line(std::shared_ptr<Buffer::Iterator> start_of_line)
+1 -1
View File
@@ -56,6 +56,7 @@ public:
CharacterWidthDeterminer & character_width_determiner);
void resize(int width, int height);
void set_scroll_offset(int scroll_offset);
void update();
Iterator vert_iter();
BufferLineWalker horiz_iter(std::shared_ptr<Buffer::Iterator> start_of_line)
{
@@ -88,7 +89,6 @@ protected:
{
return std::min(m_scroll_offset, (m_height - 1) / 2);
}
void update();
int calculate_rows_in_line(std::shared_ptr<Buffer::Iterator> start_of_line);
int calculate_rows_in_cursor_line(std::shared_ptr<Buffer::Iterator> start_of_line);
int screen_rows_below_line(std::shared_ptr<Buffer::Iterator> line);