mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibGUI+LibSyntax: Stringify Highlighter::Language
This patch adds a Highlighter::Language -> string helper and a callback for Highlighter changes.
This commit is contained in:
parent
3aa95dd4d5
commit
94b74937d8
Notes:
sideshowbarker
2024-07-17 18:19:04 +09:00
Author: https://github.com/thankyouverycool Commit: https://github.com/SerenityOS/serenity/commit/94b74937d8 Pull-request: https://github.com/SerenityOS/serenity/pull/12723
@ -1934,6 +1934,8 @@ void TextEditor::set_syntax_highlighter(OwnPtr<Syntax::Highlighter> highlighter)
|
|||||||
m_needs_rehighlight = true;
|
m_needs_rehighlight = true;
|
||||||
} else
|
} else
|
||||||
document().set_spans({});
|
document().set_spans({});
|
||||||
|
if (on_highlighter_change)
|
||||||
|
on_highlighter_change();
|
||||||
}
|
}
|
||||||
|
|
||||||
AutocompleteProvider const* TextEditor::autocomplete_provider() const
|
AutocompleteProvider const* TextEditor::autocomplete_provider() const
|
||||||
|
@ -107,6 +107,7 @@ public:
|
|||||||
Function<void()> on_selection_change;
|
Function<void()> on_selection_change;
|
||||||
Function<void()> on_focusin;
|
Function<void()> on_focusin;
|
||||||
Function<void()> on_focusout;
|
Function<void()> on_focusout;
|
||||||
|
Function<void()> on_highlighter_change;
|
||||||
|
|
||||||
void set_text(StringView, AllowCallback = AllowCallback::Yes);
|
void set_text(StringView, AllowCallback = AllowCallback::Yes);
|
||||||
void scroll_cursor_into_view();
|
void scroll_cursor_into_view();
|
||||||
|
@ -142,4 +142,30 @@ void Highlighter::register_nested_token_pairs(Vector<MatchingTokenPair> pairs)
|
|||||||
m_nested_token_pairs.set(pair);
|
m_nested_token_pairs.set(pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringView Highlighter::language_string(Language language) const
|
||||||
|
{
|
||||||
|
switch (language) {
|
||||||
|
case Language::Cpp:
|
||||||
|
return "C++"sv;
|
||||||
|
case Language::CSS:
|
||||||
|
return "CSS"sv;
|
||||||
|
case Language::GitCommit:
|
||||||
|
return "Git"sv;
|
||||||
|
case Language::GML:
|
||||||
|
return "GML"sv;
|
||||||
|
case Language::HTML:
|
||||||
|
return "HTML"sv;
|
||||||
|
case Language::INI:
|
||||||
|
return "INI"sv;
|
||||||
|
case Language::JavaScript:
|
||||||
|
return "JavaScript"sv;
|
||||||
|
case Language::Shell:
|
||||||
|
return "Shell"sv;
|
||||||
|
case Language::SQL:
|
||||||
|
return "SQL"sv;
|
||||||
|
default:
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
virtual ~Highlighter();
|
virtual ~Highlighter();
|
||||||
|
|
||||||
virtual Language language() const = 0;
|
virtual Language language() const = 0;
|
||||||
|
StringView language_string(Language) const;
|
||||||
virtual void rehighlight(const Palette&) = 0;
|
virtual void rehighlight(const Palette&) = 0;
|
||||||
virtual void highlight_matching_token_pair();
|
virtual void highlight_matching_token_pair();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user