Skip to content

Commit 58fce00

Browse files
committed
Fix sidebar resizing for new Urwid API
Closes gh-666
1 parent 0b9b626 commit 58fce00

File tree

1 file changed

+12
-28
lines changed

1 file changed

+12
-28
lines changed

pudb/debugger.py

+12-28
Original file line numberDiff line numberDiff line change
@@ -2029,53 +2029,37 @@ def cmdline_results_scroll(w, size, key):
20292029

20302030
# {{{ sidebar sizing
20312031

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

2035-
weight = 5
20362035
CONFIG["sidebar_width"] = weight
20372036
save_config(CONFIG)
20382037

20392038
self.columns.contents[1] = (
20402039
self.columns.contents[1][0],
2041-
(urwid.WEIGHT, weight))
2042-
self.columns._invalidate()
2043-
2044-
def min_sidebar(w, size, key):
2045-
from pudb.settings import save_config
2040+
self.columns.options("weight", weight))
20462041

2047-
weight = 1/5
2048-
CONFIG["sidebar_width"] = weight
2049-
save_config(CONFIG)
2042+
def max_sidebar(w, size, key):
2043+
_set_sidebar_weight(5)
20502044

2051-
self.columns.contents[1] = (
2052-
self.columns.contents[1][0],
2053-
(urwid.WEIGHT, weight))
2054-
self.columns._invalidate()
2045+
def min_sidebar(w, size, key):
2046+
_set_sidebar_weight(1/5)
20552047

20562048
def grow_sidebar(w, size, key):
2057-
from pudb.settings import save_config
2058-
2059-
weight = self.columns.column_types[1][1]
2049+
_widget, (_weight_literal, weight, _flag) = self.columns.contents[1]
2050+
assert weight is not None
20602051

20612052
if weight < 5:
20622053
weight *= 1.25
2063-
CONFIG["sidebar_width"] = weight
2064-
save_config(CONFIG)
2065-
self.columns.column_types[1] = urwid.WEIGHT, weight
2066-
self.columns._invalidate()
2054+
_set_sidebar_weight(weight)
20672055

20682056
def shrink_sidebar(w, size, key):
2069-
from pudb.settings import save_config
2070-
2071-
weight = self.columns.column_types[1][1]
2057+
_widget, (_weight_literal, weight, _flag) = self.columns.contents[1]
2058+
assert weight is not None
20722059

20732060
if weight > 1/5:
20742061
weight /= 1.25
2075-
CONFIG["sidebar_width"] = weight
2076-
save_config(CONFIG)
2077-
self.columns.column_types[1] = urwid.WEIGHT, weight
2078-
self.columns._invalidate()
2062+
_set_sidebar_weight(weight)
20792063

20802064
self.rhs_col_sigwrap.listen("=", max_sidebar)
20812065
self.rhs_col_sigwrap.listen("+", grow_sidebar)

0 commit comments

Comments
 (0)