summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-08-12 10:00:47 +0200
committerGitHub <noreply@github.com>2019-08-12 10:00:47 +0200
commit6c8434a98d22e9d50008a1d143a935a1e996d7f4 (patch)
treebfcb76b72c4a98f4f4860ba32265391db561cf19 /editor/plugins
parent72670788bbb93f4a8e0e2bd92499b23d06c122d8 (diff)
parent68ce87fbab511ada7fd17baa41972bcc9d73d036 (diff)
Merge pull request #31251 from YeldhamDev/text_editor_goto_full
Move "Go to Line..." from "Edit" to "Go To" in text editor
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/text_editor.cpp47
-rw-r--r--editor/plugins/text_editor.h2
2 files changed, 28 insertions, 21 deletions
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index a8fbadb773..eb0794ba77 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -221,19 +221,19 @@ void TextEditor::_validate_script() {
void TextEditor::_update_bookmark_list() {
- bookmarks_menu->get_popup()->clear();
+ bookmarks_menu->clear();
- bookmarks_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE);
- bookmarks_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_bookmarks"), BOOKMARK_REMOVE_ALL);
- bookmarks_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT);
- bookmarks_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
+ bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE);
+ bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_bookmarks"), BOOKMARK_REMOVE_ALL);
+ bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT);
+ bookmarks_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
Array bookmark_list = code_editor->get_text_edit()->get_bookmarks_array();
if (bookmark_list.size() == 0) {
return;
}
- bookmarks_menu->get_popup()->add_separator();
+ bookmarks_menu->add_separator();
for (int i = 0; i < bookmark_list.size(); i++) {
String line = code_editor->get_text_edit()->get_line(bookmark_list[i]).strip_edges();
@@ -242,17 +242,17 @@ void TextEditor::_update_bookmark_list() {
line = line.substr(0, 50);
}
- bookmarks_menu->get_popup()->add_item(String::num((int)bookmark_list[i] + 1) + " - \"" + line + "\"");
- bookmarks_menu->get_popup()->set_item_metadata(bookmarks_menu->get_popup()->get_item_count() - 1, bookmark_list[i]);
+ bookmarks_menu->add_item(String::num((int)bookmark_list[i] + 1) + " - \"" + line + "\"");
+ bookmarks_menu->set_item_metadata(bookmarks_menu->get_item_count() - 1, bookmark_list[i]);
}
}
void TextEditor::_bookmark_item_pressed(int p_idx) {
if (p_idx < 4) { // Any item before the separator.
- _edit_option(bookmarks_menu->get_popup()->get_item_id(p_idx));
+ _edit_option(bookmarks_menu->get_item_id(p_idx));
} else {
- code_editor->goto_line(bookmarks_menu->get_popup()->get_item_metadata(p_idx));
+ code_editor->goto_line(bookmarks_menu->get_item_metadata(p_idx));
}
}
@@ -636,11 +636,6 @@ TextEditor::TextEditor() {
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT);
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV);
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace"), SEARCH_REPLACE);
- search_menu->get_popup()->add_separator();
- search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE);
-
- goto_line_dialog = memnew(GotoLineDialog);
- add_child(goto_line_dialog);
edit_menu = memnew(MenuButton);
edit_menu->set_text(TTR("Edit"));
@@ -689,13 +684,25 @@ TextEditor::TextEditor() {
highlighter_menu->add_radio_check_item(TTR("Standard"));
highlighter_menu->connect("id_pressed", this, "_change_syntax_highlighter");
- bookmarks_menu = memnew(MenuButton);
- edit_hb->add_child(bookmarks_menu);
- bookmarks_menu->set_text(TTR("Bookmarks"));
- bookmarks_menu->set_switch_on_hover(true);
+ MenuButton *goto_menu = memnew(MenuButton);
+ 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", this, "_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();
+
+ bookmarks_menu = memnew(PopupMenu);
+ bookmarks_menu->set_name(TTR("Bookmarks"));
+ goto_menu->get_popup()->add_child(bookmarks_menu);
+ goto_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "Bookmarks");
_update_bookmark_list();
bookmarks_menu->connect("about_to_show", this, "_update_bookmark_list");
- bookmarks_menu->get_popup()->connect("index_pressed", this, "_bookmark_item_pressed");
+ bookmarks_menu->connect("index_pressed", this, "_bookmark_item_pressed");
+
+ goto_line_dialog = memnew(GotoLineDialog);
+ add_child(goto_line_dialog);
code_editor->get_text_edit()->set_drag_forwarding(this);
}
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index c0d4052646..c69e1672c5 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -46,7 +46,7 @@ private:
MenuButton *edit_menu;
PopupMenu *highlighter_menu;
MenuButton *search_menu;
- MenuButton *bookmarks_menu;
+ PopupMenu *bookmarks_menu;
PopupMenu *context_menu;
GotoLineDialog *goto_line_dialog;