Update TUI layout handling

The right column is now created first so the title, info,
current, and worker panes are all in the same "container"
This commit is contained in:
2Shirt 2023-07-05 15:46:27 -07:00
parent ebd1bbda18
commit 408a0c6114
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 27 additions and 23 deletions

View file

@ -73,7 +73,7 @@ def fix_layout(
avail_vertical -= layout[group].get('height', 0) + 1
num_workers = len(layout['Workers']['Panes'])
avail_vertical -= num_workers * (layout['Workers'].get('height', 0) + 1)
avail_horizontal -= layout['Started']['width'] + 1
avail_horizontal -= layout['Progress']['width'] + 1
# Fix heights
for group, data in layout.items():
@ -89,10 +89,12 @@ def fix_layout(
)
# Fix widths
for group in ('Started', 'Progress'):
resize_kwargs.append(
{'pane_id': layout[group]['Panes'][0], 'width': layout[group]['width']}
)
resize_kwargs.append(
{'pane_id': layout['Progress']['Panes'][0], 'width': layout['Progress']['width']}
)
resize_kwargs.append(
{'pane_id': layout['Started']['Panes'][0], 'height': layout['Started']['height']}
)
for group, data in layout.items():
num_panes = len(data['Panes'])
if num_panes < 2 or group not in ('Title', 'Info'):

View file

@ -22,7 +22,7 @@ TMUX_LAYOUT = { # NOTE: This needs to be in order from top to bottom
'Info': {'Panes': []},
'Current': {'Panes': [environ.get('TMUX_PANE', None)]},
'Workers': {'Panes': []},
'Started': {'Panes': [], 'width': TMUX_SIDE_WIDTH},
'Started': {'Panes': [], 'height': TMUX_TITLE_HEIGHT},
'Progress': {'Panes': [], 'width': TMUX_SIDE_WIDTH},
}
@ -180,6 +180,25 @@ class TUI():
self.layout.clear()
self.layout.update(deepcopy(TMUX_LAYOUT))
# Progress
self.layout['Progress']['Panes'].append(tmux.split_window(
lines=TMUX_SIDE_WIDTH,
text=' ',
))
# Started
self.layout['Started']['Panes'].append(tmux.split_window(
behind=True,
lines=2,
target_id=self.layout['Progress']['Panes'][0],
text=ansi.color_string(
['Started', time.strftime("%Y-%m-%d %H:%M %Z")],
['BLUE', None],
sep='\n',
),
vertical=True,
))
# Title
self.layout['Title']['Panes'].append(tmux.split_window(
behind=True,
@ -192,23 +211,6 @@ class TUI():
),
))
# Started
self.layout['Started']['Panes'].append(tmux.split_window(
lines=TMUX_SIDE_WIDTH,
target_id=self.layout['Title']['Panes'][0],
text=ansi.color_string(
['Started', time.strftime("%Y-%m-%d %H:%M %Z")],
['BLUE', None],
sep='\n',
),
))
# Progress
self.layout['Progress']['Panes'].append(tmux.split_window(
lines=TMUX_SIDE_WIDTH,
text=' ',
))
def remove_all_info_panes(self) -> None:
"""Remove all info panes and update layout."""
self.layout['Info'].pop('height', None)