reverse coloring variable
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
_qColVersion() { echo Version 2018.10.23.0; }
|
||||
_qColVersion() { echo Version 2018.12.23.0; }
|
||||
|
||||
_qColHelp() {
|
||||
_qColVersion
|
||||
@@ -30,7 +30,13 @@ Examples:
|
||||
_qCol export _c
|
||||
echo -e ${_cG}Title${_cZ}
|
||||
|
||||
Run qolop as script to print ANSI code table
|
||||
Run qolop as script to print ANSI code table, or evaluate commands
|
||||
|
||||
qolop eval "_qCol G; printf hello; _qCol z" | qolop export
|
||||
|
||||
The first command produces string with ANSI commands, the
|
||||
second will escape the escape characters, so you can copy/paste
|
||||
it in to another echo -e command.
|
||||
'
|
||||
}
|
||||
|
||||
@@ -123,6 +129,9 @@ _qPos() {
|
||||
[[ "$1" = "linedown" ]] && { printf '\033['${n}'F'; return; }
|
||||
[[ "$1" = "col" ]] && { printf '\033['${n}'G'; return; }
|
||||
[[ "$1" = "abs" ]] && { printf '\033['${n}';'${x}'H'; return; }
|
||||
echo "Command missing: save, restore, up, down, right, left, lineup, linedown, col, abs" >&2
|
||||
echo "Directional commands take one argument, abs uses two (row, col)" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
_qClr() {
|
||||
@@ -170,6 +179,17 @@ if [[ "$0" = "${BASH_SOURCE[0]}" ]]; then
|
||||
rm -f "$TMPFILE"
|
||||
exit 0
|
||||
} # end update
|
||||
[[ "$1" = "eval" ]] && {
|
||||
set -e
|
||||
eval "$@"
|
||||
exit
|
||||
}
|
||||
[[ "$1" = "export" ]] && {
|
||||
cat - | sed s/$'\e'/\\\\033/g
|
||||
echo ''
|
||||
exit
|
||||
}
|
||||
|
||||
_qColHelp
|
||||
[[ "$1" = *"help" ]] && exit
|
||||
[[ "$1" = "-h" ]] && exit
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user