|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
- * Copyright (c) 2020, the SerenityOS developers.
|
|
|
|
|
|
+ * Copyright (c) 2020-2021, the SerenityOS developers.
|
|
* All rights reserved.
|
|
* All rights reserved.
|
|
*
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* Redistribution and use in source and binary forms, with or without
|
|
@@ -31,43 +31,44 @@
|
|
#include <LibGUI/TextDocument.h>
|
|
#include <LibGUI/TextDocument.h>
|
|
#include <LibGfx/Palette.h>
|
|
#include <LibGfx/Palette.h>
|
|
|
|
|
|
-namespace GUI {
|
|
|
|
|
|
+namespace Syntax {
|
|
|
|
|
|
-enum class SyntaxLanguage {
|
|
|
|
|
|
+enum class Language {
|
|
PlainText,
|
|
PlainText,
|
|
Cpp,
|
|
Cpp,
|
|
JavaScript,
|
|
JavaScript,
|
|
INI,
|
|
INI,
|
|
|
|
+ GML,
|
|
Shell,
|
|
Shell,
|
|
};
|
|
};
|
|
|
|
|
|
struct TextStyle {
|
|
struct TextStyle {
|
|
- const Color color;
|
|
|
|
|
|
+ const Gfx::Color color;
|
|
const bool bold { false };
|
|
const bool bold { false };
|
|
};
|
|
};
|
|
|
|
|
|
-class SyntaxHighlighter {
|
|
|
|
- AK_MAKE_NONCOPYABLE(SyntaxHighlighter);
|
|
|
|
- AK_MAKE_NONMOVABLE(SyntaxHighlighter);
|
|
|
|
|
|
+class Highlighter {
|
|
|
|
+ AK_MAKE_NONCOPYABLE(Highlighter);
|
|
|
|
+ AK_MAKE_NONMOVABLE(Highlighter);
|
|
|
|
|
|
public:
|
|
public:
|
|
- virtual ~SyntaxHighlighter();
|
|
|
|
|
|
+ virtual ~Highlighter();
|
|
|
|
|
|
- virtual SyntaxLanguage language() const = 0;
|
|
|
|
|
|
+ virtual Language language() const = 0;
|
|
virtual void rehighlight(Gfx::Palette) = 0;
|
|
virtual void rehighlight(Gfx::Palette) = 0;
|
|
virtual void highlight_matching_token_pair();
|
|
virtual void highlight_matching_token_pair();
|
|
|
|
|
|
virtual bool is_identifier(void*) const { return false; };
|
|
virtual bool is_identifier(void*) const { return false; };
|
|
virtual bool is_navigatable(void*) const { return false; };
|
|
virtual bool is_navigatable(void*) const { return false; };
|
|
|
|
|
|
- void attach(TextEditor& editor);
|
|
|
|
|
|
+ void attach(GUI::TextEditor& editor);
|
|
void detach();
|
|
void detach();
|
|
void cursor_did_change();
|
|
void cursor_did_change();
|
|
|
|
|
|
protected:
|
|
protected:
|
|
- SyntaxHighlighter() { }
|
|
|
|
|
|
+ Highlighter() { }
|
|
|
|
|
|
- WeakPtr<TextEditor> m_editor;
|
|
|
|
|
|
+ WeakPtr<GUI::TextEditor> m_editor;
|
|
|
|
|
|
struct MatchingTokenPair {
|
|
struct MatchingTokenPair {
|
|
void* open;
|
|
void* open;
|