1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibGUI+TextEditor: Allow cursor line highlighting to be toggled

This commit is contained in:
thankyouverycool 2021-09-11 11:08:01 -04:00 committed by Andreas Kling
parent a5ff941c86
commit 9a5a9fbee0
4 changed files with 23 additions and 1 deletions

View file

@ -511,7 +511,7 @@ 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())
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 constexpr (TEXTEDITOR_DEBUG)
painter.draw_rect(visual_line_rect, Color::Cyan);
@ -1973,6 +1973,14 @@ void TextEditor::set_gutter_visible(bool visible)
update();
}
void TextEditor::set_cursor_line_highlighting(bool highlighted)
{
if (m_cursor_line_highlighting == highlighted)
return;
m_cursor_line_highlighting = highlighted;
update();
}
void TextEditor::undo()
{
clear_selection();