1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-17 22:31:12 +01:00
zsh/Completion/X/_xmodmap

96 lines
2.2 KiB
Text
Raw Normal View History

1999-09-23 15:09:12 +02:00
#compdef xmodmap
1999-11-15 13:01:46 +01:00
local curcontext="$curcontext" state line ret=1
1999-10-13 19:50:30 +02:00
typeset -A opt_args
1999-09-23 15:09:12 +02:00
1999-11-15 13:01:46 +01:00
_x_arguments -C \
1999-09-23 15:09:12 +02:00
-{help,grammar,verbose,quiet} \
'-n[only show what would be done]' \
'*-e[specify expression]:expression:->expr' \
'-pm[print modifier map]' \
'-pk[print keymap table]' \
'-pke[print keymap table as expressions]' \
'-pp[print pointer map]' \
':X mapping file:_files' && ret=0
if [[ -n "$state" ]]; then
local expl expr="${PREFIX##[ ]#}" what suf
if compset -P '[^ ]##[ ]##'; then
case "$expr" in
keycode*)
if compset -P '*=[ ]#'; then
compset -P '*[ ]'
what=ksyms
elif [[ "$expr" = *[\ \ ]##[^\ \ ]##[\ \ ] ]]; then
IPREFIX="${IPREFIX}${PREFIX}"
PREFIX=''
compadd -S ' ' '=' && ret=0
else
_message 'key code or `any'"'"
fi
;;
keysym*)
if compset -P '*=[ ]#'; then
compset -P '*[ ]'
what=ksyms
elif [[ "$expr" = *[\ \ ]##[^\ \ ]##[\ \ ] ]]; then
IPREFIX="${IPREFIX}${PREFIX}"
PREFIX=''
compadd -S ' ' '=' && ret=0
else
what=ksym-eq
fi
;;
clear*)
what=mods
;;
(add|remove)*)
if compset -P '*[ ]##'; then
what=ksyms
else
what=mods-eq
fi
;;
pointer*)
if compset -P '*=[ ]#'; then
compset -P '*[ ]'
1999-12-01 16:29:41 +01:00
_description values expl 'button code'
1999-09-23 15:09:12 +02:00
compadd "$expl[@]" -qS ' ' 1 2 3 4 5 default
return
else
IPREFIX="${IPREFIX}${PREFIX}"
PREFIX=''
compadd -S ' ' '=' && ret=0
fi
;;
esac
if [[ "$what" = *eq* ]]; then
suf=(-S ' = ')
elif [[ "$what" = *ksyms* ]]; then
if [[ -n "$compstate[quote]" ]]; then
suf=(-S "$compstate[quote] " -r "$compstate[quote] ")
else
suf=(-qS ' ')
fi
else
suf=()
fi
[[ "$what" = *mods* ]] && _x_modifier "$suf[@]" && ret=0
[[ "$what" = *ksym* ]] && _x_keysym "$suf[@]" && ret=0
else
2000-03-23 05:19:26 +01:00
if _wanted commands; then
while _try commands expl command; do
compadd "$expl[@]" -S ' ' keycode keysym clear add remove && ret=0
compadd "$expl[@]" -S ' = ' pointer && ret=0
(( ret )) || return 0
done
1999-11-12 16:28:24 +01:00
fi
1999-09-23 15:09:12 +02:00
fi
fi
return ret