summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorPaulb23 <p_batty@hotmail.co.uk>2020-09-13 21:14:20 +0100
committerPaulb23 <p_batty@hotmail.co.uk>2021-06-01 15:38:45 +0100
commit1c166737986a4c30fa5327f5f5eb97906dfa8abf (patch)
treeb572b8346d8e847bba3bc9134cb108ef78adbf45 /editor
parent680dc9e81a79761f733db5ce7f3fa0c05b8e1ff6 (diff)
downloadredot-engine-1c166737986a4c30fa5327f5f5eb97906dfa8abf.tar.gz
Move and expose AutoComplete in CodeEdit
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp29
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--editor/plugins/shader_editor_plugin.cpp2
3 files changed, 18 insertions, 15 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 97ba5d7a5f..67a2d11670 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) {
@@ -1847,15 +1848,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/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 99278a18ba..6836a877dd 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1076,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();
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 1f778dace9..c100923167 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -352,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();