summaryrefslogtreecommitdiffstats
path: root/tools/editor/code_editor.cpp
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2014-05-06 12:30:32 -0300
committerreduz <reduzio@gmail.com>2014-05-06 12:30:32 -0300
commitac39af73b1b987ef8d3b9898e841a420f36a12ac (patch)
tree695acca948bd96903290a15372d09659ce27fad9 /tools/editor/code_editor.cpp
parent5044bead5f344a24f971f0bb0c8d282f1785f06a (diff)
parent0771020c8357eee5ea9c395782089d867db84c05 (diff)
downloadredot-engine-ac39af73b1b987ef8d3b9898e841a420f36a12ac.tar.gz
Merge pull request #374 from marynate/PR-code-complete
Add auto code completion (without press Ctrl+Space manually)
Diffstat (limited to 'tools/editor/code_editor.cpp')
-rw-r--r--tools/editor/code_editor.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp
index a780c0173e..994e3e1e68 100644
--- a/tools/editor/code_editor.cpp
+++ b/tools/editor/code_editor.cpp
@@ -479,10 +479,15 @@ void CodeTextEditor::_line_col_changed() {
void CodeTextEditor::_text_changed() {
-
+ code_complete_timer->start();
idle->start();
}
+void CodeTextEditor::_code_complete_timer_timeout() {
+
+ text_editor->query_code_comple();
+}
+
void CodeTextEditor::_complete_request(const String& p_request, int p_line) {
List<String> entries;
@@ -551,6 +556,7 @@ void CodeTextEditor::_bind_methods() {
ObjectTypeDB::bind_method("_text_changed",&CodeTextEditor::_text_changed);
ObjectTypeDB::bind_method("_on_settings_change",&CodeTextEditor::_on_settings_change);
ObjectTypeDB::bind_method("_text_changed_idle_timeout",&CodeTextEditor::_text_changed_idle_timeout);
+ ObjectTypeDB::bind_method("_code_complete_timer_timeout",&CodeTextEditor::_code_complete_timer_timeout);
ObjectTypeDB::bind_method("_complete_request",&CodeTextEditor::_complete_request);
}
@@ -575,6 +581,11 @@ CodeTextEditor::CodeTextEditor() {
idle->set_one_shot(true);
idle->set_wait_time(EDITOR_DEF("text_editor/idle_parse_delay",2));
+ code_complete_timer = memnew(Timer);
+ add_child(code_complete_timer);
+ code_complete_timer->set_one_shot(true);
+ code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/code_complete_delay",.3f));
+
error = memnew( Label );
add_child(error);
error->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
@@ -593,6 +604,7 @@ CodeTextEditor::CodeTextEditor() {
cs.push_back(".");
text_editor->set_completion(true,cs);
idle->connect("timeout", this,"_text_changed_idle_timeout");
+ code_complete_timer->connect("timeout", this,"_code_complete_timer_timeout");
EditorSettings::get_singleton()->connect("settings_changed",this,"_on_settings_change");
}