feat(backend): add viu image backend (#1592)

* feat(backend): add viu image backend

* fix: double quote typo on viu command
This commit is contained in:
Paul Delafosse 2020-11-03 12:11:00 +01:00 committed by GitHub
parent 9818199c73
commit dbe781043b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -749,7 +749,8 @@ disk_display="off"
# #
# Default: 'ascii' # Default: 'ascii'
# Values: 'ascii', 'caca', 'catimg', 'chafa', 'jp2a', 'iterm2', 'off', # Values: 'ascii', 'caca', 'catimg', 'chafa', 'jp2a', 'iterm2', 'off',
# 'pot', 'termpix', 'pixterm', 'tycat', 'w3m', 'kitty', 'ueberzug' # 'pot', 'termpix', 'pixterm', 'tycat', 'w3m', 'kitty', 'ueberzug',
# 'viu'
# Flag: --backend # Flag: --backend
image_backend="ascii" image_backend="ascii"
@ -3892,7 +3893,8 @@ image_backend() {
"off") image_backend="off" ;; "off") image_backend="off" ;;
"caca" | "catimg" | "chafa" | "jp2a" | "iterm2" | "termpix" |\ "caca" | "catimg" | "chafa" | "jp2a" | "iterm2" | "termpix" |\
"tycat" | "w3m" | "sixel" | "pixterm" | "kitty" | "pot", | "ueberzug") "tycat" | "w3m" | "sixel" | "pixterm" | "kitty" | "pot", | "ueberzug" |\
"viu")
get_image_source get_image_source
[[ ! -f "$image" ]] && { [[ ! -f "$image" ]] && {
@ -3919,7 +3921,7 @@ image_backend() {
err "Image: Unknown image backend specified '$image_backend'." err "Image: Unknown image backend specified '$image_backend'."
err "Image: Valid backends are: 'ascii', 'caca', 'catimg', 'chafa', 'jp2a', 'iterm2', err "Image: Valid backends are: 'ascii', 'caca', 'catimg', 'chafa', 'jp2a', 'iterm2',
'kitty', 'off', 'sixel', 'pot', 'pixterm', 'termpix', 'kitty', 'off', 'sixel', 'pot', 'pixterm', 'termpix',
'tycat', 'w3m')" 'tycat', 'w3m', 'viu')"
err "Image: Falling back to ascii mode." err "Image: Falling back to ascii mode."
print_ascii print_ascii
;; ;;
@ -4398,6 +4400,12 @@ display_image() {
"$image" "$image"
;; ;;
"viu")
viu \
-t -w "$((width / font_width))" -h "$((height / font_height))" \
"$image"
;;
"w3m") "w3m")
get_w3m_img_path get_w3m_img_path
zws='\xE2\x80\x8B\x20' zws='\xE2\x80\x8B\x20'
@ -4973,7 +4981,7 @@ BARS:
IMAGE BACKEND: IMAGE BACKEND:
--backend backend Which image backend to use. --backend backend Which image backend to use.
Possible values: 'ascii', 'caca', 'catimg', 'chafa', 'jp2a', Possible values: 'ascii', 'caca', 'catimg', 'chafa', 'jp2a',
'iterm2', 'off', 'sixel', 'tycat', 'w3m', 'kitty' 'iterm2', 'off', 'sixel', 'tycat', 'w3m', 'kitty', 'viu'
--source source Which image or ascii file to use. --source source Which image or ascii file to use.
Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img',
'/path/to/ascii', '/path/to/dir/', 'command output' [ascii] '/path/to/ascii', '/path/to/dir/', 'command output' [ascii]
@ -4995,6 +5003,7 @@ IMAGE BACKEND:
--tycat source Shortcut to use 'tycat' backend. --tycat source Shortcut to use 'tycat' backend.
--w3m source Shortcut to use 'w3m' backend. --w3m source Shortcut to use 'w3m' backend.
--ueberzug source Shortcut to use 'ueberzug' backend --ueberzug source Shortcut to use 'ueberzug' backend
--viu source Shortcut to use 'viu' backend
--off Shortcut to use 'off' backend (Disable ascii art). --off Shortcut to use 'off' backend (Disable ascii art).
NOTE: 'source; can be any of the following: 'auto', 'ascii', 'wallpaper', '/path/to/img', NOTE: 'source; can be any of the following: 'auto', 'ascii', 'wallpaper', '/path/to/img',
@ -5224,7 +5233,7 @@ get_args() {
"--source") image_source="$2" ;; "--source") image_source="$2" ;;
"--ascii" | "--caca" | "--catimg" | "--chafa" | "--jp2a" | "--iterm2" | "--off" |\ "--ascii" | "--caca" | "--catimg" | "--chafa" | "--jp2a" | "--iterm2" | "--off" |\
"--pot" | "--pixterm" | "--sixel" | "--termpix" | "--tycat" | "--w3m" | "--kitty" |\ "--pot" | "--pixterm" | "--sixel" | "--termpix" | "--tycat" | "--w3m" | "--kitty" |\
"--ueberzug") "--ueberzug" | "--viu")
image_backend="${1/--}" image_backend="${1/--}"
case $2 in case $2 in
"-"* | "") ;; "-"* | "") ;;