diff options
Diffstat (limited to 'editor/plugins/script_text_editor.cpp')
| -rw-r--r-- | editor/plugins/script_text_editor.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 1a3092b6e..89dc358d0 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -75,9 +75,14 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->clear_colors(); - /* keyword color */ + /* color from color_theme or from editor color */ + + Color background_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)); + if (EDITOR_DEF("text_editor/theme/adapted_code_editor_background_color", false)) + background_color = get_color("dark_color_1", "Editor"); - text_edit->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0))); + /* keyword color */ + text_edit->add_color_override("background_color", background_color); text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0))); text_edit->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244"))); text_edit->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"))); @@ -597,13 +602,13 @@ void ScriptEditor::_update_modified_scripts_for_external_editor(Ref<Script> p_fo } } -void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code, List<String> *r_options) { +void ScriptTextEditor::_code_complete_scripts(void *p_ud, const String &p_code, List<String> *r_options, bool &r_force) { ScriptTextEditor *ste = (ScriptTextEditor *)p_ud; - ste->_code_complete_script(p_code, r_options); + ste->_code_complete_script(p_code, r_options, r_force); } -void ScriptTextEditor::_code_complete_script(const String &p_code, List<String> *r_options) { +void ScriptTextEditor::_code_complete_script(const String &p_code, List<String> *r_options, bool &r_force) { if (color_panel->is_visible_in_tree()) return; Node *base = get_tree()->get_edited_scene_root(); @@ -611,7 +616,7 @@ void ScriptTextEditor::_code_complete_script(const String &p_code, List<String> base = _find_node_for_script(base, base, script); } String hint; - Error err = script->get_language()->complete_code(p_code, script->get_path().get_base_dir(), base, r_options, hint); + Error err = script->get_language()->complete_code(p_code, script->get_path().get_base_dir(), base, r_options, r_force, hint); if (hint != "") { code_editor->get_text_edit()->set_code_hint(hint); } @@ -972,16 +977,27 @@ void ScriptTextEditor::_edit_option(int p_op) { Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; + + te->begin_complex_operation(); int begin, end; if (te->is_selection_active()) { begin = te->get_selection_from_line(); end = te->get_selection_to_line(); + // ignore if the cursor is not past the first column + if (te->get_selection_to_column() == 0) { + end--; + } } else { begin = 0; end = te->get_line_count() - 1; } scr->get_language()->auto_indent_code(text, begin, end); - te->set_text(text); + Vector<String> lines = text.split("\n"); + for (int i = begin; i <= end; ++i) { + te->set_line(i, lines[i]); + } + + te->end_complex_operation(); } break; case EDIT_TRIM_TRAILING_WHITESAPCE: { @@ -1214,7 +1230,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data } if (res->get_path().is_resource_file()) { - EditorNode::get_singleton()->show_warning("Only resources from filesystem can be dropped."); + EditorNode::get_singleton()->show_warning(TTR("Only resources from filesystem can be dropped.")); return; } |
