BufferPane: replace colrow_to_xy() with col_x() and row_y()
This commit is contained in:
parent
129716e28f
commit
3422df51d6
@ -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();
|
||||
}
|
||||
|
@ -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<Buffer> m_buffer;
|
||||
std::shared_ptr<Font> m_font;
|
||||
|
Loading…
x
Reference in New Issue
Block a user