summaryrefslogtreecommitdiff
path: root/editor/code_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r--editor/code_editor.cpp54
1 files changed, 32 insertions, 22 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index b73a27214d..d8648310b6 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -108,22 +108,25 @@ void FindReplaceBar::_notification(int p_what) {
void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> k = p_event;
- if (k.is_valid()) {
- if (k->is_pressed() && (text_edit->has_focus() || vbc_lineedit->is_a_parent_of(get_focus_owner()))) {
- bool accepted = true;
-
- switch (k->get_keycode()) {
- case KEY_ESCAPE: {
- _hide_bar();
- } break;
- default: {
- accepted = false;
- } break;
- }
+ if (!k.is_valid() || !k->is_pressed()) {
+ return;
+ }
- if (accepted) {
- accept_event();
- }
+ Control *focus_owner = get_focus_owner();
+ if (text_edit->has_focus() || (focus_owner && vbc_lineedit->is_a_parent_of(focus_owner))) {
+ bool accepted = true;
+
+ switch (k->get_keycode()) {
+ case KEY_ESCAPE: {
+ _hide_bar();
+ } break;
+ default: {
+ accepted = false;
+ } break;
+ }
+
+ if (accepted) {
+ accept_event();
}
}
}
@@ -834,7 +837,14 @@ void CodeTextEditor::_complete_request() {
}
for (List<ScriptCodeCompletionOption>::Element *E = entries.front(); E; E = E->next()) {
- E->get().icon = _get_completion_icon(E->get());
+ 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;
+ }
}
text_editor->code_complete(entries, forced);
}
@@ -907,7 +917,10 @@ bool CodeTextEditor::_add_font_size(int p_delta) {
}
void CodeTextEditor::update_editor_settings() {
- text_editor->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
+ completion_font_color = EDITOR_GET("text_editor/highlighting/completion_font_color");
+ completion_string_color = EDITOR_GET("text_editor/highlighting/string_color");
+ completion_comment_color = EDITOR_GET("text_editor/highlighting/comment_color");
+
text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
text_editor->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type"));
@@ -1404,11 +1417,8 @@ Variant CodeTextEditor::get_edit_state() {
state["breakpoints"] = text_editor->get_breakpoints_array();
state["bookmarks"] = text_editor->get_bookmarks_array();
- state["syntax_highlighter"] = TTR("Standard");
- SyntaxHighlighter *syntax_highlighter = text_editor->_get_syntax_highlighting();
- if (syntax_highlighter) {
- state["syntax_highlighter"] = syntax_highlighter->get_name();
- }
+ Ref<EditorSyntaxHighlighter> syntax_highlighter = text_editor->get_syntax_highlighter();
+ state["syntax_highlighter"] = syntax_highlighter->_get_name();
return state;
}