1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00

LibGUI+TextEditor: Highlight the entire current line

And fix Line Highlighting's duplicate alt-menu shortcut.

Previously only text on the cursor's line was highlighted. This makes
discerning cursor focus on empty lines easier.
This commit is contained in:
thankyouverycool 2022-02-02 19:28:58 -05:00 committed by Linus Groh
parent b2df863b55
commit f35a6c13ab
2 changed files with 11 additions and 4 deletions

View file

@ -512,8 +512,15 @@ void TextEditor::paint_event(PaintEvent& event)
size_t visual_line_index = 0;
for_each_visual_line(line_index, [&](Gfx::IntRect const& visual_line_rect, auto& visual_line_text, size_t start_of_visual_line, [[maybe_unused]] bool is_last_visual_line) {
if (is_multi_line() && line_index == m_cursor.line() && is_cursor_line_highlighted())
painter.fill_rect(visual_line_rect, widget_background_color.darkened(0.9f));
if (is_focused() && is_multi_line() && line_index == m_cursor.line() && is_cursor_line_highlighted()) {
Gfx::IntRect visible_content_line_rect {
visible_content_rect().x(),
visual_line_rect.y(),
widget_inner_rect().width() - gutter_ruler_width,
line_height()
};
painter.fill_rect(visible_content_line_rect, widget_background_color.darkened(0.9f));
}
if constexpr (TEXTEDITOR_DEBUG)
painter.draw_rect(visual_line_rect, Color::Cyan);