diff --git a/pudb/debugger.py b/pudb/debugger.py index a221a2a1..9165de5d 100644 --- a/pudb/debugger.py +++ b/pudb/debugger.py @@ -90,6 +90,7 @@ def newfunc(*fargs, **fkeywords): +/- - grow/shrink sidebar _/= - minimize/maximize sidebar [/] - grow/shrink relative size of active sidebar box + Ctrl-^ - toggle sidebar display Keys in variables list: \ - expand/collapse @@ -673,6 +674,8 @@ def clear_cmdline_history(btn): urwid.AttrMap(self.columns, "background"), header)) + self._toggle_sidebar(CONFIG["sidebar_visible"]) + # }}} def change_rhs_box(name, index, direction, w, size, key): @@ -1614,6 +1617,17 @@ def shrink_sidebar(w, size, key): self.columns.column_types[1] = "weight", weight self.columns._invalidate() + def toggle_sidebar(w, size, key): + from pudb.settings import save_config + + CONFIG["sidebar_visible"] = not CONFIG["sidebar_visible"] + save_config(CONFIG) + + if not CONFIG["sidebar_visible"]: + self.columns.set_focus(self.lhs_col) + + self._toggle_sidebar(CONFIG["sidebar_visible"]) + self.rhs_col_sigwrap.listen("=", max_sidebar) self.rhs_col_sigwrap.listen("+", grow_sidebar) self.rhs_col_sigwrap.listen("_", min_sidebar) @@ -1697,6 +1711,14 @@ def __init__(self, idx): self.idx = idx def __call__(subself, w, size, key): + from pudb.settings import save_config + + # ensure sidebar is visible when focussing rh columns + if not CONFIG["sidebar_visible"]: + CONFIG["sidebar_visible"] = True + save_config(CONFIG) + self._toggle_sidebar(CONFIG["sidebar_visible"]) + self.columns.set_focus(self.rhs_col_sigwrap) self.rhs_col.set_focus(self.rhs_col.widget_list[subself.idx]) @@ -1722,6 +1744,7 @@ def help(w, size, key): self.top.listen("V", RHColumnFocuser(0)) self.top.listen("S", RHColumnFocuser(1)) self.top.listen("B", RHColumnFocuser(2)) + self.top.listen("ctrl ^", toggle_sidebar) self.top.listen("q", quit) self.top.listen("ctrl p", do_edit_config) @@ -1860,6 +1883,15 @@ def __call__(subself, w, size, key): return self.event_loop(w)[0] + def _toggle_sidebar(self, visible): + if visible: + self.columns.dividechars = 1 + self.columns.column_types[1] = "weight", float(CONFIG["sidebar_width"]) + else: + self.columns.dividechars = 0 + self.columns.column_types[1] = "given", 0 + self.columns._invalidate() + @staticmethod def setup_palette(screen): may_use_fancy_formats = not hasattr(urwid.escape, "_fg_attr_xterm") diff --git a/pudb/settings.py b/pudb/settings.py index 96b4adaf..77fa57f9 100644 --- a/pudb/settings.py +++ b/pudb/settings.py @@ -76,6 +76,7 @@ def load_config(): conf_dict.setdefault("wrap_variables", True) conf_dict.setdefault("display", "auto") + conf_dict.setdefault("sidebar_visible", True) conf_dict.setdefault("prompt_on_quit", True) @@ -91,6 +92,7 @@ def normalize_bool_inplace(name): normalize_bool_inplace("line_numbers") normalize_bool_inplace("wrap_variables") normalize_bool_inplace("prompt_on_quit") + normalize_bool_inplace("sidebar_visible") return conf_dict