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:
parent
ebd1bbda18
commit
408a0c6114
2 changed files with 27 additions and 23 deletions
|
|
@ -73,7 +73,7 @@ def fix_layout(
|
||||||
avail_vertical -= layout[group].get('height', 0) + 1
|
avail_vertical -= layout[group].get('height', 0) + 1
|
||||||
num_workers = len(layout['Workers']['Panes'])
|
num_workers = len(layout['Workers']['Panes'])
|
||||||
avail_vertical -= num_workers * (layout['Workers'].get('height', 0) + 1)
|
avail_vertical -= num_workers * (layout['Workers'].get('height', 0) + 1)
|
||||||
avail_horizontal -= layout['Started']['width'] + 1
|
avail_horizontal -= layout['Progress']['width'] + 1
|
||||||
|
|
||||||
# Fix heights
|
# Fix heights
|
||||||
for group, data in layout.items():
|
for group, data in layout.items():
|
||||||
|
|
@ -89,10 +89,12 @@ def fix_layout(
|
||||||
)
|
)
|
||||||
|
|
||||||
# Fix widths
|
# Fix widths
|
||||||
for group in ('Started', 'Progress'):
|
resize_kwargs.append(
|
||||||
resize_kwargs.append(
|
{'pane_id': layout['Progress']['Panes'][0], 'width': layout['Progress']['width']}
|
||||||
{'pane_id': layout[group]['Panes'][0], 'width': layout[group]['width']}
|
)
|
||||||
)
|
resize_kwargs.append(
|
||||||
|
{'pane_id': layout['Started']['Panes'][0], 'height': layout['Started']['height']}
|
||||||
|
)
|
||||||
for group, data in layout.items():
|
for group, data in layout.items():
|
||||||
num_panes = len(data['Panes'])
|
num_panes = len(data['Panes'])
|
||||||
if num_panes < 2 or group not in ('Title', 'Info'):
|
if num_panes < 2 or group not in ('Title', 'Info'):
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ TMUX_LAYOUT = { # NOTE: This needs to be in order from top to bottom
|
||||||
'Info': {'Panes': []},
|
'Info': {'Panes': []},
|
||||||
'Current': {'Panes': [environ.get('TMUX_PANE', None)]},
|
'Current': {'Panes': [environ.get('TMUX_PANE', None)]},
|
||||||
'Workers': {'Panes': []},
|
'Workers': {'Panes': []},
|
||||||
'Started': {'Panes': [], 'width': TMUX_SIDE_WIDTH},
|
'Started': {'Panes': [], 'height': TMUX_TITLE_HEIGHT},
|
||||||
'Progress': {'Panes': [], 'width': TMUX_SIDE_WIDTH},
|
'Progress': {'Panes': [], 'width': TMUX_SIDE_WIDTH},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,6 +180,25 @@ class TUI():
|
||||||
self.layout.clear()
|
self.layout.clear()
|
||||||
self.layout.update(deepcopy(TMUX_LAYOUT))
|
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
|
# Title
|
||||||
self.layout['Title']['Panes'].append(tmux.split_window(
|
self.layout['Title']['Panes'].append(tmux.split_window(
|
||||||
behind=True,
|
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:
|
def remove_all_info_panes(self) -> None:
|
||||||
"""Remove all info panes and update layout."""
|
"""Remove all info panes and update layout."""
|
||||||
self.layout['Info'].pop('height', None)
|
self.layout['Info'].pop('height', None)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue