add BufferPane::draw_character() and refactor BufferPane::draw_buffer_line()
This commit is contained in:
parent
a2e5f7428c
commit
b3f972d7f4
@ -217,8 +217,6 @@ int BufferPane::draw_buffer_line(int screen_row, const Buffer::Iterator & start_
|
||||
walk_line(start_of_line, [this, &saved_row_offset, &screen_row](int row_offset, int screen_column, int virtual_column, int character_width, const Buffer::Iterator & i) {
|
||||
uint32_t code_point = *i;
|
||||
int draw_row = screen_row + row_offset;
|
||||
int x = col_x(screen_column);
|
||||
int y = row_y(draw_row);
|
||||
if ((draw_row >= 0) && (draw_row <= m_rows))
|
||||
{
|
||||
if (i == *m_iterator)
|
||||
@ -238,32 +236,39 @@ int BufferPane::draw_buffer_line(int screen_row, const Buffer::Iterator & start_
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((code_point == '\n') || (code_point == Buffer::Iterator::INVALID_CODE_POINT))
|
||||
{
|
||||
}
|
||||
else
|
||||
draw_character(code_point, draw_row, screen_column);
|
||||
if ((code_point != '\n') && (code_point != Buffer::Iterator::INVALID_CODE_POINT))
|
||||
{
|
||||
saved_row_offset = row_offset;
|
||||
if ((code_point != '\t') && (code_point != ' '))
|
||||
}
|
||||
}
|
||||
});
|
||||
return saved_row_offset + 1;
|
||||
}
|
||||
|
||||
void BufferPane::draw_character(uint32_t character, int screen_row, int screen_column)
|
||||
{
|
||||
if (code_point < 0x20u)
|
||||
if ((character != ' ') &&
|
||||
(character != '\t') &&
|
||||
(character != '\n') &&
|
||||
(character != Buffer::Iterator::INVALID_CODE_POINT))
|
||||
{
|
||||
int x = col_x(screen_column);
|
||||
int y = row_y(screen_row);
|
||||
if (character < 0x20u)
|
||||
{
|
||||
m_window->gl()->draw_rect(win_x(x + 2), win_y(y),
|
||||
m_window->font()->get_advance() * 2 - 4, 1,
|
||||
0, 0.7, 1.0, 1.0);
|
||||
m_window->gl()->draw_character(win_x(x), win_y(y), '^', *m_window->font(), 1.0, 1.0, 1.0, 1.0);
|
||||
m_window->gl()->draw_character(win_x(col_x(screen_column + 1)), win_y(y), code_point | 0x40u, *m_window->font(), 1.0, 1.0, 1.0, 1.0);
|
||||
m_window->gl()->draw_character(win_x(col_x(screen_column + 1)), win_y(y), character | 0x40u, *m_window->font(), 1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_window->gl()->draw_character(win_x(x), win_y(y), code_point, *m_window->font(), 1.0, 1.0, 1.0, 1.0);
|
||||
m_window->gl()->draw_character(win_x(x), win_y(y), character, *m_window->font(), 1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return saved_row_offset + 1;
|
||||
}
|
||||
|
||||
int BufferPane::character_width(uint32_t character)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ protected:
|
||||
return std::min(m_scroll_offset, (m_rows - 1) / 2);
|
||||
}
|
||||
int draw_buffer_line(int screen_row, const Buffer::Iterator & start_of_line);
|
||||
void draw_character(uint32_t character, int screen_row, int screen_column);
|
||||
int character_width(uint32_t character);
|
||||
void draw_buffer_character(int screen_column, int screen_row, uint32_t character);
|
||||
void draw_cursor(int x, int y);
|
||||
|
Loading…
x
Reference in New Issue
Block a user