diff options
Diffstat (limited to 'editor/plugins/text_editor.cpp')
| -rw-r--r-- | editor/plugins/text_editor.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 5bc3cafe19..ecdc4acf47 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -288,6 +288,10 @@ void TextEditor::trim_trailing_whitespace() { code_editor->trim_trailing_whitespace(); } +void TextEditor::trim_final_newlines() { + code_editor->trim_final_newlines(); +} + void TextEditor::insert_final_newline() { code_editor->insert_final_newline(); } @@ -414,6 +418,9 @@ void TextEditor::_edit_option(int p_op) { case EDIT_TRIM_TRAILING_WHITESAPCE: { trim_trailing_whitespace(); } break; + case EDIT_TRIM_FINAL_NEWLINES: { + trim_final_newlines(); + } break; case EDIT_CONVERT_INDENT_TO_SPACES: { code_editor->set_indent_using_spaces(true); convert_indent(); @@ -607,7 +614,7 @@ TextEditor::TextEditor() { context_menu = memnew(PopupMenu); add_child(context_menu); - context_menu->connect("id_pressed", callable_mp(this, &TextEditor::_edit_option)); + context_menu->connect(SceneStringName(id_pressed), callable_mp(this, &TextEditor::_edit_option)); edit_hb = memnew(HBoxContainer); @@ -617,7 +624,7 @@ TextEditor::TextEditor() { edit_menu->set_text(TTR("Edit")); edit_menu->set_switch_on_hover(true); edit_menu->connect("about_to_popup", callable_mp(this, &TextEditor::_prepare_edit_menu)); - edit_menu->get_popup()->connect("id_pressed", callable_mp(this, &TextEditor::_edit_option)); + edit_menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &TextEditor::_edit_option)); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_undo"), EDIT_UNDO); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_redo"), EDIT_REDO); @@ -641,6 +648,7 @@ TextEditor::TextEditor() { edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_lines"), EDIT_DUPLICATE_LINES); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_word_wrap"), EDIT_TOGGLE_WORD_WRAP); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_final_newlines"), EDIT_TRIM_FINAL_NEWLINES); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS); @@ -650,11 +658,11 @@ TextEditor::TextEditor() { convert_case->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_uppercase"), EDIT_TO_UPPERCASE); convert_case->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_lowercase"), EDIT_TO_LOWERCASE); convert_case->add_shortcut(ED_GET_SHORTCUT("script_text_editor/capitalize"), EDIT_CAPITALIZE); - convert_case->connect("id_pressed", callable_mp(this, &TextEditor::_edit_option)); + convert_case->connect(SceneStringName(id_pressed), callable_mp(this, &TextEditor::_edit_option)); highlighter_menu = memnew(PopupMenu); edit_menu->get_popup()->add_submenu_node_item(TTR("Syntax Highlighter"), highlighter_menu); - highlighter_menu->connect("id_pressed", callable_mp(this, &TextEditor::_change_syntax_highlighter)); + highlighter_menu->connect(SceneStringName(id_pressed), callable_mp(this, &TextEditor::_change_syntax_highlighter)); Ref<EditorPlainTextSyntaxHighlighter> plain_highlighter; plain_highlighter.instantiate(); @@ -670,7 +678,7 @@ TextEditor::TextEditor() { edit_hb->add_child(search_menu); search_menu->set_text(TTR("Search")); search_menu->set_switch_on_hover(true); - search_menu->get_popup()->connect("id_pressed", callable_mp(this, &TextEditor::_edit_option)); + search_menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &TextEditor::_edit_option)); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT); @@ -685,7 +693,7 @@ TextEditor::TextEditor() { edit_hb->add_child(goto_menu); goto_menu->set_text(TTR("Go To")); goto_menu->set_switch_on_hover(true); - goto_menu->get_popup()->connect("id_pressed", callable_mp(this, &TextEditor::_edit_option)); + goto_menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &TextEditor::_edit_option)); goto_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE); goto_menu->get_popup()->add_separator(); |
