Begin more refactoring to shrink GapBuffer class
This commit is contained in:
1 parent
6c8e860fb5
commit
41c65f2dd9
8 files changed
+350
-337
No files matched your search
@@ -29,7 +29,7 @@ void BufferPane::update_cursor_row()
|
||||
|
||||
int BufferPane::screen_rows_below_cursor(int stop_at)
|
||||
{
|
||||
Buffer::Cursor cursor = *m_cursor;
|
||||
Cursor cursor = *m_cursor;
|
||||
size_t column = cursor.column();
|
||||
cursor.go_end_of_line(false);
|
||||
int rows = (cursor.column() / m_columns) - (column / m_columns);
|
||||
@@ -43,11 +43,11 @@ int BufferPane::screen_rows_below_cursor(int stop_at)
|
||||
|
||||
int BufferPane::screen_rows_above_cursor(int stop_at)
|
||||
{
|
||||
Buffer::Cursor cursor = *m_cursor;
|
||||
Cursor cursor = *m_cursor;
|
||||
int rows = cursor.column() / m_columns;
|
||||
while ((rows < stop_at) && cursor.go_up(0u))
|
||||
{
|
||||
Buffer::Cursor cursor2 = cursor;
|
||||
Cursor cursor2 = cursor;
|
||||
cursor2.go_end_of_line(false);
|
||||
rows += (cursor2.column() / m_columns) + 1;
|
||||
}
|
||||
@@ -58,11 +58,11 @@ void BufferPane::draw()
|
||||
{
|
||||
update_cursor_row();
|
||||
int screen_row = m_cursor_row - m_cursor->column() / m_columns;
|
||||
Buffer::Cursor iter_cursor = *m_cursor;
|
||||
Cursor iter_cursor = *m_cursor;
|
||||
iter_cursor.go_start_of_line();
|
||||
while ((screen_row > 0) && iter_cursor.go_up(0u))
|
||||
{
|
||||
Buffer::Cursor cursor2 = iter_cursor;
|
||||
Cursor cursor2 = iter_cursor;
|
||||
cursor2.go_end_of_line(false);
|
||||
screen_row -= (1 + cursor2.column() / m_columns);
|
||||
}
|
||||
@@ -78,9 +78,9 @@ void BufferPane::draw()
|
||||
}
|
||||
}
|
||||
|
||||
void BufferPane::draw_buffer_line(int screen_row, const Buffer::Cursor & cursor)
|
||||
void BufferPane::draw_buffer_line(int screen_row, const Cursor & cursor)
|
||||
{
|
||||
Buffer::Cursor iter_cursor = cursor;
|
||||
Cursor iter_cursor = cursor;
|
||||
while (!iter_cursor.is_end_of_line(true))
|
||||
{
|
||||
int draw_row = screen_row + (iter_cursor.column() / m_columns);
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
std::shared_ptr<GL> gl);
|
||||
void resize(int width, int height) override;
|
||||
void draw();
|
||||
std::shared_ptr<Buffer::Cursor> cursor() { return m_cursor; }
|
||||
std::shared_ptr<Cursor> cursor() { return m_cursor; }
|
||||
|
||||
protected:
|
||||
int effective_scroll_offset()
|
||||
@@ -25,7 +25,7 @@ protected:
|
||||
int screen_rows_below_cursor(int stop_at);
|
||||
int screen_rows_above_cursor(int stop_at);
|
||||
void update_cursor_row();
|
||||
void draw_buffer_line(int screen_row, const Buffer::Cursor & cursor);
|
||||
void draw_buffer_line(int screen_row, const Cursor & cursor);
|
||||
void draw_buffer_character(int screen_column, int screen_row, uint32_t character);
|
||||
void draw_cursor(int screen_column, int screen_row, bool insert_mode);
|
||||
void colrow_to_xy(int col, int row, int * x, int * y);
|
||||
@@ -37,7 +37,7 @@ protected:
|
||||
int m_columns;
|
||||
int m_scroll_offset;
|
||||
int m_cursor_row;
|
||||
std::shared_ptr<Buffer::Cursor> m_cursor;
|
||||
std::shared_ptr<Cursor> m_cursor;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user