Skip to content

Commit

Permalink
Fix sidebar resizing for new Urwid API
Browse files Browse the repository at this point in the history
Closes gh-666
  • Loading branch information
inducer committed Feb 5, 2025
1 parent 0b9b626 commit 58fce00
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions pudb/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2029,53 +2029,37 @@ def cmdline_results_scroll(w, size, key):

# {{{ sidebar sizing

def max_sidebar(w, size, key):
def _set_sidebar_weight(weight: float) -> None:
from pudb.settings import save_config

weight = 5
CONFIG["sidebar_width"] = weight
save_config(CONFIG)

self.columns.contents[1] = (
self.columns.contents[1][0],
(urwid.WEIGHT, weight))
self.columns._invalidate()

def min_sidebar(w, size, key):
from pudb.settings import save_config
self.columns.options("weight", weight))

weight = 1/5
CONFIG["sidebar_width"] = weight
save_config(CONFIG)
def max_sidebar(w, size, key):
_set_sidebar_weight(5)

self.columns.contents[1] = (
self.columns.contents[1][0],
(urwid.WEIGHT, weight))
self.columns._invalidate()
def min_sidebar(w, size, key):
_set_sidebar_weight(1/5)

def grow_sidebar(w, size, key):
from pudb.settings import save_config

weight = self.columns.column_types[1][1]
_widget, (_weight_literal, weight, _flag) = self.columns.contents[1]
assert weight is not None

if weight < 5:
weight *= 1.25
CONFIG["sidebar_width"] = weight
save_config(CONFIG)
self.columns.column_types[1] = urwid.WEIGHT, weight
self.columns._invalidate()
_set_sidebar_weight(weight)

def shrink_sidebar(w, size, key):
from pudb.settings import save_config

weight = self.columns.column_types[1][1]
_widget, (_weight_literal, weight, _flag) = self.columns.contents[1]
assert weight is not None

if weight > 1/5:
weight /= 1.25
CONFIG["sidebar_width"] = weight
save_config(CONFIG)
self.columns.column_types[1] = urwid.WEIGHT, weight
self.columns._invalidate()
_set_sidebar_weight(weight)

self.rhs_col_sigwrap.listen("=", max_sidebar)
self.rhs_col_sigwrap.listen("+", grow_sidebar)
Expand Down

0 comments on commit 58fce00

Please sign in to comment.