@@ -28,6 +28,7 @@ class View(urwid.WidgetWrap):
28
28
29
29
LEFT_WIDTH = 27
30
30
RIGHT_WIDTH = 23
31
+ MAX_TOTAL_WIDTH = 200
31
32
32
33
def __init__ (self , controller : Any ) -> None :
33
34
self .controller = controller
@@ -138,17 +139,20 @@ def main_window(self) -> Any:
138
139
if self .controller .autohide :
139
140
body = [
140
141
(self .LEFT_WIDTH , self .left_panel ),
141
- ("weight" , 10 , self .center_panel ),
142
+ ("weight" , 80 , self .center_panel ),
142
143
(0 , self .right_panel ),
143
144
]
144
145
else :
145
146
body = [
146
147
(self .LEFT_WIDTH , self .left_panel ),
147
- ("weight" , 10 , self .center_panel ),
148
+ ("weight" , 60 , self .center_panel ),
148
149
(self .RIGHT_WIDTH , self .right_panel ),
149
150
]
150
151
self .body = urwid .Columns (body , focus_column = 0 )
151
152
self .focus_col = self .body .focus_position
153
+ padded_body = urwid .Padding (
154
+ self .body , align = "center" , width = self .MAX_TOTAL_WIDTH
155
+ )
152
156
153
157
# NOTE: message_view is None, but middle_column_view is called above
154
158
# and sets it.
@@ -174,22 +178,36 @@ def main_window(self) -> Any:
174
178
)
175
179
176
180
w = urwid .Frame (
177
- self . body , title_bar , focus_part = "body" , footer = self .footer_view ()
181
+ padded_body , title_bar , focus_part = "body" , footer = self .footer_view ()
178
182
)
179
183
return w
180
184
181
- def show_left_panel (self , * , visible : bool ) -> None :
182
- if not (self .controller . autohide or self .mode == "small" ):
185
+ def show_left_panel (self , * , visible : bool , ignore_check : bool = False ) -> None :
186
+ if not (self .autohide or self .mode == "small" or ignore_check ):
183
187
return
184
- option = ("given" , self .LEFT_WIDTH ) if visible else ("given" , 0 )
188
+
189
+ if visible and self .mode != "wide" :
190
+ option = ("given" , self .LEFT_WIDTH )
191
+ elif visible and self .mode == "wide" :
192
+ option = ("weight" , 20 )
193
+ else :
194
+ option = ("given" , 0 )
195
+
185
196
self .body .contents [0 ] = (self .left_panel , self .body .options (* option ))
186
197
if visible :
187
198
self .focus_col = 0
188
199
189
- def show_right_panel (self , * , visible : bool ) -> None :
190
- if not (self .controller . autohide or self .mode == "small" ):
200
+ def show_right_panel (self , * , visible : bool , ignore_check : bool = False ) -> None :
201
+ if not (self .autohide or self .mode == "small" or ignore_check ):
191
202
return
192
- option = ("given" , self .RIGHT_WIDTH ) if visible else ("given" , 0 )
203
+
204
+ if visible and self .mode != "wide" :
205
+ option = ("given" , self .RIGHT_WIDTH )
206
+ elif visible and self .mode == "wide" :
207
+ option = ("weight" , 20 )
208
+ else :
209
+ option = ("given" , 0 )
210
+
193
211
self .body .contents [2 ] = (self .right_panel , self .body .options (* option ))
194
212
if visible :
195
213
self .focus_col = 2
@@ -333,6 +351,23 @@ def render(self, size: urwid_Box, focus: bool) -> Any:
333
351
self .focus_col = prev_focus
334
352
self .mode = "normal"
335
353
354
+ def update_column_options () -> None :
355
+ if not self .autohide :
356
+ self .show_left_panel (visible = True , ignore_check = True )
357
+ self .show_right_panel (visible = True , ignore_check = True )
358
+ if self .autohide :
359
+ if self .focus_col == 0 :
360
+ self .show_left_panel (visible = True )
361
+ elif self .focus_col == 2 :
362
+ self .show_right_panel (visible = True )
363
+
364
+ if maxcols > 160 and not self .mode == "wide" :
365
+ self .mode = "wide"
366
+ update_column_options ()
367
+ elif maxcols < 160 and self .mode == "wide" :
368
+ self .mode = "normal"
369
+ update_column_options ()
370
+
336
371
return super ().render (size , focus )
337
372
338
373
0 commit comments