diff options
| author | Paulb23 <p_batty@hotmail.co.uk> | 2020-09-10 21:25:40 +0100 |
|---|---|---|
| committer | Paulb23 <p_batty@hotmail.co.uk> | 2021-06-01 15:38:45 +0100 |
| commit | 680dc9e81a79761f733db5ce7f3fa0c05b8e1ff6 (patch) | |
| tree | 7a588e2744f4ce5cf7e821742714779102e7bfca /editor | |
| parent | c9ce5367e3d35074193eb3999d9e2f9cbb8576c6 (diff) | |
| download | redot-engine-680dc9e81a79761f733db5ce7f3fa0c05b8e1ff6.tar.gz | |
Add comment and string tracking to CodeEdit
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/plugins/script_text_editor.cpp | 20 | ||||
| -rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 4 | ||||
| -rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 8 |
3 files changed, 32 insertions, 0 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index fe5d830239..99278a18ba 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -203,6 +203,26 @@ void ScriptTextEditor::_set_theme_for_script() { CodeEdit *text_edit = code_editor->get_text_editor(); text_edit->get_syntax_highlighter()->update_cache(); + List<String> strings; + script->get_language()->get_string_delimiters(&strings); + text_edit->clear_string_delimiters(); + for (List<String>::Element *E = strings.front(); E; E = E->next()) { + String string = E->get(); + String beg = string.get_slice(" ", 0); + String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); + text_edit->add_string_delimiter(beg, end, end == ""); + } + + List<String> comments; + script->get_language()->get_comment_delimiters(&comments); + text_edit->clear_comment_delimiters(); + for (List<String>::Element *E = comments.front(); E; E = E->next()) { + String comment = E->get(); + String beg = comment.get_slice(" ", 0); + String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); + text_edit->add_comment_delimiter(beg, end, end == ""); + } + /* add keywords for auto completion */ // singleton autoloads (as types, just as engine singletons are) Map<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list(); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index a210a46127..1f778dace9 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -154,6 +154,10 @@ void ShaderTextEditor::_load_theme_settings() { syntax_highlighter->add_color_region("/*", "*/", comment_color, false); syntax_highlighter->add_color_region("//", "", comment_color, true); + text_editor->clear_comment_delimiters(); + text_editor->add_comment_delimiter("/*", "*/", false); + text_editor->add_comment_delimiter("//", "", true); + if (warnings_panel) { // Warnings panel warnings_panel->add_theme_font_override("normal_font", EditorNode::get_singleton()->get_gui_base()->get_theme_font("main", "EditorFonts")); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index a0757439c3..98e1a1489e 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -848,6 +848,10 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { expression_syntax_highlighter->add_color_region("/*", "*/", comment_color, false); expression_syntax_highlighter->add_color_region("//", "", comment_color, true); + expression_box->clear_comment_delimiters(); + expression_box->add_comment_delimiter("/*", "*/", false); + expression_box->add_comment_delimiter("//", "", true); + expression_box->set_text(expression); expression_box->set_context_menu_enabled(false); expression_box->set_draw_line_numbers(true); @@ -2984,6 +2988,10 @@ void VisualShaderEditor::_notification(int p_what) { syntax_highlighter->add_color_region("/*", "*/", comment_color, false); syntax_highlighter->add_color_region("//", "", comment_color, true); + preview_text->clear_comment_delimiters(); + preview_text->add_comment_delimiter("/*", "*/", false); + preview_text->add_comment_delimiter("//", "", true); + error_text->add_theme_font_override("font", get_theme_font("status_source", "EditorFonts")); error_text->add_theme_font_size_override("font_size", get_theme_font_size("status_source_size", "EditorFonts")); error_text->add_theme_color_override("font_color", get_theme_color("error_color", "Editor")); |
