diff --git a/src/gui/BufferPane.cc b/src/gui/BufferPane.cc index 75fa917..0fb3f4f 100644 --- a/src/gui/BufferPane.cc +++ b/src/gui/BufferPane.cc @@ -81,9 +81,7 @@ void BufferPane::draw() } else { - int x, y; - colrow_to_xy(0, 0, &x, &y); - draw_cursor(x, y, false); + draw_cursor(col_x(0), row_y(0), false); } } @@ -98,8 +96,8 @@ void BufferPane::draw_buffer_line(int screen_row, const Buffer::Cursor & cursor) if (draw_row >= m_rows) break; int draw_column = iter_cursor.column() % m_columns; - int x, y; - colrow_to_xy(draw_column, draw_row, &x, &y); + int x = col_x(draw_column); + int y = row_y(draw_row); if (iter_cursor == *m_cursor) { draw_cursor(x, y, false); @@ -115,9 +113,8 @@ void BufferPane::draw_buffer_line(int screen_row, const Buffer::Cursor & cursor) void BufferPane::draw_buffer_character(int screen_column, int screen_row, uint32_t character) { - int x, y; - colrow_to_xy(screen_column, screen_row, &x, &y); - m_gl->draw_character(win_x(x), win_y(y), character, *m_font); + m_gl->draw_character(win_x(col_x(screen_column)), win_y(row_y(screen_row)), + character, *m_font); } void BufferPane::draw_cursor(int x, int y, bool insert_mode) @@ -126,9 +123,3 @@ void BufferPane::draw_cursor(int x, int y, bool insert_mode) int height = m_font->get_line_height(); m_gl->draw_rect(win_x(x), win_y(y), width, height, 1.0, 0.2, 1.0, 1.0); } - -void BufferPane::colrow_to_xy(int col, int row, int * x, int * y) -{ - *x = col * m_font->get_advance(); - *y = m_height - (row + 1) * m_font->get_line_height(); -} diff --git a/src/gui/BufferPane.h b/src/gui/BufferPane.h index a5233a0..063c9db 100644 --- a/src/gui/BufferPane.h +++ b/src/gui/BufferPane.h @@ -28,7 +28,14 @@ protected: void draw_buffer_line(int screen_row, const Buffer::Cursor & cursor); void draw_buffer_character(int screen_column, int screen_row, uint32_t character); void draw_cursor(int x, int y, bool insert_mode); - void colrow_to_xy(int col, int row, int * x, int * y); + int col_x(int col) + { + return col * m_font->get_advance(); + } + int row_y(int row) + { + return m_height - (row + 1) * m_font->get_line_height(); + } std::shared_ptr m_buffer; std::shared_ptr m_font;