summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-08-24 00:06:56 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-08-24 00:06:56 -0300
commit36e0a72c77348d4a1f2195937dff8dba88f7e044 (patch)
treea3e798e46199c18f729ab9c692dde990e3c3250b /scene
parent3d1c03187132677800b7f6bc609eeef8fe51f315 (diff)
-Code completion for enumerations
-Disabled GDNative and GDNativeScript so build compiles again
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/text_edit.cpp16
-rw-r--r--scene/gui/text_edit.h3
2 files changed, 15 insertions, 4 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 245e7e04be..2c50b4e854 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4319,6 +4319,7 @@ void TextEdit::_cancel_completion() {
return;
completion_active = false;
+ completion_forced = false;
update();
}
@@ -4386,13 +4387,19 @@ void TextEdit::_update_completion_candidates() {
}
}
- if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_strings[0].begins_with("\"")) {
+ if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_forced) {
cancel = true;
}
update();
- if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !completion_prefixes.has(String::chr(l[cofs - 1]))))) {
+ bool prev_is_prefix = false;
+ if (cofs > 0 && completion_prefixes.has(String::chr(l[cofs - 1])))
+ prev_is_prefix = true;
+ if (cofs > 1 && l[cofs - 1] == ' ' && completion_prefixes.has(String::chr(l[cofs - 2]))) //check with one space before prefix, to allow indent
+ prev_is_prefix = true;
+
+ if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !prev_is_prefix))) {
//none to complete, cancel
_cancel_completion();
return;
@@ -4481,6 +4488,8 @@ void TextEdit::query_code_comple() {
if (ofs > 0 && (inquote || _is_completable(l[ofs - 1]) || completion_prefixes.has(String::chr(l[ofs - 1]))))
emit_signal("request_completion");
+ else if (ofs > 1 && l[ofs - 1] == ' ' && completion_prefixes.has(String::chr(l[ofs - 2]))) //make it work with a space too, it's good enough
+ emit_signal("request_completion");
}
void TextEdit::set_code_hint(const String &p_hint) {
@@ -4492,12 +4501,13 @@ void TextEdit::set_code_hint(const String &p_hint) {
update();
}
-void TextEdit::code_complete(const Vector<String> &p_strings) {
+void TextEdit::code_complete(const Vector<String> &p_strings, bool p_forced) {
VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
raised_from_completion = true;
completion_strings = p_strings;
completion_active = true;
+ completion_forced = p_forced;
completion_current = "";
completion_index = 0;
_update_completion_candidates();
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 6321cad2da..7ab26322e7 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -205,6 +205,7 @@ class TextEdit : public Control {
Vector<String> completion_strings;
Vector<String> completion_options;
bool completion_active;
+ bool completion_forced;
String completion_current;
String completion_base;
int completion_index;
@@ -522,7 +523,7 @@ public:
void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata);
void set_completion(bool p_enabled, const Vector<String> &p_prefixes);
- void code_complete(const Vector<String> &p_strings);
+ void code_complete(const Vector<String> &p_strings, bool p_forced = false);
void set_code_hint(const String &p_hint);
void query_code_comple();