Skip to content

Commit b602744

Browse files
committed
fix selector ksh
1 parent 1654268 commit b602744

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cdhist

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,14 @@ EOT
288288

289289
function _readkey
290290
{
291-
typeset o=${1:-n} k
291+
typeset o=${1:-n} k tmout=0.001
292+
[ "$KSH_VERSION" ] && tmout=1
292293
IFS= read -rs${o}1 key
293294
[ "$key" = $'\x1b' ] && key="" && while true
294295
do
295296
k=""
296-
read -rs${o}1 -t 0.001 k 2>/dev/null
297-
[ $? = 1 ] && [ ! "$ZSH_VERSION" ] && read -rs${o}1 -t 1 k # old bash
297+
read -rs${o}1 -t $tmout k 2>/dev/null
298+
[ $? = 1 ] && [ "$BASH" ] && read -rs${o}1 -t 1 k # old bash
298299
[ ! "$k" ] && key=${key:-$'\x1b'} && break
299300
key+="$k"
300301
case "$key" in
@@ -343,11 +344,11 @@ function _domenu
343344
filter="";_select "$prompt" "_nsel+lines-1" "$nbitems" "$filter";;
344345
'[5~'|$'\x02') #pageup Ctl-B
345346
filter="";_select "$prompt" "_nsel-lines+1" "$nbitems" "$filter";;
346-
'[19~'|$'\x04') # F8 Ctl-D delete
347+
'[19~'|$'\x04'|'[3~') # F8 Ctl-D delete
347348
[ "$_delfunc" ] && $_delfunc "${_aitems[$_nsel]}"
348349
unset "_aitems[$_nsel]"
349-
[ "$BASH" ] && _aitems=(_ "${_aitems[@]}") && unset '_aitems[0]' ||\
350-
_aitems=("${(@)_aitems[1,$_nsel-1]}" "${(@)_aitems[$_nsel+1,$nbitems]}")
350+
[ "$ZSH_VERSION" ] && _aitems=("${(@)_aitems[1,$_nsel-1]}" "${(@)_aitems[$_nsel+1,$nbitems]}") ||\
351+
_aitems=(_ "${_aitems[@]}") && unset '_aitems[0]'
351352
nbitems=${#_aitems[@]}
352353
tput ed
353354
filter="";_select "$prompt" "$_nsel" "$nbitems" "$filter";;

0 commit comments

Comments
 (0)