1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 10:45:08 +00:00
serenity/DevTools/HackStudio/Editor.h
Andreas Kling 15fb341eb4 HackStudio: Always re-match curlies/parens after a re-highlight
While you are typing in HackStudio, we re-lex the C++ as you type,
so this means we also need to keep re-checking for matching curlies and
parentheses at the cursor.

Fixes #769 (although it's not optional, because it's too cool. :^)
2019-11-18 19:21:18 +01:00

43 lines
1.1 KiB
C++

#pragma once
#include <LibGUI/GTextEditor.h>
class EditorWrapper;
class HtmlView;
class Editor final : public GTextEditor {
C_OBJECT(Editor)
public:
virtual ~Editor() override;
Function<void()> on_focus;
EditorWrapper& wrapper();
const EditorWrapper& wrapper() const;
void notify_did_rehighlight();
private:
virtual void focusin_event(CEvent&) override;
virtual void focusout_event(CEvent&) override;
virtual void paint_event(GPaintEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void cursor_did_change() override;
void show_documentation_tooltip_if_available(const String&, const Point& screen_location);
void highlight_matching_curlies_or_parens();
explicit Editor(GWidget* parent);
RefPtr<GWindow> m_documentation_tooltip_window;
RefPtr<HtmlView> m_documentation_html_view;
String m_last_parsed_token;
struct BuddySpan {
int index { -1 };
GTextDocumentSpan span_backup;
};
bool m_has_brace_buddies { false };
BuddySpan m_brace_buddies[2];
};