fix: Fix select after refactor
This commit is contained in:
+18
-19
@@ -59,16 +59,6 @@ _increment_selected() {
|
|||||||
echo -n $selected
|
echo -n $selected
|
||||||
}
|
}
|
||||||
|
|
||||||
# checks if $1 contains element $2
|
|
||||||
_contains() {
|
|
||||||
items=$1
|
|
||||||
search=$2
|
|
||||||
for item in "${items[@]}"; do
|
|
||||||
if [ "$item" == "$search" ]; then return 0; fi
|
|
||||||
done
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# @description Prompt for text
|
# @description Prompt for text
|
||||||
# @arg $1 string Phrase for prompting to text
|
# @arg $1 string Phrase for prompting to text
|
||||||
# @stderr Instructions for user
|
# @stderr Instructions for user
|
||||||
@@ -203,12 +193,14 @@ checkbox() {
|
|||||||
local idx=0
|
local idx=0
|
||||||
for opt in "${opts[@]}"; do
|
for opt in "${opts[@]}"; do
|
||||||
_cursor_to $((startrow + idx))
|
_cursor_to $((startrow + idx))
|
||||||
local icon
|
local icon="◯"
|
||||||
if _contains "${checked[*]}" $idx; then
|
for item in "${checked[@]}"; do
|
||||||
icon=$(echo -en "\u25C9")
|
if [ "$item" == "$idx" ]; then
|
||||||
else
|
icon="◉"
|
||||||
icon=$(echo -en "\u25EF")
|
break;
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [ $idx -eq $selected ]; then
|
if [ $idx -eq $selected ]; then
|
||||||
printf "%s \e[0m\e[36m\u276F\e[0m \e[36m%-50s\e[0m" "$icon" "$opt" >&2
|
printf "%s \e[0m\e[36m\u276F\e[0m \e[36m%-50s\e[0m" "$icon" "$opt" >&2
|
||||||
else
|
else
|
||||||
@@ -221,8 +213,15 @@ checkbox() {
|
|||||||
case $(_key_input) in
|
case $(_key_input) in
|
||||||
enter) break;;
|
enter) break;;
|
||||||
space)
|
space)
|
||||||
if _contains "${checked[*]}" $selected; then
|
local found=0;
|
||||||
checked=( "${checked[@]/$selected}" )
|
for item in "${checked[@]}"; do
|
||||||
|
if [ "$item" == "$selected" ]; then
|
||||||
|
found=1
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ $found -eq 1 ]; then
|
||||||
|
checked=( "${checked[@]/$selected}" )
|
||||||
else
|
else
|
||||||
checked+=("${selected}")
|
checked+=("${selected}")
|
||||||
fi
|
fi
|
||||||
@@ -236,7 +235,7 @@ checkbox() {
|
|||||||
_cursor_to "${lastrow}"
|
_cursor_to "${lastrow}"
|
||||||
_cursor_blink_on
|
_cursor_blink_on
|
||||||
|
|
||||||
IFS=" " echo -n "${checked[@]}"
|
IFS="" echo -n "${checked[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# @description Show password prompt displaying stars for each password character letter typed
|
# @description Show password prompt displaying stars for each password character letter typed
|
||||||
|
|||||||
Reference in New Issue
Block a user