diff options
Diffstat (limited to 'editor/plugins/text_editor.cpp')
-rw-r--r-- | editor/plugins/text_editor.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 06ba8a6168..cbde382d67 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -65,18 +65,21 @@ void TextEditor::_load_theme_settings() { String TextEditor::get_name() { String name; - if (text_file->get_path().find("local://") == -1 && text_file->get_path().find("::") == -1) { - name = text_file->get_path().get_file(); - if (is_unsaved()) { - if (text_file->get_path().is_empty()) { - name = TTR("[unsaved]"); - } - name += "(*)"; + name = text_file->get_path().get_file(); + if (name.is_empty()) { + // This appears for newly created built-in text_files before saving the scene. + name = TTR("[unsaved]"); + } else if (text_file->is_built_in()) { + const String &text_file_name = text_file->get_name(); + if (!text_file_name.is_empty()) { + // If the built-in text_file has a custom resource name defined, + // display the built-in text_file name as follows: `ResourceName (scene_file.tscn)` + name = vformat("%s (%s)", text_file_name, name.get_slice("::", 0)); } - } else if (text_file->get_name() != "") { - name = text_file->get_name(); - } else { - name = text_file->get_class() + "(" + itos(text_file->get_instance_id()) + ")"; + } + + if (is_unsaved()) { + name += "(*)"; } return name; @@ -407,10 +410,6 @@ void TextEditor::_convert_case(CodeTextEditor::CaseStyle p_case) { code_editor->convert_case(p_case); } -void TextEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_syntax_highlighter", "highlighter"), &TextEditor::add_syntax_highlighter); -} - static ScriptEditorBase *create_editor(const RES &p_resource) { if (Object::cast_to<TextFile>(*p_resource)) { return memnew(TextEditor); @@ -426,7 +425,7 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { Ref<InputEventMouseButton> mb = ev; if (mb.is_valid()) { - if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) { + if (mb->get_button_index() == MouseButton::RIGHT) { CodeEdit *tx = code_editor->get_text_editor(); Point2i pos = tx->get_line_column_at_pos(mb->get_global_position() - tx->get_global_position()); @@ -508,8 +507,8 @@ void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is context_menu->set_item_disabled(context_menu->get_item_index(EDIT_UNDO), !tx->has_undo()); context_menu->set_item_disabled(context_menu->get_item_index(EDIT_REDO), !tx->has_redo()); - context_menu->set_position(get_global_transform().xform(p_position)); - context_menu->set_size(Vector2(1, 1)); + context_menu->set_position(get_screen_position() + p_position); + context_menu->reset_size(); context_menu->popup(); } |