1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:18:12 +00:00

LibGUI+HackStudio: Move syntax highlighting from HackStudio to LibGUI

This patch introduces the GUI::SyntaxHighlighter class, which can be
attached to a GUI::TextEditor to provide syntax highlighting.

The C++ syntax highlighting from HackStudio becomes a new class called
GUI::CppSyntaxHighlighter. This will make it possible to get C++ syntax
highlighting in any app that uses a GUI::TextEditor. :^)

Sidenote: It does feel a bit weird having a C++ lexer in a GUI toolkit
library, and we'll probably end up moving this out to a separate place
as this functionality grows larger.
This commit is contained in:
Andreas Kling 2020-02-07 20:07:15 +01:00
parent 6cf49c23d4
commit bb8e65be41
13 changed files with 277 additions and 170 deletions

View file

@ -41,29 +41,17 @@ public:
EditorWrapper& wrapper();
const EditorWrapper& wrapper() const;
void notify_did_rehighlight();
private:
virtual void focusin_event(Core::Event&) override;
virtual void focusout_event(Core::Event&) override;
virtual void paint_event(GUI::PaintEvent&) override;
virtual void mousemove_event(GUI::MouseEvent&) override;
virtual void cursor_did_change() override;
void show_documentation_tooltip_if_available(const String&, const Gfx::Point& screen_location);
void highlight_matching_token_pair();
explicit Editor(GUI::Widget* parent);
RefPtr<GUI::Window> m_documentation_tooltip_window;
RefPtr<HtmlView> m_documentation_html_view;
String m_last_parsed_token;
struct BuddySpan {
int index { -1 };
GUI::TextDocumentSpan span_backup;
};
bool m_has_brace_buddies { false };
BuddySpan m_brace_buddies[2];
};