summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/code_editor.cpp73
-rw-r--r--editor/code_editor.h5
-rw-r--r--editor/editor_settings.cpp2
-rw-r--r--editor/editor_themes.cpp2
-rw-r--r--editor/plugins/script_text_editor.cpp35
-rw-r--r--editor/plugins/script_text_editor.h4
-rw-r--r--editor/plugins/shader_editor_plugin.cpp28
-rw-r--r--editor/plugins/shader_editor_plugin.h4
-rw-r--r--editor/plugins/text_editor.cpp28
-rw-r--r--editor/plugins/text_editor.h4
10 files changed, 184 insertions, 1 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index ec984e480a..e9a1403d5a 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -764,6 +764,7 @@ void CodeTextEditor::update_editor_settings() {
text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
+ text_editor->set_bookmark_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_bookmark_gutter"));
text_editor->set_breakpoint_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter"));
text_editor->set_hiding_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding"));
text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding"));
@@ -1203,6 +1204,7 @@ Variant CodeTextEditor::get_edit_state() {
state["folded_lines"] = text_editor->get_folded_lines();
state["breakpoints"] = text_editor->get_breakpoints_array();
+ state["bookmarks"] = text_editor->get_bookmarks_array();
state["syntax_highlighter"] = TTR("Standard");
SyntaxHighlighter *syntax_highlighter = text_editor->_get_syntax_highlighting();
@@ -1240,6 +1242,13 @@ void CodeTextEditor::set_edit_state(const Variant &p_state) {
}
}
+ if (state.has("bookmarks")) {
+ Array bookmarks = state["bookmarks"];
+ for (int i = 0; i < bookmarks.size(); i++) {
+ text_editor->set_line_as_bookmark(bookmarks[i], true);
+ }
+ }
+
text_editor->grab_focus();
}
@@ -1357,6 +1366,70 @@ void CodeTextEditor::set_warning_nb(int p_warning_nb) {
_set_show_warnings_panel(false);
}
+void CodeTextEditor::toggle_bookmark() {
+
+ int line = text_editor->cursor_get_line();
+ text_editor->set_line_as_bookmark(line, !text_editor->is_line_set_as_bookmark(line));
+}
+
+void CodeTextEditor::goto_next_bookmark() {
+
+ List<int> bmarks;
+ text_editor->get_bookmarks(&bmarks);
+ if (bmarks.size() <= 0) {
+ return;
+ }
+
+ int line = text_editor->cursor_get_line();
+ if (line >= bmarks[bmarks.size() - 1]) {
+ text_editor->unfold_line(bmarks[0]);
+ text_editor->cursor_set_line(bmarks[0]);
+ } else {
+ for (List<int>::Element *E = bmarks.front(); E; E = E->next()) {
+ int bline = E->get();
+ if (bline > line) {
+ text_editor->unfold_line(bline);
+ text_editor->cursor_set_line(bline);
+ return;
+ }
+ }
+ }
+}
+
+void CodeTextEditor::goto_prev_bookmark() {
+
+ List<int> bmarks;
+ text_editor->get_bookmarks(&bmarks);
+ if (bmarks.size() <= 0) {
+ return;
+ }
+
+ int line = text_editor->cursor_get_line();
+ if (line <= bmarks[0]) {
+ text_editor->unfold_line(bmarks[bmarks.size() - 1]);
+ text_editor->cursor_set_line(bmarks[bmarks.size() - 1]);
+ } else {
+ for (List<int>::Element *E = bmarks.back(); E; E = E->prev()) {
+ int bline = E->get();
+ if (bline < line) {
+ text_editor->unfold_line(bline);
+ text_editor->cursor_set_line(bline);
+ return;
+ }
+ }
+ }
+}
+
+void CodeTextEditor::remove_all_bookmarks() {
+
+ List<int> bmarks;
+ text_editor->get_bookmarks(&bmarks);
+
+ for (List<int>::Element *E = bmarks.front(); E; E = E->next()) {
+ text_editor->set_line_as_bookmark(E->get(), false);
+ }
+}
+
void CodeTextEditor::_bind_methods() {
ClassDB::bind_method("_text_editor_gui_input", &CodeTextEditor::_text_editor_gui_input);
diff --git a/editor/code_editor.h b/editor/code_editor.h
index b98af377ce..5c6b54ae44 100644
--- a/editor/code_editor.h
+++ b/editor/code_editor.h
@@ -234,6 +234,11 @@ public:
virtual void apply_code() {}
void goto_error();
+ void toggle_bookmark();
+ void goto_next_bookmark();
+ void goto_prev_bookmark();
+ void remove_all_bookmarks();
+
void set_code_complete_func(CodeTextEditorCodeCompleteFunc p_code_complete_func, void *p_ud);
CodeTextEditor();
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index e80d3e1b37..b71deb4bf4 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -429,6 +429,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
// Line numbers
_initial_set("text_editor/line_numbers/show_line_numbers", true);
_initial_set("text_editor/line_numbers/line_numbers_zero_padded", false);
+ _initial_set("text_editor/line_numbers/show_bookmark_gutter", true);
_initial_set("text_editor/line_numbers/show_breakpoint_gutter", true);
_initial_set("text_editor/line_numbers/show_info_gutter", true);
_initial_set("text_editor/line_numbers/code_folding", true);
@@ -647,6 +648,7 @@ void EditorSettings::_load_default_text_editor_theme() {
_initial_set("text_editor/highlighting/function_color", Color::html("66a2ce"));
_initial_set("text_editor/highlighting/member_variable_color", Color::html("e64e59"));
_initial_set("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4));
+ _initial_set("text_editor/highlighting/bookmark_color", Color(0.08, 0.49, 0.98));
_initial_set("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2));
_initial_set("text_editor/highlighting/executing_line_color", Color(0.2, 0.8, 0.2, 0.4));
_initial_set("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8));
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index b8dd29cecc..71714d8c55 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -1115,6 +1115,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
const Color function_color = main_color;
const Color member_variable_color = main_color.linear_interpolate(mono_color, 0.6);
const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3);
+ const Color bookmark_color = Color(0.08, 0.49, 0.98);
const Color breakpoint_color = error_color;
const Color executing_line_color = Color(0.2, 0.8, 0.2, 0.4);
const Color code_folding_color = alpha3;
@@ -1151,6 +1152,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
setting->set_initial_value("text_editor/highlighting/function_color", function_color, true);
setting->set_initial_value("text_editor/highlighting/member_variable_color", member_variable_color, true);
setting->set_initial_value("text_editor/highlighting/mark_color", mark_color, true);
+ setting->set_initial_value("text_editor/highlighting/bookmark_color", bookmark_color, true);
setting->set_initial_value("text_editor/highlighting/breakpoint_color", breakpoint_color, true);
setting->set_initial_value("text_editor/highlighting/executing_line_color", executing_line_color, true);
setting->set_initial_value("text_editor/highlighting/code_folding_color", code_folding_color, true);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index d40e67cc8c..2801c37fe5 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -213,6 +213,7 @@ void ScriptTextEditor::_load_theme_settings() {
Color function_color = EDITOR_GET("text_editor/highlighting/function_color");
Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
Color mark_color = EDITOR_GET("text_editor/highlighting/mark_color");
+ Color bookmark_color = EDITOR_GET("text_editor/highlighting/bookmark_color");
Color breakpoint_color = EDITOR_GET("text_editor/highlighting/breakpoint_color");
Color executing_line_color = EDITOR_GET("text_editor/highlighting/executing_line_color");
Color code_folding_color = EDITOR_GET("text_editor/highlighting/code_folding_color");
@@ -245,6 +246,7 @@ void ScriptTextEditor::_load_theme_settings() {
text_edit->add_color_override("number_color", number_color);
text_edit->add_color_override("function_color", function_color);
text_edit->add_color_override("member_variable_color", member_variable_color);
+ text_edit->add_color_override("bookmark_color", bookmark_color);
text_edit->add_color_override("breakpoint_color", breakpoint_color);
text_edit->add_color_override("executing_line_color", executing_line_color);
text_edit->add_color_override("mark_color", mark_color);
@@ -1066,6 +1068,22 @@ void ScriptTextEditor::_edit_option(int p_op) {
goto_line_dialog->popup_find_line(tx);
} break;
+ case BOOKMARK_TOGGLE: {
+
+ code_editor->toggle_bookmark();
+ } break;
+ case BOOKMARK_GOTO_NEXT: {
+
+ code_editor->goto_next_bookmark();
+ } break;
+ case BOOKMARK_GOTO_PREV: {
+
+ code_editor->goto_prev_bookmark();
+ } break;
+ case BOOKMARK_REMOVE_ALL: {
+
+ code_editor->remove_all_bookmarks();
+ } break;
case DEBUG_TOGGLE_BREAKPOINT: {
int line = tx->cursor_get_line();
@@ -1499,6 +1517,7 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT);
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT);
context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT);
+ context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE);
if (p_selection) {
context_menu->add_separator();
@@ -1651,6 +1670,16 @@ ScriptTextEditor::ScriptTextEditor() {
search_menu->get_popup()->connect("id_pressed", this, "_edit_option");
+ PopupMenu *bookmarks = memnew(PopupMenu);
+ bookmarks->set_name("bookmarks");
+ edit_menu->get_popup()->add_child(bookmarks);
+ edit_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "bookmarks");
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE);
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_bookmarks"), BOOKMARK_REMOVE_ALL);
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT);
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
+ bookmarks->connect("id_pressed", this, "_edit_option");
+
edit_hb->add_child(edit_menu);
quick_open = memnew(ScriptEditorQuickOpen);
@@ -1692,6 +1721,10 @@ void ScriptTextEditor::register_editor() {
ED_SHORTCUT("script_text_editor/indent_left", TTR("Indent Left"), 0);
ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), 0);
ED_SHORTCUT("script_text_editor/toggle_comment", TTR("Toggle Comment"), KEY_MASK_CMD | KEY_K);
+ ED_SHORTCUT("script_text_editor/toggle_bookmark", TTR("Toggle Bookmark"), KEY_MASK_CMD | KEY_MASK_ALT | KEY_B);
+ ED_SHORTCUT("script_text_editor/goto_next_bookmark", TTR("Go to Next Bookmark"), KEY_MASK_CMD | KEY_B);
+ ED_SHORTCUT("script_text_editor/goto_previous_bookmark", TTR("Go to Previous Bookmark"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_B);
+ ED_SHORTCUT("script_text_editor/remove_all_bookmarks", TTR("Remove All Bookmarks"), 0);
ED_SHORTCUT("script_text_editor/toggle_fold_line", TTR("Fold/Unfold Line"), KEY_MASK_ALT | KEY_F);
ED_SHORTCUT("script_text_editor/fold_all_lines", TTR("Fold All Lines"), 0);
ED_SHORTCUT("script_text_editor/unfold_all_lines", TTR("Unfold All Lines"), 0);
@@ -1699,7 +1732,7 @@ void ScriptTextEditor::register_editor() {
ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_C);
ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CTRL | KEY_SPACE);
#else
- ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD | KEY_B);
+ ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD | KEY_D);
ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CMD | KEY_SPACE);
#endif
ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KEY_MASK_CMD | KEY_MASK_ALT | KEY_T);
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 0dbc884594..bdfdf18d45 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -128,6 +128,10 @@ class ScriptTextEditor : public ScriptEditorBase {
SEARCH_LOCATE_FUNCTION,
SEARCH_GOTO_LINE,
SEARCH_IN_FILES,
+ BOOKMARK_TOGGLE,
+ BOOKMARK_GOTO_NEXT,
+ BOOKMARK_GOTO_PREV,
+ BOOKMARK_REMOVE_ALL,
DEBUG_TOGGLE_BREAKPOINT,
DEBUG_REMOVE_ALL_BREAKPOINTS,
DEBUG_GOTO_NEXT_BREAKPOINT,
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 31660a9e19..a795405dfc 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -84,6 +84,7 @@ void ShaderTextEditor::_load_theme_settings() {
Color function_color = EDITOR_GET("text_editor/highlighting/function_color");
Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
Color mark_color = EDITOR_GET("text_editor/highlighting/mark_color");
+ Color bookmark_color = EDITOR_GET("text_editor/highlighting/bookmark_color");
Color breakpoint_color = EDITOR_GET("text_editor/highlighting/breakpoint_color");
Color executing_line_color = EDITOR_GET("text_editor/highlighting/executing_line_color");
Color code_folding_color = EDITOR_GET("text_editor/highlighting/code_folding_color");
@@ -113,6 +114,7 @@ void ShaderTextEditor::_load_theme_settings() {
get_text_edit()->add_color_override("function_color", function_color);
get_text_edit()->add_color_override("member_variable_color", member_variable_color);
get_text_edit()->add_color_override("mark_color", mark_color);
+ get_text_edit()->add_color_override("bookmark_color", bookmark_color);
get_text_edit()->add_color_override("breakpoint_color", breakpoint_color);
get_text_edit()->add_color_override("executing_line_color", executing_line_color);
get_text_edit()->add_color_override("code_folding_color", code_folding_color);
@@ -304,6 +306,22 @@ void ShaderEditor::_menu_option(int p_option) {
goto_line_dialog->popup_find_line(shader_editor->get_text_edit());
} break;
+ case BOOKMARK_TOGGLE: {
+
+ shader_editor->toggle_bookmark();
+ } break;
+ case BOOKMARK_GOTO_NEXT: {
+
+ shader_editor->goto_next_bookmark();
+ } break;
+ case BOOKMARK_GOTO_PREV: {
+
+ shader_editor->goto_prev_bookmark();
+ } break;
+ case BOOKMARK_REMOVE_ALL: {
+
+ shader_editor->remove_all_bookmarks();
+ } break;
}
if (p_option != SEARCH_FIND && p_option != SEARCH_REPLACE && p_option != SEARCH_GOTO_LINE) {
shader_editor->get_text_edit()->call_deferred("grab_focus");
@@ -535,6 +553,16 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE);
search_menu->get_popup()->connect("id_pressed", this, "_menu_option");
+ PopupMenu *bookmarks = memnew(PopupMenu);
+ bookmarks->set_name("bookmarks");
+ edit_menu->get_popup()->add_child(bookmarks);
+ edit_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "bookmarks");
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE);
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_bookmarks"), BOOKMARK_REMOVE_ALL);
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT);
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
+ bookmarks->connect("id_pressed", this, "_edit_option");
+
add_child(main_container);
main_container->add_child(hbc);
hbc->add_child(search_menu);
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index 46c78c1d33..28ac9faaa5 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -88,6 +88,10 @@ class ShaderEditor : public PanelContainer {
SEARCH_FIND_PREV,
SEARCH_REPLACE,
SEARCH_GOTO_LINE,
+ BOOKMARK_TOGGLE,
+ BOOKMARK_GOTO_NEXT,
+ BOOKMARK_GOTO_PREV,
+ BOOKMARK_REMOVE_ALL,
};
diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp
index becaae3567..43197c5675 100644
--- a/editor/plugins/text_editor.cpp
+++ b/editor/plugins/text_editor.cpp
@@ -93,6 +93,7 @@ void TextEditor::_load_theme_settings() {
Color function_color = EDITOR_GET("text_editor/highlighting/function_color");
Color member_variable_color = EDITOR_GET("text_editor/highlighting/member_variable_color");
Color mark_color = EDITOR_GET("text_editor/highlighting/mark_color");
+ Color bookmark_color = EDITOR_GET("text_editor/highlighting/bookmark_color");
Color breakpoint_color = EDITOR_GET("text_editor/highlighting/breakpoint_color");
Color executing_line_color = EDITOR_GET("text_editor/highlighting/executing_line_color");
Color code_folding_color = EDITOR_GET("text_editor/highlighting/code_folding_color");
@@ -127,6 +128,7 @@ void TextEditor::_load_theme_settings() {
text_edit->add_color_override("breakpoint_color", breakpoint_color);
text_edit->add_color_override("executing_line_color", executing_line_color);
text_edit->add_color_override("mark_color", mark_color);
+ text_edit->add_color_override("bookmark_color", bookmark_color);
text_edit->add_color_override("code_folding_color", code_folding_color);
text_edit->add_color_override("search_result_color", search_result_color);
text_edit->add_color_override("search_result_border_color", search_result_border_color);
@@ -438,6 +440,22 @@ void TextEditor::_edit_option(int p_op) {
goto_line_dialog->popup_find_line(tx);
} break;
+ case BOOKMARK_TOGGLE: {
+
+ code_editor->toggle_bookmark();
+ } break;
+ case BOOKMARK_GOTO_NEXT: {
+
+ code_editor->goto_next_bookmark();
+ } break;
+ case BOOKMARK_GOTO_PREV: {
+
+ code_editor->goto_prev_bookmark();
+ } break;
+ case BOOKMARK_REMOVE_ALL: {
+
+ code_editor->remove_all_bookmarks();
+ } break;
}
}
@@ -620,5 +638,15 @@ TextEditor::TextEditor() {
highlighter_menu->add_radio_check_item(TTR("Standard"));
highlighter_menu->connect("id_pressed", this, "_change_syntax_highlighter");
+ PopupMenu *bookmarks = memnew(PopupMenu);
+ bookmarks->set_name("bookmarks");
+ edit_menu->get_popup()->add_child(bookmarks);
+ edit_menu->get_popup()->add_submenu_item(TTR("Bookmarks"), "bookmarks");
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE);
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/remove_all_bookmarks"), BOOKMARK_REMOVE_ALL);
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_next_bookmark"), BOOKMARK_GOTO_NEXT);
+ bookmarks->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_previous_bookmark"), BOOKMARK_GOTO_PREV);
+ bookmarks->connect("id_pressed", this, "_edit_option");
+
code_editor->get_text_edit()->set_drag_forwarding(this);
}
diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h
index 767001e2f6..2da7474793 100644
--- a/editor/plugins/text_editor.h
+++ b/editor/plugins/text_editor.h
@@ -87,6 +87,10 @@ private:
SEARCH_FIND_PREV,
SEARCH_REPLACE,
SEARCH_GOTO_LINE,
+ BOOKMARK_TOGGLE,
+ BOOKMARK_GOTO_NEXT,
+ BOOKMARK_GOTO_PREV,
+ BOOKMARK_REMOVE_ALL,
};
protected: