From 3c2abf21612e7b9bb7ae48077e6c598f11db7fac Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Thu, 12 Apr 2018 12:07:19 +0200 Subject: [PATCH] gopher.sh: small fixes: - Allow INVERT for colour inversion of displayed images (for bright BG) - Fix PREFIXes ("+" was not recognized) - Fix "EXIT" to exit program in dialog mode (was only going back) - Fix "BACK" to go back to the previous menu in dialog mode (was doing nothing) --- gopher.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gopher.sh b/gopher.sh index 3e9a264..f896f9d 100755 --- a/gopher.sh +++ b/gopher.sh @@ -20,6 +20,9 @@ # 1 : means colour 1 # 2 : means colour 2 # [...] +# INVERT : invert the output for image viewing (for white backgrounds) +# 0 : do not invert (default) +# 1 : invert SERVER="$1" SELECTOR="$2" @@ -60,7 +63,14 @@ if [ "$USE_DIALOG" = "" ]; then fi fi -PREFIX="[0-9hIg]" +# Invert image viewer +if [ "$INVERT" = 1 ]; then + INVERT="--invert" +else + INVERT= +fi + +PREFIX="[0-9hIg+]" # $0 [FILE] (dialog) # Display a gopher menu for the given resource @@ -148,8 +158,9 @@ download) --menu "$title" \ "$LINES" "$COLUMNS" "$LINES" \ --file "$tmp.menu" 2>"$tmp.choice" - clear val=$? + clear + if [ $val = 3 ]; then CHOICE="" elif [ $val = 1 ]; then @@ -193,11 +204,13 @@ download) g|I) if img2aa --help >/dev/null 2>&1; then img2aa --mode=DITHERING \ + $INVERT \ --width=74 "$tmp" | less elif jp2a -h >/dev/null 2>&1; then if convert -h >/dev/null 2>&1; then convert "$tmp" "$tmp.jpg" jp2a --border --chars=" .-+=o8#"\ + $INVERT \ --width=74 "$tmp.jpg" | less else echo "required program not found to view images: convert" \ -- 2.27.0