mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
Terminal: Draw the cursor by reversing foreground/background color.
This makes the cursor pleasantly see-through.
This commit is contained in:
parent
b7967d1292
commit
240b5fe677
1 changed files with 11 additions and 10 deletions
|
@ -633,6 +633,9 @@ void Terminal::paint()
|
||||||
}
|
}
|
||||||
m_rows_to_scroll_backing_store = 0;
|
m_rows_to_scroll_backing_store = 0;
|
||||||
|
|
||||||
|
// Always redraw the line with the cursor on it.
|
||||||
|
line(m_cursor_row).dirty = true;
|
||||||
|
|
||||||
for (word row = 0; row < m_rows; ++row) {
|
for (word row = 0; row < m_rows; ++row) {
|
||||||
auto& line = this->line(row);
|
auto& line = this->line(row);
|
||||||
if (!line.dirty)
|
if (!line.dirty)
|
||||||
|
@ -642,25 +645,23 @@ void Terminal::paint()
|
||||||
if (has_only_one_background_color)
|
if (has_only_one_background_color)
|
||||||
painter.fill_rect(row_rect(row), line.attributes[0].background_color);
|
painter.fill_rect(row_rect(row), line.attributes[0].background_color);
|
||||||
for (word column = 0; column < m_columns; ++column) {
|
for (word column = 0; column < m_columns; ++column) {
|
||||||
|
bool should_reverse_fill_for_cursor = m_in_active_window && row == m_cursor_row && column == m_cursor_column;
|
||||||
auto& attribute = line.attributes[column];
|
auto& attribute = line.attributes[column];
|
||||||
line.did_paint = true;
|
line.did_paint = true;
|
||||||
char ch = line.characters[column];
|
char ch = line.characters[column];
|
||||||
auto character_rect = glyph_rect(row, column);
|
auto character_rect = glyph_rect(row, column);
|
||||||
if (!has_only_one_background_color) {
|
if (!has_only_one_background_color || should_reverse_fill_for_cursor)
|
||||||
auto character_background = ansi_color(attribute.background_color);
|
painter.fill_rect(character_rect, ansi_color(should_reverse_fill_for_cursor ? attribute.foreground_color : attribute.background_color));
|
||||||
painter.fill_rect(character_rect, character_background);
|
|
||||||
}
|
|
||||||
if (ch == ' ')
|
if (ch == ' ')
|
||||||
continue;
|
continue;
|
||||||
painter.draw_glyph(character_rect.location(), ch, ansi_color(attribute.foreground_color));
|
painter.draw_glyph(character_rect.location(), ch, ansi_color(should_reverse_fill_for_cursor ? attribute.background_color : attribute.foreground_color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cursor_rect = glyph_rect(m_cursor_row, m_cursor_column);
|
if (!m_in_active_window) {
|
||||||
if (m_in_active_window)
|
auto cursor_rect = glyph_rect(m_cursor_row, m_cursor_column);
|
||||||
painter.fill_rect(cursor_rect, Color::MidGray);
|
painter.draw_rect(cursor_rect, ansi_color(line(m_cursor_row).attributes[m_cursor_column].foreground_color));
|
||||||
else
|
}
|
||||||
painter.draw_rect(cursor_rect, Color::MidGray);
|
|
||||||
|
|
||||||
line(m_cursor_row).did_paint = true;
|
line(m_cursor_row).did_paint = true;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue