reverse coloring variable

This commit is contained in:
ville rantanen
2018-12-23 11:10:49 +02:00
parent 3417d51326
commit 3fd0d1f12e
2 changed files with 29 additions and 9 deletions

View File

@@ -24,12 +24,12 @@ function select_option {
cursor_blink_on() { printf "$ESC[?25h"; }
cursor_blink_off() { printf "$ESC[?25l"; }
cursor_to() { printf "$ESC[$1;${2:-1}H"; }
if [[ $COLORS -eq 1 ]]; then
print_option() { printf " $ESC[33m $1 $ESC[0m "; }
print_selected() { printf " [$ESC[37;1m$1$ESC[0m] "; }
else
if [[ $SELECT_MONOCHROME -eq 1 ]]; then
print_option() { printf " $1 "; }
print_selected() { printf " [$ESC[1m$1$ESC[0m] "; }
else
print_option() { printf " $ESC[33m $1 $ESC[0m "; }
print_selected() { printf " [$ESC[37;1m$1$ESC[0m] "; }
fi
get_cursor_row() { IFS=';' read -sdR -p $'\E[6n' ROW COL; echo ${ROW#*[}; }
key_input() { read -s -n1 key1 2>/dev/null >&2
@@ -88,7 +88,7 @@ function select_option {
if [ $selected -lt 0 ]; then selected=$(($# - 1)); fi;;
down) ((selected++));
if [ $selected -ge $# ]; then selected=0; fi;;
[0-9]) selected=$(( $user_input - 1 )); break;;
[0-9]) selected=$(( $user_input - 1 )) ;;
esac
done
@@ -130,7 +130,7 @@ _help() {
exit
}
SELECT_COLORS=1
SELECT_MONOCHROME=0
SELECT_NUMBERS=0
SELECT_UNDERSCORES=0
SELECT_TOFILE=""
@@ -139,7 +139,7 @@ for (( i=1; i<=$#; i++ )); do
j=$(( i + 1 ))
[[ "$value" = "-h" ]] && _help
[[ "$value" = "--help" ]] && _help
[[ "$value" = "--nc" ]] && { SELECT_COLORS=0; continue; }
[[ "$value" = "--nc" ]] && { SELECT_MONOCHROME=1; continue; }
[[ "$value" = "-n" ]] && { SELECT_NUMBERS=1; continue; }
[[ "$value" = "-_" ]] && { SELECT_UNDERSCORES=1; continue; }
[[ "$value" = "-o" ]] && { SELECT_TOFILE="${!j}"; ((i++)); continue; }