From 1fc0c75448cc29b7737635f491782c238771ca85 Mon Sep 17 00:00:00 2001 From: Sergiy Redko Date: Mon, 13 Nov 2023 08:42:05 +1100 Subject: [PATCH 1/4] Add restart hotkey --- pudb/__init__.py | 4 ++++ pudb/debugger.py | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pudb/__init__.py b/pudb/__init__.py index 71988391..27801e51 100644 --- a/pudb/__init__.py +++ b/pudb/__init__.py @@ -172,6 +172,10 @@ def runscript(mainpyfile, args=None, pre_run="", steal_output=False, import urwid pre_run_edit = urwid.Edit("", pre_run) + if dbg.restart_requested(): + dbg.clear_restart() + break + if not load_config()["prompt_on_quit"]: return diff --git a/pudb/debugger.py b/pudb/debugger.py index 5614f02b..b477bd65 100644 --- a/pudb/debugger.py +++ b/pudb/debugger.py @@ -196,6 +196,7 @@ def __init__(self, stdin=None, stdout=None, term_size=None, steal_output=False, self.ui = DebuggerUI(self, stdin=stdin, stdout=stdout, term_size=term_size) self.steal_output = steal_output self._continue_at_start__setting = _continue_at_start + self.__restart = False self.setup_state() @@ -297,6 +298,15 @@ def set_trace(self, frame=None, as_breakpoint=None, paused=True): else: return + def clear_restart(self): + self.__restart = False + + def request_restart(self): + self.__restart = True + + def restart_requested(self): + return self.__restart + def save_breakpoints(self): from pudb.settings import save_breakpoints save_breakpoints([ @@ -1740,7 +1750,6 @@ def helpmain(w, size, key): self.source_sigwrap.listen("n", next_line) self.source_sigwrap.listen("s", step) self.source_sigwrap.listen("f", finish) - self.source_sigwrap.listen("r", finish) self.source_sigwrap.listen("c", cont) self.source_sigwrap.listen("t", run_to_cursor) self.source_sigwrap.listen("J", jump_to_cursor) @@ -2214,6 +2223,11 @@ def edit_current_frame(w, size, key): "(perhaps this is generated code)") open_file_editor(source_identifier, pos+1) + def restart(w, size, key): + self.debugger.set_quit() + self.debugger.request_restart() + end() + self.top.listen("o", show_output) self.top.listen("ctrl r", lambda w, size, key: reload_breakpoints_and_redisplay()) @@ -2226,6 +2240,7 @@ def edit_current_frame(w, size, key): self.top.listen(CONFIG["hotkeys_breakpoints"], RHColumnFocuser(2)) self.top.listen("q", quit) + self.top.listen("r", restart) self.top.listen("ctrl p", do_edit_config) self.top.listen("ctrl l", redraw_screen) From f5706ea6d04dec03914d59a1ccc02cf95a36f16d Mon Sep 17 00:00:00 2001 From: Sergiy Redko Date: Wed, 27 Mar 2024 08:17:37 +1100 Subject: [PATCH 2/4] revert global restart hotkey --- pudb/__init__.py | 4 ---- pudb/debugger.py | 17 +---------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/pudb/__init__.py b/pudb/__init__.py index 27801e51..71988391 100644 --- a/pudb/__init__.py +++ b/pudb/__init__.py @@ -172,10 +172,6 @@ def runscript(mainpyfile, args=None, pre_run="", steal_output=False, import urwid pre_run_edit = urwid.Edit("", pre_run) - if dbg.restart_requested(): - dbg.clear_restart() - break - if not load_config()["prompt_on_quit"]: return diff --git a/pudb/debugger.py b/pudb/debugger.py index b477bd65..5614f02b 100644 --- a/pudb/debugger.py +++ b/pudb/debugger.py @@ -196,7 +196,6 @@ def __init__(self, stdin=None, stdout=None, term_size=None, steal_output=False, self.ui = DebuggerUI(self, stdin=stdin, stdout=stdout, term_size=term_size) self.steal_output = steal_output self._continue_at_start__setting = _continue_at_start - self.__restart = False self.setup_state() @@ -298,15 +297,6 @@ def set_trace(self, frame=None, as_breakpoint=None, paused=True): else: return - def clear_restart(self): - self.__restart = False - - def request_restart(self): - self.__restart = True - - def restart_requested(self): - return self.__restart - def save_breakpoints(self): from pudb.settings import save_breakpoints save_breakpoints([ @@ -1750,6 +1740,7 @@ def helpmain(w, size, key): self.source_sigwrap.listen("n", next_line) self.source_sigwrap.listen("s", step) self.source_sigwrap.listen("f", finish) + self.source_sigwrap.listen("r", finish) self.source_sigwrap.listen("c", cont) self.source_sigwrap.listen("t", run_to_cursor) self.source_sigwrap.listen("J", jump_to_cursor) @@ -2223,11 +2214,6 @@ def edit_current_frame(w, size, key): "(perhaps this is generated code)") open_file_editor(source_identifier, pos+1) - def restart(w, size, key): - self.debugger.set_quit() - self.debugger.request_restart() - end() - self.top.listen("o", show_output) self.top.listen("ctrl r", lambda w, size, key: reload_breakpoints_and_redisplay()) @@ -2240,7 +2226,6 @@ def restart(w, size, key): self.top.listen(CONFIG["hotkeys_breakpoints"], RHColumnFocuser(2)) self.top.listen("q", quit) - self.top.listen("r", restart) self.top.listen("ctrl p", do_edit_config) self.top.listen("ctrl l", redraw_screen) From c1d0f69c672416edb5196a372daf241cc3c23475 Mon Sep 17 00:00:00 2001 From: Sergiy Redko Date: Wed, 27 Mar 2024 08:21:49 +1100 Subject: [PATCH 3/4] Add restart hotkey to quit prompt --- pudb/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pudb/__init__.py b/pudb/__init__.py index 71988391..caa5796b 100644 --- a/pudb/__init__.py +++ b/pudb/__init__.py @@ -196,6 +196,7 @@ def runscript(mainpyfile, args=None, pre_run="", steal_output=False, extra_bindings=[ ("q", "quit"), ("esc", "examine"), + ("r", "restart"), ]) if result == "quit": From 477dd88f026cdcfcdb07cf147bfd25b733ea1022 Mon Sep 17 00:00:00 2001 From: Sergiy Redko Date: Thu, 12 Sep 2024 09:15:59 +1000 Subject: [PATCH 4/4] Add mention of r hotkey to the text box --- pudb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pudb/__init__.py b/pudb/__init__.py index caa5796b..4eadcdc3 100644 --- a/pudb/__init__.py +++ b/pudb/__init__.py @@ -179,7 +179,7 @@ def runscript(mainpyfile, args=None, pre_run="", steal_output=False, urwid.ListBox(urwid.SimpleListWalker([urwid.Text( "Your PuDB session has ended.\n\n%s" "Would you like to quit PuDB or restart your program?\n" - "You may hit 'q' to quit." + "You may hit 'q' to quit or 'r' to restart." % status_msg), urwid.Text("\n\nIf you decide to restart, this command " "will be run prior to actually restarting:"),