diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-03-15 12:35:00 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-15 14:55:49 +0100 |
commit | 6d8f046fd047bca5f476cb48ec42fa9ce4e1d11f (patch) | |
tree | aecd9525c26b5ee79cea0253725b6a395874d3a9 /Userland/DevTools/HackStudio/Editor.cpp | |
parent | 609b6160851109ad881a733e9d9e2e7851553f2a (diff) | |
download | serenity-6d8f046fd047bca5f476cb48ec42fa9ce4e1d11f.zip |
LibGfx+Userland: Make TextAttributes::underline_style optional
Rather than having a style AND a field saying whether to use the style,
just make the style Optional.
Diffstat (limited to 'Userland/DevTools/HackStudio/Editor.cpp')
-rw-r--r-- | Userland/DevTools/HackStudio/Editor.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 3db73b6b16..0fe712fd44 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -292,8 +292,8 @@ void Editor::mousemove_event(GUI::MouseEvent& event) for (auto& span : document().spans()) { bool is_clickable = (highlighter->is_navigatable(span.data) || highlighter->is_identifier(span.data)); if (span.range.contains(m_previous_text_position) && !span.range.contains(text_position)) { - if (is_clickable && span.attributes.underline) { - span.attributes.underline = false; + if (is_clickable && span.attributes.underline_style.has_value()) { + span.attributes.underline_style.clear(); wrapper().editor().update(); } } @@ -304,9 +304,12 @@ void Editor::mousemove_event(GUI::MouseEvent& event) if (is_clickable) { is_over_clickable = true; - bool was_underlined = span.attributes.underline; - span.attributes.underline = event.modifiers() & Mod_Ctrl; - if (span.attributes.underline != was_underlined) { + bool was_underlined = span.attributes.underline_style.has_value(); + bool now_underlined = event.modifiers() & Mod_Ctrl; + span.attributes.underline_style.clear(); + if (now_underlined) + span.attributes.underline_style = Gfx::TextAttributes::UnderlineStyle::Solid; + if (now_underlined != was_underlined) { wrapper().editor().update(); } } |