Fix dashboard window sizing to avoid curses error
This commit is contained in:
@@ -224,17 +224,19 @@ class ReactorDashboard:
|
||||
def _draw(self, stdscr: "curses._CursesWindow", state: PlantState) -> None:
|
||||
stdscr.erase()
|
||||
height, width = stdscr.getmaxyx()
|
||||
if height < 20 or width < 70:
|
||||
min_status = 4
|
||||
if height < min_status + 12 or width < 70:
|
||||
stdscr.addstr(
|
||||
0,
|
||||
0,
|
||||
"Terminal too small; try >=70x20 or reduce font size.".ljust(width),
|
||||
"Terminal too small; try >=70x16 or reduce font size.".ljust(width),
|
||||
curses.color_pair(4),
|
||||
)
|
||||
stdscr.refresh()
|
||||
return
|
||||
|
||||
data_height = height - 5
|
||||
status_height = min_status
|
||||
data_height = height - status_height
|
||||
right_width = max(28, width // 3)
|
||||
left_width = width - right_width
|
||||
if left_width < 50:
|
||||
@@ -243,7 +245,7 @@ class ReactorDashboard:
|
||||
|
||||
data_win = stdscr.derwin(data_height, left_width, 0, 0)
|
||||
help_win = stdscr.derwin(data_height, right_width, 0, left_width)
|
||||
status_win = stdscr.derwin(6, width, data_height, 0)
|
||||
status_win = stdscr.derwin(status_height, width, data_height, 0)
|
||||
|
||||
self._draw_data_panel(data_win, state)
|
||||
self._draw_help_panel(help_win)
|
||||
|
||||
Reference in New Issue
Block a user