Skip to content

Commit

Permalink
Added setting to hide the header
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasJRyan committed Sep 29, 2023
1 parent 7156767 commit 1326cb2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
26 changes: 20 additions & 6 deletions pudb/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,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
Expand Down Expand Up @@ -2419,6 +2421,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]
Expand Down Expand Up @@ -2836,11 +2839,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()
Expand Down Expand Up @@ -2953,6 +2962,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

# }}}

Expand Down
15 changes: 15 additions & 0 deletions pudb/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 1326cb2

Please sign in to comment.