Clear ddrescue pane when resizing
This replaces the clear every 30s/60s/etc. It's only enabled while ddrescue is running to prevent clearing warning messages if printed.
This commit is contained in:
parent
becc564269
commit
86f748c599
3 changed files with 13 additions and 5 deletions
|
|
@ -1953,6 +1953,7 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True) -> None:
|
|||
poweroff_source_after_idle = True
|
||||
state.update_progress_pane('Active')
|
||||
state.ui.clear_current_pane()
|
||||
state.ui.clear_on_resize = True
|
||||
warning_message = ''
|
||||
|
||||
def _poweroff_source_drive(idle_minutes) -> None:
|
||||
|
|
@ -2030,9 +2031,6 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True) -> None:
|
|||
exe.stop_process(proc)
|
||||
cli.print_error(warning_message)
|
||||
break
|
||||
|
||||
# Clear ddrescue pane
|
||||
state.ui.clear_current_pane()
|
||||
_i += 1
|
||||
|
||||
# Update progress
|
||||
|
|
@ -2062,6 +2060,7 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True) -> None:
|
|||
# NOTE: Using 'Active' here to avoid flickering between block pairs
|
||||
block_pair.update_progress(pass_name)
|
||||
state.update_progress_pane('Active')
|
||||
state.ui.clear_on_resize = False
|
||||
|
||||
# Check result
|
||||
if proc.poll():
|
||||
|
|
|
|||
|
|
@ -40,7 +40,11 @@ def clear_pane(pane_id: str | None = None) -> None:
|
|||
run_program(cmd, check=False)
|
||||
|
||||
|
||||
def fix_layout(layout: dict[str, dict[str, Any]], forced: bool = False) -> None:
|
||||
def fix_layout(
|
||||
layout: dict[str, dict[str, Any]],
|
||||
clear_on_resize: bool = False,
|
||||
forced: bool = False,
|
||||
) -> None:
|
||||
"""Fix pane sizes based on layout."""
|
||||
resize_kwargs = []
|
||||
|
||||
|
|
@ -49,6 +53,10 @@ def fix_layout(layout: dict[str, dict[str, Any]], forced: bool = False) -> None:
|
|||
# Layout should be fine
|
||||
return
|
||||
|
||||
# Clear current pane if needed
|
||||
if clear_on_resize:
|
||||
clear_pane()
|
||||
|
||||
# Remove closed panes
|
||||
for data in layout.values():
|
||||
data['Panes'] = [pane for pane in data['Panes'] if poll_pane(pane)]
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ TMUX_LAYOUT = { # NOTE: This needs to be in order from top to bottom
|
|||
class TUI():
|
||||
"""Object for tracking TUI elements."""
|
||||
def __init__(self, title_text: str | None = None):
|
||||
self.clear_on_resize = False
|
||||
self.layout: dict[str, dict[str, Any]] = deepcopy(TMUX_LAYOUT)
|
||||
self.side_width: int = TMUX_SIDE_WIDTH
|
||||
self.title_text: str = title_text if title_text else 'Title Text'
|
||||
|
|
@ -159,7 +160,7 @@ class TUI():
|
|||
def fix_layout(self, forced: bool = True) -> None:
|
||||
"""Fix tmux layout based on self.layout."""
|
||||
try:
|
||||
tmux.fix_layout(self.layout, forced=forced)
|
||||
tmux.fix_layout(self.layout, clear_on_resize=self.clear_on_resize, forced=forced)
|
||||
except RuntimeError:
|
||||
# Assuming self.panes changed while running
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in a new issue