Skip to content

Commit

Permalink
refac: tui: Improve grid render refresh on resize
Browse files Browse the repository at this point in the history
- Change: Refresh grid rendering regardless of whether the grid is
  active or not.
- Change: For graphics-based styles, refresh grid rendering based on
  change in terminal cell size.

  Cell ratio is now only for text-based styles.
  • Loading branch information
AnonymouX47 committed Apr 26, 2024
1 parent 736e4eb commit 6ef2a51
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/termvisage/tui/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ def resize():
# implement the `TIOCSWINSZ` ioctl command. Hence, the `cell_size and`.
if cell_size and cell_size != _prev_cell_size:
_prev_cell_size = cell_size
refresh_grid_rendering()
Image._ti_update_grid_thumbnailing_threshold(cell_size)

if main.grid_active.is_set():
else:
cell_ratio = get_cell_ratio()
if cell_ratio != _prev_cell_ratio:
_prev_cell_ratio = cell_ratio
Expand Down Expand Up @@ -737,6 +737,7 @@ def close():
_prev_view_widget: urwid.Widget | None = None

# Used to guard clearing of grid render cache
# Updated from `resize()`, for text-based styles.
_prev_cell_ratio: float = 0.0

# Used to [re]compute the thumbnailing threshold.
Expand Down

0 comments on commit 6ef2a51

Please sign in to comment.