diff options
Diffstat (limited to 'tools/editor/code_editor.cpp')
| -rw-r--r-- | tools/editor/code_editor.cpp | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index ea87ac625b..d86e48f74e 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -242,7 +242,7 @@ bool FindReplaceDialog::_search() { if (found) { - print_line("found"); + // print_line("found"); text_edit->cursor_set_line(line); text_edit->cursor_set_column(col+text.length()); text_edit->select(line,col,line,col+text.length()); @@ -479,15 +479,20 @@ void CodeTextEditor::_line_col_changed() { void CodeTextEditor::_text_changed() { - + code_complete_timer->start(); idle->start(); } +void CodeTextEditor::_code_complete_timer_timeout() { + if (enable_complete_timer) + text_editor->query_code_comple(); +} + void CodeTextEditor::_complete_request(const String& p_request, int p_line) { List<String> entries; _code_complete_script(text_editor->get_text(),p_request,p_line,&entries); - print_line("COMPLETE: "+p_request); + // print_line("COMPLETE: "+p_request); Vector<String> strs; strs.resize(entries.size()); int i=0; @@ -510,18 +515,31 @@ void CodeTextEditor::set_error(const String& p_error) { } -void CodeTextEditor::_update_font() { - - String editor_font = EditorSettings::get_singleton()->get("text_editor/font"); +void CodeTextEditor::_on_settings_change() { + + // FONTS + String editor_font = EDITOR_DEF("text_editor/font", ""); + bool font_overrode = false; if (editor_font!="") { Ref<Font> fnt = ResourceLoader::load(editor_font); if (fnt.is_valid()) { text_editor->add_font_override("font",fnt); - return; + font_overrode = true; } } + if(!font_overrode) + text_editor->add_font_override("font",get_font("source","Fonts")); + + // AUTO BRACE COMPLETION + text_editor->set_auto_brace_completion( + EDITOR_DEF("text_editor/auto_brace_complete", false) + ); - text_editor->add_font_override("font",get_font("source","Fonts")); + code_complete_timer->set_wait_time( + EDITOR_DEF("text_editor/code_complete_delay",.3f) + ); + + enable_complete_timer = EDITOR_DEF("text_editor/enable_code_completion_delay",true); } void CodeTextEditor::_text_changed_idle_timeout() { @@ -541,8 +559,9 @@ void CodeTextEditor::_bind_methods() { ObjectTypeDB::bind_method("_line_col_changed",&CodeTextEditor::_line_col_changed); ObjectTypeDB::bind_method("_text_changed",&CodeTextEditor::_text_changed); - ObjectTypeDB::bind_method("_update_font",&CodeTextEditor::_update_font); + 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); } @@ -567,6 +586,13 @@ 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); + enable_complete_timer = EDITOR_DEF("text_editor/enable_code_completion_delay",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); @@ -586,5 +612,7 @@ CodeTextEditor::CodeTextEditor() { text_editor->set_completion(true,cs); idle->connect("timeout", this,"_text_changed_idle_timeout"); - EditorSettings::get_singleton()->connect("settings_changed",this,"_update_font"); + code_complete_timer->connect("timeout", this,"_code_complete_timer_timeout"); + + EditorSettings::get_singleton()->connect("settings_changed",this,"_on_settings_change"); } |