mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 01:15:07 +00:00
HackStudio+LibGUI: Implement matching curly brace highlighting
This works for C++ syntax highlighted text documents by caching the C++ token type in a new "arbitrary data" member of GTextDocumentSpan. When the cursor is placed immediately before a '{' or immediately after a '}', we highlight both of these brace buddies by changing their corresponding spans to have a different background color. ..and spans can also now have a custom background color. :^)
This commit is contained in:
parent
5f7f97355e
commit
c8e02e60a6
6 changed files with 89 additions and 1 deletions
|
@ -15,8 +15,10 @@ class GTextDocumentLine;
|
|||
struct GTextDocumentSpan {
|
||||
GTextRange range;
|
||||
Color color;
|
||||
Optional<Color> background_color;
|
||||
bool is_skippable { false };
|
||||
const Font* font { nullptr };
|
||||
void* data { nullptr };
|
||||
};
|
||||
|
||||
class GTextDocument : public RefCounted<GTextDocument> {
|
||||
|
@ -54,6 +56,7 @@ public:
|
|||
|
||||
bool has_spans() const { return !m_spans.is_empty(); }
|
||||
const Vector<GTextDocumentSpan>& spans() const { return m_spans; }
|
||||
void set_span_at_index(int index, GTextDocumentSpan span) { m_spans[index] = move(span); }
|
||||
|
||||
void append_line(NonnullOwnPtr<GTextDocumentLine>);
|
||||
void remove_line(int line_index);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue