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 --- editor/plugins/script_editor_plugin.cpp | 39 +++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'editor/plugins/script_editor_plugin.cpp') diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 3f17f1166f..237aefb1b9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -63,6 +63,8 @@ void ScriptEditorBase::_bind_methods() { // TODO: This signal is no use for VisualScript. ADD_SIGNAL(MethodInfo("search_in_files_requested", PropertyInfo(Variant::STRING, "text"))); ADD_SIGNAL(MethodInfo("replace_in_files_requested", PropertyInfo(Variant::STRING, "text"))); + + BIND_VMETHOD(MethodInfo("add_syntax_highlighter", PropertyInfo(Variant::OBJECT, "highlighter"))); } static bool _is_built_in_script(Script *p_script) { @@ -2019,8 +2021,11 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra if (p_resource->get_class_name() != StringName("VisualScript")) { bool highlighter_set = false; - for (int i = 0; i < syntax_highlighters_func_count; i++) { - SyntaxHighlighter *highlighter = syntax_highlighters_funcs[i](); + for (int i = 0; i < syntax_highlighters.size(); i++) { + Ref highlighter = syntax_highlighters[i]->_create(); + if (highlighter.is_null()) { + continue; + } se->add_syntax_highlighter(highlighter); if (script != nullptr && !highlighter_set) { @@ -2768,6 +2773,18 @@ Vector> ScriptEditor::get_open_scripts() const { return out_scripts; } +Array ScriptEditor::_get_open_script_editors() const { + Array script_editors; + for (int i = 0; i < tab_container->get_child_count(); i++) { + ScriptEditorBase *se = Object::cast_to(tab_container->get_child(i)); + if (!se) { + continue; + } + script_editors.push_back(se); + } + return script_editors; +} + void ScriptEditor::set_scene_root_script(Ref