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