diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-07-14 09:49:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-14 09:49:02 +0200 |
commit | ca5958d1806d96e2d54e8b3336a96f0a02381a86 (patch) | |
tree | c738df29c03b2f056d7d15aea9fe7b5a4ad46cd4 /editor/code_editor.cpp | |
parent | 28e8347d6cb1e5e8945ba62b9678849046038bb6 (diff) | |
parent | bc4cee44582d2a90d0792d6b213f00be1043000b (diff) | |
download | redot-engine-ca5958d1806d96e2d54e8b3336a96f0a02381a86.tar.gz |
Merge pull request #38440 from Paulb23/syntax_highlighter_refactor
Syntax highlighter refactor
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r-- | editor/code_editor.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 70747b4956..d8648310b6 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -837,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); } @@ -910,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")); @@ -1407,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; } |