summaryrefslogtreecommitdiff
path: root/modules/gdscript/editor/gdscript_highlighter.h
diff options
context:
space:
mode:
authorPaulb23 <p_batty@hotmail.co.uk>2020-05-03 17:08:15 +0100
committerPaulb23 <p_batty@hotmail.co.uk>2020-07-11 17:09:58 +0100
commitbc4cee44582d2a90d0792d6b213f00be1043000b (patch)
tree001ab82ed2bd7c6b59a7cc06807cce988c484d66 /modules/gdscript/editor/gdscript_highlighter.h
parent156daddaaf16e36eb932452d1e30f4f77d29aae6 (diff)
Extract Syntax highlighting from TextEdit and add EditorSyntaxHighlighter
- Extacted all syntax highlighting code from text edit - Removed enable syntax highlighting from text edit - Added line_edited_from signal to text_edit - Renamed get/set_syntax_highlighting to get/set_syntax_highlighter - Added EditorSyntaxHighligher
Diffstat (limited to 'modules/gdscript/editor/gdscript_highlighter.h')
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/modules/gdscript/editor/gdscript_highlighter.h b/modules/gdscript/editor/gdscript_highlighter.h
index c1de22167a..49357f3d2e 100644
--- a/modules/gdscript/editor/gdscript_highlighter.h
+++ b/modules/gdscript/editor/gdscript_highlighter.h
@@ -31,12 +31,25 @@
#ifndef GDSCRIPT_HIGHLIGHTER_H
#define GDSCRIPT_HIGHLIGHTER_H
+#include "editor/plugins/script_editor_plugin.h"
#include "scene/gui/text_edit.h"
-class GDScriptSyntaxHighlighter : public SyntaxHighlighter {
- GDCLASS(GDScriptSyntaxHighlighter, SyntaxHighlighter)
+class GDScriptSyntaxHighlighter : public EditorSyntaxHighlighter {
+ GDCLASS(GDScriptSyntaxHighlighter, EditorSyntaxHighlighter)
private:
+ struct ColorRegion {
+ Color color;
+ String start_key;
+ String end_key;
+ bool line_only;
+ };
+ Vector<ColorRegion> color_regions;
+ Map<int, int> color_region_cache;
+
+ Dictionary keywords;
+ Dictionary member_keywords;
+
enum Type {
NONE,
REGION,
@@ -61,6 +74,8 @@ private:
Color node_path_color;
Color type_color;
+ void add_color_region(const String &p_start_key, const String &p_end_key, const Color &p_color, bool p_line_only = false);
+
public:
virtual void _update_cache() override;
virtual Dictionary _get_line_syntax_highlighting(int p_line) override;
@@ -68,7 +83,7 @@ public:
virtual String _get_name() const override;
virtual Array _get_supported_languages() const override;
- virtual Ref<SyntaxHighlighter> _create() const override;
+ virtual Ref<EditorSyntaxHighlighter> _create() const override;
};
#endif // GDSCRIPT_HIGHLIGHTER_H