From 7029c962217b5157667000c2313c81deb5d7fe94 Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Fri, 27 May 2016 15:29:04 +0100 Subject: [PATCH] Added, goto next and previous breakpoint and remove all, issue 1690 (cherry picked from commit daf0ed646f90ed149a45838e5e6ebf9c577672f7) --- tools/editor/plugins/script_editor_plugin.cpp | 58 +++++++++++++++++++ tools/editor/plugins/script_editor_plugin.h | 3 + 2 files changed, 61 insertions(+) diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 9fa7c72cff1..4dd50c19422 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -1388,6 +1388,61 @@ void ScriptEditor::_menu_option(int p_option) { current->get_text_edit()->set_line_as_breakpoint(line,dobreak); get_debugger()->set_breakpoint(current->get_edited_script()->get_path(),line+1,dobreak); } break; + case DEBUG_REMOVE_ALL_BREAKPOINTS: { + List bpoints; + current->get_text_edit()->get_breakpoints(&bpoints); + + for(List::Element *E=bpoints.front();E;E=E->next()) { + int line = E->get(); + bool dobreak = !current->get_text_edit()->is_line_set_as_breakpoint(line); + current->get_text_edit()->set_line_as_breakpoint(line,dobreak); + get_debugger()->set_breakpoint(current->get_edited_script()->get_path(),line+1,dobreak); + } + } + case DEBUG_GOTO_NEXT_BREAKPOINT: { + List bpoints; + current->get_text_edit()->get_breakpoints(&bpoints); + if (bpoints.size() <= 0) { + return; + } + + int line=current->get_text_edit()->cursor_get_line(); + // wrap around + if (line >= bpoints[bpoints.size() - 1]) { + current->get_text_edit()->cursor_set_line(bpoints[0]); + } else { + for(List::Element *E=bpoints.front();E;E=E->next()) { + int bline = E->get(); + if (bline > line) { + current->get_text_edit()->cursor_set_line(bline); + return; + } + } + } + + } break; + case DEBUG_GOTO_PREV_BREAKPOINT: { + List bpoints; + current->get_text_edit()->get_breakpoints(&bpoints); + if (bpoints.size() <= 0) { + return; + } + + int line=current->get_text_edit()->cursor_get_line(); + // wrap around + if (line <= bpoints[0]) { + current->get_text_edit()->cursor_set_line(bpoints[bpoints.size() - 1]); + } else { + for(List::Element *E=bpoints.back();E;E=E->prev()) { + int bline = E->get(); + if (bline < line) { + current->get_text_edit()->cursor_set_line(bline); + return; + } + } + } + + } break; case DEBUG_NEXT: { if (debugger) @@ -2491,6 +2546,9 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { menu_hb->add_child(debug_menu); debug_menu->set_text("Debug"); debug_menu->get_popup()->add_item("Toggle Breakpoint",DEBUG_TOGGLE_BREAKPOINT,KEY_F9); + debug_menu->get_popup()->add_item("Remove All Breakpoints", DEBUG_REMOVE_ALL_BREAKPOINTS, KEY_MASK_CTRL|KEY_MASK_SHIFT|KEY_F9); + debug_menu->get_popup()->add_item("Goto Next Breakpoint", DEBUG_GOTO_NEXT_BREAKPOINT, KEY_MASK_CTRL|KEY_PERIOD); + debug_menu->get_popup()->add_item("Goto Previous Breakpoint", DEBUG_GOTO_PREV_BREAKPOINT, KEY_MASK_CTRL|KEY_COMMA); debug_menu->get_popup()->add_separator(); debug_menu->get_popup()->add_item("Step Over",DEBUG_NEXT,KEY_F10); debug_menu->get_popup()->add_item("Step Into",DEBUG_STEP,KEY_F11); diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index 68aef4d39c5..fd06d8d7da3 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -147,6 +147,9 @@ class ScriptEditor : public VBoxContainer { SEARCH_CLASSES, SEARCH_WEBSITE, DEBUG_TOGGLE_BREAKPOINT, + DEBUG_REMOVE_ALL_BREAKPOINTS, + DEBUG_GOTO_NEXT_BREAKPOINT, + DEBUG_GOTO_PREV_BREAKPOINT, DEBUG_NEXT, DEBUG_STEP, DEBUG_BREAK,