Skip to content

Commit

Permalink
feat: tui: Make "max pixels" optional for the grid
Browse files Browse the repository at this point in the history
- Add: `--no-max-pixels-grid` command-line option.
_ Add: `.main.NO_MAX_PIXELS_GRID`.
- Change: Do not apply "max pixels" to grid rendering when thumbnailing
  is disabled and `--no-max-pixels-grid` is specified.
  • Loading branch information
AnonymouX47 committed Apr 27, 2024
1 parent 4b989d3 commit 70a57bc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/termvisage/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,14 @@ def strip_markup(string: str) -> str:
action="store_true",
help="Apply :option:`--max-pixels` in CLI mode",
)
perf_options.add_argument(
"--no-max-pixels-grid",
action="store_true",
help=(
"Do not apply :option:`--max-pixels` to the image grid in TUI mode when "
"thumbnailing is disabled."
),
)
perf_options.add_argument(
"--multi",
action=BooleanOptionalAction,
Expand Down
1 change: 1 addition & 0 deletions src/termvisage/tui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def init(
main.DEBUG = args.debug
main.MAX_PIXELS = args.max_pixels
main.NO_ANIMATION = args.no_anim
main.NO_MAX_PIXELS_GRID = args.no_max_pixels_grid
main.RECURSIVE = args.recursive
main.SHOW_HIDDEN = args.all
main.THUMBNAIL = args.thumbnail
Expand Down
1 change: 1 addition & 0 deletions src/termvisage/tui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ def update_screen():
DEBUG: bool
MAX_PIXELS: int
NO_ANIMATION: bool
NO_MAX_PIXELS_GRID: bool
RECURSIVE: bool
SHOW_HIDDEN: bool
THUMBNAIL: bool
Expand Down
8 changes: 6 additions & 2 deletions src/termvisage/tui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,12 @@ def render(self, size: Tuple[int, int], focus: bool = False) -> urwid.Canvas:
# is the image grid in view? (next two lines)
view.original_widget is image_grid_box
and context != "full-grid-image"
# is thumbnailing enabled?
and tui_main.THUMBNAIL
and (
# is thumbnailing enabled?
tui_main.THUMBNAIL
# does "max pixels" NOT apply to the image grid?
or tui_main.NO_MAX_PIXELS_GRID
)
)
# does the image have more pixels than `max pixels`?
and mul(*image.original_size) > tui_main.MAX_PIXELS
Expand Down

0 comments on commit 70a57bc

Please sign in to comment.