LibGUI: Abstract token pair matching

This commit is contained in:
Oriko 2020-03-13 00:51:02 +02:00 committed by Andreas Kling
commit c02037e944
Notes: sideshowbarker 2024-07-19 08:19:37 +09:00
4 changed files with 124 additions and 105 deletions

View file

@ -8,7 +8,13 @@ namespace GUI {
enum class SyntaxLanguage {
PlainText,
Cpp
Cpp,
Javascript
};
struct TextStyle {
Color color;
const Gfx::Font* font { nullptr };
};
class SyntaxHighlighter {
@ -20,7 +26,7 @@ public:
virtual SyntaxLanguage language() const = 0;
virtual void rehighlight() = 0;
virtual void highlight_matching_token_pair() = 0;
virtual void highlight_matching_token_pair();
virtual bool is_identifier(void*) const { return false; };
virtual bool is_navigatable(void*) const { return false; };
@ -34,6 +40,14 @@ protected:
WeakPtr<TextEditor> m_editor;
struct MatchingTokenPair {
void* open;
void* close;
};
virtual Vector<MatchingTokenPair> matching_token_pairs() const = 0;
virtual bool token_types_equal(void*, void*) const = 0;
struct BuddySpan {
int index { -1 };
GUI::TextDocumentSpan span_backup;