Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added toggle sidebar feature #134

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions pudb/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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])

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

Expand All @@ -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

Expand Down