diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/code_editor.cpp | 33 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 1 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 26 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 10 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 8 |
5 files changed, 53 insertions, 25 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 97ba5d7a5f..be42eab636 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -816,12 +816,12 @@ void CodeTextEditor::_code_complete_timer_timeout() { if (!is_visible_in_tree()) { return; } - text_editor->query_code_comple(); + text_editor->request_code_completion(); } void CodeTextEditor::_complete_request() { List<ScriptCodeCompletionOption> entries; - String ctext = text_editor->get_text_for_completion(); + String ctext = text_editor->get_text_for_code_completion(); _code_complete_script(ctext, &entries); bool forced = false; if (code_complete_func) { @@ -832,16 +832,17 @@ void CodeTextEditor::_complete_request() { } for (List<ScriptCodeCompletionOption>::Element *E = entries.front(); E; E = E->next()) { - ScriptCodeCompletionOption *e = &E->get(); - e->icon = _get_completion_icon(*e); - e->font_color = completion_font_color; - if (e->insert_text.begins_with("\"") || e->insert_text.begins_with("\'")) { - e->font_color = completion_string_color; - } else if (e->insert_text.begins_with("#") || e->insert_text.begins_with("//")) { - e->font_color = completion_comment_color; + ScriptCodeCompletionOption &e = E->get(); + + Color font_color = completion_font_color; + if (e.insert_text.begins_with("\"") || e.insert_text.begins_with("\'")) { + font_color = completion_string_color; + } else if (e.insert_text.begins_with("#") || e.insert_text.begins_with("//")) { + font_color = completion_comment_color; } + text_editor->add_code_completion_option((CodeEdit::CodeCompletionKind)e.kind, e.display, e.insert_text, font_color, _get_completion_icon(e), e.default_value); } - text_editor->code_complete(entries, forced); + text_editor->update_code_completion_options(forced); } Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptCodeCompletionOption &p_option) { @@ -1563,9 +1564,7 @@ void CodeTextEditor::_on_settings_change() { EDITOR_GET("text_editor/completion/code_complete_delay")); // Call hint settings. - text_editor->set_callhint_settings( - EDITOR_GET("text_editor/completion/put_callhint_tooltip_below_current_line"), - EDITOR_GET("text_editor/completion/callhint_tooltip_offset")); + text_editor->set_code_hint_draw_below(EDITOR_GET("text_editor/completion/put_callhint_tooltip_below_current_line")); idle->set_wait_time(EDITOR_GET("text_editor/completion/idle_parse_delay")); } @@ -1847,15 +1846,17 @@ CodeTextEditor::CodeTextEditor() { text_editor->connect("gui_input", callable_mp(this, &CodeTextEditor::_text_editor_gui_input)); text_editor->connect("cursor_changed", callable_mp(this, &CodeTextEditor::_line_col_changed)); text_editor->connect("text_changed", callable_mp(this, &CodeTextEditor::_text_changed)); - text_editor->connect("request_completion", callable_mp(this, &CodeTextEditor::_complete_request)); - Vector<String> cs; + text_editor->connect("request_code_completion", callable_mp(this, &CodeTextEditor::_complete_request)); + TypedArray<String> cs; cs.push_back("."); cs.push_back(","); cs.push_back("("); cs.push_back("="); cs.push_back("$"); cs.push_back("@"); - text_editor->set_completion(true, cs); + cs.push_back("\""); + cs.push_back("\'"); + text_editor->set_code_completion_prefixes(cs); idle->connect("timeout", callable_mp(this, &CodeTextEditor::_text_changed_idle_timeout)); code_complete_timer->connect("timeout", callable_mp(this, &CodeTextEditor::_code_complete_timer_timeout)); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 1255526a4a..e4072f7d4b 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -571,7 +571,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/completion/code_complete_delay", 0.3); hints["text_editor/completion/code_complete_delay"] = PropertyInfo(Variant::FLOAT, "text_editor/completion/code_complete_delay", PROPERTY_HINT_RANGE, "0.01, 5, 0.01"); _initial_set("text_editor/completion/put_callhint_tooltip_below_current_line", true); - _initial_set("text_editor/completion/callhint_tooltip_offset", Vector2()); _initial_set("text_editor/completion/complete_file_paths", true); _initial_set("text_editor/completion/add_type_hints", false); _initial_set("text_editor/completion/use_single_quotes", false); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index fe5d830239..a29e51e8fb 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(); @@ -1056,7 +1076,7 @@ void ScriptTextEditor::_edit_option(int p_op) { _edit_option_toggle_inline_comment(); } break; case EDIT_COMPLETE: { - tx->query_code_comple(); + tx->request_code_completion(true); } break; case EDIT_AUTO_INDENT: { String text = tx->get_text(); @@ -1804,9 +1824,7 @@ ScriptTextEditor::ScriptTextEditor() { update_settings(); - code_editor->get_text_editor()->set_callhint_settings( - EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"), - EditorSettings::get_singleton()->get("text_editor/completion/callhint_tooltip_offset")); + code_editor->get_text_editor()->set_code_hint_draw_below(EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line")); code_editor->get_text_editor()->set_select_identifiers_on_hover(true); code_editor->get_text_editor()->set_context_menu_enabled(false); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index a210a46127..3beef78bfc 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")); @@ -348,7 +352,7 @@ void ShaderEditor::_menu_option(int p_option) { } break; case EDIT_COMPLETE: { - shader_editor->get_text_editor()->query_code_comple(); + shader_editor->get_text_editor()->request_code_completion(); } break; case SEARCH_FIND: { shader_editor->get_find_replace_bar()->popup_search(); @@ -659,9 +663,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &ShaderEditor::_editor_settings_changed)); ProjectSettingsEditor::get_singleton()->connect("confirmed", callable_mp(this, &ShaderEditor::_project_settings_changed)); - shader_editor->get_text_editor()->set_callhint_settings( - EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"), - EditorSettings::get_singleton()->get("text_editor/completion/callhint_tooltip_offset")); + shader_editor->get_text_editor()->set_code_hint_draw_below(EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line")); shader_editor->get_text_editor()->set_select_identifiers_on_hover(true); shader_editor->get_text_editor()->set_context_menu_enabled(false); 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")); |