From 294c7a6a9562bb07eea4717156c2a78b9544a6ab Mon Sep 17 00:00:00 2001 From: Thomas Ryan Date: Fri, 29 Sep 2023 05:31:07 -0400 Subject: [PATCH] Added setting to hide the header --- pudb/debugger.py | 26 ++++++++++++++++++++------ pudb/settings.py | 15 +++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/pudb/debugger.py b/pudb/debugger.py index eed2b714..ffefe6c3 100644 --- a/pudb/debugger.py +++ b/pudb/debugger.py @@ -947,14 +947,16 @@ def helpside(w, size, key): self.rhs_col_sigwrap), ], dividechars=1) + + background = urwid.AttrMap(self.columns, "background") self.caption = urwid.Text("") - header = urwid.AttrMap(self.caption, "header") - self.top = SignalWrap(urwid.Frame( - urwid.AttrMap(self.columns, "background"), - header)) - - # }}} + self.header = urwid.AttrMap(self.caption, "header") + + self.top = SignalWrap(urwid.Frame(background, self.header)) + + if CONFIG["hide_header"]: + self.top._w.header = None def change_rhs_box(name, index, direction, w, size, key): from pudb.settings import save_config @@ -2421,6 +2423,7 @@ def __call__(subself, w, size, key): # noqa: N805, E501 # pylint: disable=no-se width=("relative", 75), height=("relative", 75), ) + w = Attr(w, "background") return self.event_loop(w)[0] @@ -2838,11 +2841,17 @@ def interaction(self, exc_tuple, show_exc_dialog=True): (None, " "), ("header warning", "[POST-MORTEM MODE]") ]) + self.update_header(override=True) + CONFIG["hide_header"] = False + elif exc_tuple is not None: caption.extend([ (None, " "), ("header warning", "[PROCESSING EXCEPTION - hit 'e' to examine]") ]) + self.update_header(override=True) + CONFIG["hide_header"] = False + self.caption.set_text(caption) self.event_loop() @@ -2955,6 +2964,11 @@ def make_frame_ui(i, frame_lineno): def update_cmdline_win(self): self.set_cmdline_state(not CONFIG["hide_cmdline_win"]) + + def update_header(self, override=None): + if override is not None: + self.top._w.header = self.header if override else None + self.top._w.header = self.header if not CONFIG["hide_header"] else None # }}} diff --git a/pudb/settings.py b/pudb/settings.py index d4ab9923..c43950ca 100644 --- a/pudb/settings.py +++ b/pudb/settings.py @@ -112,6 +112,7 @@ def load_config(): conf_dict.setdefault("prompt_on_quit", "True") conf_dict.setdefault("hide_cmdline_win", "False") + conf_dict.setdefault("hide_header", "False") # hotkeys conf_dict.setdefault("hotkeys_code", "C") @@ -133,6 +134,7 @@ def normalize_bool_inplace(name): normalize_bool_inplace("wrap_variables") normalize_bool_inplace("prompt_on_quit") normalize_bool_inplace("hide_cmdline_win") + normalize_bool_inplace("hide_header") _config_[0] = conf_dict return conf_dict @@ -178,6 +180,9 @@ def _update_prompt_on_quit(): def _update_hide_cmdline_win(): ui.update_cmdline_win() + + def _update_hide_header(): + ui.update_header() def _update_current_stack_frame(): ui.update_stack() @@ -221,6 +226,11 @@ def _update_config(check_box, new_state, option_newvalue): new_conf_dict["hide_cmdline_win"] = not check_box.get_state() conf_dict.update(new_conf_dict) _update_hide_cmdline_win() + + elif option == "hide_header": + new_conf_dict["hide_header"] = not check_box.get_state() + conf_dict.update(new_conf_dict) + _update_hide_header() elif option == "current_stack_frame": # only activate if the new state of the radio button is 'on' @@ -269,6 +279,10 @@ def _update_config(check_box, new_state, option_newvalue): "when not in use", bool(conf_dict["hide_cmdline_win"]), on_state_change=_update_config, user_data=("hide_cmdline_win", None)) + + hide_header = urwid.CheckBox("Hide header from top of window", + bool(conf_dict["hide_header"]), on_state_change=_update_config, + user_data=("hide_header", None)) # {{{ shells @@ -441,6 +455,7 @@ def _update_config(check_box, new_state, option_newvalue): + [cb_line_numbers] + [cb_prompt_on_quit] + [hide_cmdline_win] + + [hide_header] + [urwid.AttrMap(urwid.Text("\nShell:\n"), "group head")] + [shell_info]