diff options
author | Oriko <oriko1010@protonmail.com> | 2020-03-12 16:36:25 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-12 19:04:59 +0100 |
commit | 6d89f48dd8c0a57e241a69a5db3a7ceeed8ce108 (patch) | |
tree | cfd783e01c547cb45fae38ea1be4679cc785f2d7 /Libraries/LibGUI/TextEditor.cpp | |
parent | b58893cfe130feb72210f8d65d6162aac592ce1a (diff) | |
download | serenity-6d89f48dd8c0a57e241a69a5db3a7ceeed8ce108.zip |
LibGUI: Add underlines to highlighting
Diffstat (limited to 'Libraries/LibGUI/TextEditor.cpp')
-rw-r--r-- | Libraries/LibGUI/TextEditor.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Libraries/LibGUI/TextEditor.cpp b/Libraries/LibGUI/TextEditor.cpp index 3920195d0f..78bb871bce 100644 --- a/Libraries/LibGUI/TextEditor.cpp +++ b/Libraries/LibGUI/TextEditor.cpp @@ -425,6 +425,7 @@ void TextEditor::paint_event(PaintEvent& event) const Gfx::Font* font = &this->font(); Color color; Optional<Color> background_color; + bool underline = false; TextPosition physical_position(line_index, start_of_visual_line + i); // FIXME: This is *horribly* inefficient. for (auto& span : document().spans()) { @@ -434,11 +435,15 @@ void TextEditor::paint_event(PaintEvent& event) if (span.font) font = span.font; background_color = span.background_color; + underline = span.is_underlined; break; } if (background_color.has_value()) painter.fill_rect(character_rect, background_color.value()); painter.draw_text(character_rect, visual_line_text.substring_view(i, 1), *font, m_text_alignment, color); + if (underline) { + painter.draw_line(character_rect.bottom_left().translated(0, 1), character_rect.bottom_right().translated(0, 1), color); + } character_rect.move_by(advance, 0); } } @@ -1490,6 +1495,14 @@ void TextEditor::flush_pending_change_notification_if_needed() m_has_pending_change_notification = false; } +const SyntaxHighlighter* TextEditor::syntax_highlighter() const +{ + if (m_highlighter) + return m_highlighter.ptr(); + else + return nullptr; +} + void TextEditor::set_syntax_highlighter(OwnPtr<SyntaxHighlighter> highlighter) { if (m_highlighter) |