mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 18:27:40 +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:
parent
b2df863b55
commit
f35a6c13ab
2 changed files with 11 additions and 4 deletions
|
@ -519,12 +519,12 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
||||||
view_menu.add_action(*m_visualize_trailing_whitespace_action);
|
view_menu.add_action(*m_visualize_trailing_whitespace_action);
|
||||||
view_menu.add_action(*m_visualize_leading_whitespace_action);
|
view_menu.add_action(*m_visualize_leading_whitespace_action);
|
||||||
|
|
||||||
m_cursor_line_highlighting_action = GUI::Action::create_checkable("Line High&lighting", [&](auto&) {
|
m_cursor_line_highlighting_action = GUI::Action::create_checkable("L&ine Highlighting", [&](auto&) {
|
||||||
m_editor->set_cursor_line_highlighting(m_cursor_line_highlighting_action->is_checked());
|
m_editor->set_cursor_line_highlighting(m_cursor_line_highlighting_action->is_checked());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_cursor_line_highlighting_action->set_checked(true);
|
m_cursor_line_highlighting_action->set_checked(true);
|
||||||
m_cursor_line_highlighting_action->set_status_tip("Highlight text on the cursor's line");
|
m_cursor_line_highlighting_action->set_status_tip("Highlight the current line");
|
||||||
|
|
||||||
view_menu.add_action(*m_cursor_line_highlighting_action);
|
view_menu.add_action(*m_cursor_line_highlighting_action);
|
||||||
|
|
||||||
|
|
|
@ -512,8 +512,15 @@ void TextEditor::paint_event(PaintEvent& event)
|
||||||
|
|
||||||
size_t visual_line_index = 0;
|
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) {
|
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())
|
if (is_focused() && is_multi_line() && line_index == m_cursor.line() && is_cursor_line_highlighted()) {
|
||||||
painter.fill_rect(visual_line_rect, widget_background_color.darkened(0.9f));
|
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)
|
if constexpr (TEXTEDITOR_DEBUG)
|
||||||
painter.draw_rect(visual_line_rect, Color::Cyan);
|
painter.draw_rect(visual_line_rect, Color::Cyan);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue