| 612 | } |
| 613 | |
| 614 | TextEditor::TextEditor() { |
| 615 | code_editor = memnew(CodeTextEditor); |
| 616 | add_child(code_editor); |
| 617 | code_editor->add_theme_constant_override("separation", 0); |
| 618 | code_editor->connect("load_theme_settings", callable_mp(this, &TextEditor::_load_theme_settings)); |
| 619 | code_editor->connect("validate_script", callable_mp(this, &TextEditor::_validate_script)); |
| 620 | code_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); |
| 621 | code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); |
| 622 | code_editor->show_toggle_files_button(); |
| 623 | code_editor->set_toggle_list_control(ScriptEditor::get_singleton()->get_left_list_split()); |
| 624 | |
| 625 | update_settings(); |
| 626 | |
| 627 | code_editor->get_text_editor()->set_context_menu_enabled(false); |
| 628 | code_editor->get_text_editor()->connect(SceneStringName(gui_input), callable_mp(this, &TextEditor::_text_edit_gui_input)); |
| 629 | |
| 630 | context_menu = memnew(PopupMenu); |
| 631 | add_child(context_menu); |
| 632 | context_menu->connect(SceneStringName(id_pressed), callable_mp(this, &TextEditor::_edit_option)); |
| 633 | |
| 634 | edit_hb = memnew(HBoxContainer); |
| 635 | |
| 636 | edit_menu = memnew(MenuButton); |
| 637 | edit_menu->set_flat(false); |
| 638 | edit_menu->set_theme_type_variation("FlatMenuButton"); |
| 639 | edit_menu->set_shortcut_context(this); |
| 640 | edit_hb->add_child(edit_menu); |
| 641 | edit_menu->set_text(TTRC("Edit")); |
| 642 | edit_menu->set_switch_on_hover(true); |
| 643 | edit_menu->connect("about_to_popup", callable_mp(this, &TextEditor::_prepare_edit_menu)); |
| 644 | edit_menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &TextEditor::_edit_option)); |
| 645 | |
| 646 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_undo"), EDIT_UNDO); |
| 647 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_redo"), EDIT_REDO); |
| 648 | edit_menu->get_popup()->add_separator(); |
| 649 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_cut"), EDIT_CUT); |
| 650 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_copy"), EDIT_COPY); |
| 651 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_paste"), EDIT_PASTE); |
| 652 | edit_menu->get_popup()->add_separator(); |
| 653 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_text_select_all"), EDIT_SELECT_ALL); |
| 654 | edit_menu->get_popup()->add_separator(); |
| 655 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_up"), EDIT_MOVE_LINE_UP); |
| 656 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_down"), EDIT_MOVE_LINE_DOWN); |
| 657 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent"), EDIT_INDENT); |
| 658 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unindent"), EDIT_UNINDENT); |
| 659 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/delete_line"), EDIT_DELETE_LINE); |
| 660 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE); |
| 661 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_all_lines"), EDIT_FOLD_ALL_LINES); |
| 662 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_all_lines"), EDIT_UNFOLD_ALL_LINES); |
| 663 | edit_menu->get_popup()->add_separator(); |
| 664 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_selection"), EDIT_DUPLICATE_SELECTION); |
| 665 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_lines"), EDIT_DUPLICATE_LINES); |
| 666 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_word_wrap"), EDIT_TOGGLE_WORD_WRAP); |
| 667 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE); |
| 668 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_final_newlines"), EDIT_TRIM_FINAL_NEWLINES); |
| 669 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES); |
| 670 | edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS); |
| 671 |
nothing calls this directly
no test coverage detected