Skip to content

Commit

Permalink
update selector
Browse files Browse the repository at this point in the history
  • Loading branch information
joknarf committed Jan 15, 2024
1 parent bd910c9 commit 9467078
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions redo
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,18 @@ EOT

function _readkey
{
typeset o=${1:-n} k
typeset o=${1:-n} k tmout=0.001
[ "$KSH_VERSION" ] && tmout=1
IFS= read -rs${o}1 key
[ "$key" = $'\x1b' ] && key="" && while true
do
k=""
read -rs${o}1 -t 0.001 k 2>/dev/null
[ $? = 1 ] && [ ! "$ZSH_VERSION" ] && read -rs${o}1 -t 1 k # old bash
read -rs${o}1 -t $tmout k 2>/dev/null
[ $? = 1 ] && [ "$BASH" ] && read -rs${o}1 -t 1 k # old bash
[ ! "$k" ] && key=${key:-$'\x1b'} && break
key+="$k"
case "$key" in
'['[A-H]|'['*'~'|O[A-S]|'[1;2'[P-S]) break;;
'['[A-H]|'['*'~'|O[A-S]|'[1;2'[P-S]) break;;
esac
done
printf "%s" "$key"
Expand Down Expand Up @@ -299,8 +300,8 @@ function _domenu
'[19~'|$'\x04'|'[3~') # F8 Ctl-D delete
[ "$_delfunc" ] && $_delfunc "${_aitems[$_nsel]}"
unset "_aitems[$_nsel]"
[ "$BASH" ] && _aitems=(_ "${_aitems[@]}") && unset '_aitems[0]' ||\
_aitems=("${(@)_aitems[1,$_nsel-1]}" "${(@)_aitems[$_nsel+1,$nbitems]}")
[ "$ZSH_VERSION" ] && _aitems=("${(@)_aitems[1,$_nsel-1]}" "${(@)_aitems[$_nsel+1,$nbitems]}") ||\
_aitems=(_ "${_aitems[@]}") && unset '_aitems[0]'
nbitems=${#_aitems[@]}
tput ed
filter="";_select "$prompt" "$_nsel" "$nbitems" "$filter";;
Expand Down

0 comments on commit 9467078

Please sign in to comment.