diff --git a/src/gui/BufferPane.cc b/src/gui/BufferPane.cc index 1998625..4133407 100644 --- a/src/gui/BufferPane.cc +++ b/src/gui/BufferPane.cc @@ -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,33 +236,40 @@ 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 != ' ')) - { - if (code_point < 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); - } - 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); - } - } } } }); return saved_row_offset + 1; } +void BufferPane::draw_character(uint32_t character, int screen_row, int screen_column) +{ + 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), 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), character, *m_window->font(), 1.0, 1.0, 1.0, 1.0); + } + } +} + int BufferPane::character_width(uint32_t character) { if (character < 0x20u) diff --git a/src/gui/BufferPane.h b/src/gui/BufferPane.h index fb6a1fe..fa8d6e7 100644 --- a/src/gui/BufferPane.h +++ b/src/gui/BufferPane.h @@ -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);