mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-05 20:40:09 -08:00
Merge pull request #109 from iMithrellas/preview-scaling
Add optional --scale-up flag for icat image previews
This commit is contained in:
@@ -44,18 +44,19 @@ fzf_preview() {
|
||||
|
||||
if [ "$IMAGE_RENDERER" = "icat" ] && [ -z "$GHOSTTY_BIN_DIR" ]; then
|
||||
if command -v kitten >/dev/null 2>&1; then
|
||||
kitten icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
kitten icat --clear --transfer-mode=memory --unicode-placeholder{SCALE_UP} --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
elif command -v icat >/dev/null 2>&1; then
|
||||
icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
icat --clear --transfer-mode=memory --unicode-placeholder{SCALE_UP} --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
else
|
||||
kitty icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
kitty icat --clear --transfer-mode=memory --unicode-placeholder{SCALE_UP} --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
fi
|
||||
|
||||
elif [ -n "$GHOSTTY_BIN_DIR" ]; then
|
||||
dim=$((FZF_PREVIEW_COLUMNS - 1))x${FZF_PREVIEW_LINES}
|
||||
if command -v kitten >/dev/null 2>&1; then
|
||||
kitten icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
kitten icat --clear --transfer-mode=memory --unicode-placeholder{SCALE_UP} --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
elif command -v icat >/dev/null 2>&1; then
|
||||
icat --clear --transfer-mode=memory --unicode-placeholder --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
icat --clear --transfer-mode=memory --unicode-placeholder{SCALE_UP} --stdin=no --place="$dim@0x0" "$file" | sed "\$d" | sed "$(printf "\$s/\$/\033[m/")"
|
||||
else
|
||||
chafa -s "$dim" "$file"
|
||||
fi
|
||||
|
||||
@@ -213,6 +213,7 @@ def get_anime_preview(
|
||||
"C_RULE": ansi.get_true_fg(SEPARATOR_COLOR, bold=True),
|
||||
"RESET": ansi.RESET,
|
||||
"PREFIX": "",
|
||||
"SCALE_UP": " --scale-up" if config.general.preview_scale_up else "",
|
||||
}
|
||||
|
||||
for key, value in replacements.items():
|
||||
@@ -270,6 +271,7 @@ def get_episode_preview(
|
||||
"C_RULE": ansi.get_true_fg(SEPARATOR_COLOR, bold=True),
|
||||
"RESET": ansi.RESET,
|
||||
"PREFIX": f"{media_item.title.english}_Episode_",
|
||||
"SCALE_UP": " --scale-up" if config.general.preview_scale_up else "",
|
||||
}
|
||||
|
||||
for key, value in replacements.items():
|
||||
@@ -323,6 +325,7 @@ def get_dynamic_anime_preview(config: AppConfig) -> str:
|
||||
"C_VALUE": ansi.get_true_fg(HEADER_COLOR, bold=True),
|
||||
"C_RULE": ansi.get_true_fg(SEPARATOR_COLOR, bold=True),
|
||||
"RESET": ansi.RESET,
|
||||
"SCALE_UP": " --scale-up" if config.general.preview_scale_up else "",
|
||||
}
|
||||
|
||||
for key, value in replacements.items():
|
||||
|
||||
@@ -11,6 +11,8 @@ GENERAL_SELECTOR = lambda: "fzf" if detect.has_fzf() else "default"
|
||||
GENERAL_AUTO_SELECT_ANIME_RESULT = True
|
||||
GENERAL_ICONS = True
|
||||
GENERAL_PREVIEW = lambda: "full" if detect.is_running_kitty_terminal() else "none"
|
||||
GENERAL_SCALE_PREVIEW = True
|
||||
GENERAL_SCALE_PREVIEW = False
|
||||
GENERAL_IMAGE_RENDERER = (
|
||||
lambda: "icat" if detect.is_running_kitty_terminal() else "chafa"
|
||||
)
|
||||
|
||||
@@ -14,6 +14,11 @@ GENERAL_AUTO_SELECT_ANIME_RESULT = (
|
||||
)
|
||||
GENERAL_ICONS = "Display emoji icons in the user interface."
|
||||
GENERAL_PREVIEW = "Type of preview to display in selectors."
|
||||
GENERAL_SCALE_PREVIEW = (
|
||||
"Whether to scale up images rendered with icat to fill the preview area. "
|
||||
"When using the 'full' preview type in a landscape window, enabling this may reduce "
|
||||
"the amount of text information displayed."
|
||||
)
|
||||
GENERAL_IMAGE_RENDERER = (
|
||||
"The command-line tool to use for rendering images in the terminal."
|
||||
)
|
||||
|
||||
@@ -119,6 +119,11 @@ class GeneralConfig(BaseModel):
|
||||
default_factory=defaults.GENERAL_PREVIEW,
|
||||
description=desc.GENERAL_PREVIEW,
|
||||
)
|
||||
preview_scale_up: bool = Field(
|
||||
default=defaults.GENERAL_SCALE_PREVIEW,
|
||||
description=desc.GENERAL_SCALE_PREVIEW,
|
||||
)
|
||||
|
||||
image_renderer: Literal["icat", "chafa", "imgcat"] = Field(
|
||||
default_factory=defaults.GENERAL_IMAGE_RENDERER,
|
||||
description=desc.GENERAL_IMAGE_RENDERER,
|
||||
|
||||
Reference in New Issue
Block a user