Skip to content

Commit

Permalink
fix selector ksh
Browse files Browse the repository at this point in the history
  • Loading branch information
joknarf committed Jan 15, 2024
1 parent 1654268 commit b602744
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cdhist
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,14 @@ 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
Expand Down Expand Up @@ -343,11 +344,11 @@ function _domenu
filter="";_select "$prompt" "_nsel+lines-1" "$nbitems" "$filter";;
'[5~'|$'\x02') #pageup Ctl-B
filter="";_select "$prompt" "_nsel-lines+1" "$nbitems" "$filter";;
'[19~'|$'\x04') # F8 Ctl-D delete
'[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 b602744

Please sign in to comment.