From 156daddaaf16e36eb932452d1e30f4f77d29aae6 Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Sat, 7 Mar 2020 14:29:44 +0000 Subject: Expose Syntax highlighter for editor plugins --- modules/gdscript/editor/gdscript_highlighter.cpp | 6 ++++-- modules/gdscript/editor/gdscript_highlighter.h | 12 +++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'modules/gdscript/editor') diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 4be83877be..8ab3dc1d56 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -387,6 +387,8 @@ void GDScriptSyntaxHighlighter::_update_cache() { type_color = EDITOR_GET("text_edit/highlighting/base_type_color"); } -SyntaxHighlighter *GDScriptSyntaxHighlighter::create() { - return memnew(GDScriptSyntaxHighlighter); +Ref GDScriptSyntaxHighlighter::_create() const { + Ref syntax_highlighter; + syntax_highlighter.instance(); + return syntax_highlighter; } diff --git a/modules/gdscript/editor/gdscript_highlighter.h b/modules/gdscript/editor/gdscript_highlighter.h index 47ea5a3d62..c1de22167a 100644 --- a/modules/gdscript/editor/gdscript_highlighter.h +++ b/modules/gdscript/editor/gdscript_highlighter.h @@ -34,6 +34,8 @@ #include "scene/gui/text_edit.h" class GDScriptSyntaxHighlighter : public SyntaxHighlighter { + GDCLASS(GDScriptSyntaxHighlighter, SyntaxHighlighter) + private: enum Type { NONE, @@ -60,13 +62,13 @@ private: Color type_color; public: - static SyntaxHighlighter *create(); + virtual void _update_cache() override; + virtual Dictionary _get_line_syntax_highlighting(int p_line) override; - virtual void _update_cache(); - virtual Dictionary _get_line_syntax_highlighting(int p_line); + virtual String _get_name() const override; + virtual Array _get_supported_languages() const override; - virtual String _get_name() const; - virtual Array _get_supported_languages() const; + virtual Ref _create() const override; }; #endif // GDSCRIPT_HIGHLIGHTER_H -- cgit v1.2.3