Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _xmodmap
- X-seq: zsh-workers 8013
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: _xmodmap
- Date: Thu, 23 Sep 1999 10:07:07 +0200 (MET DST)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Here is completion for `xmodmap' and two helper functions
`_x_modifier' and `_x_keysym'.
About the latter: does anyone know how we can avoid all keysyms that
aren't interesting for a certain environment? Some cpp trickery?
Bye
Sven
diff -u -r oldcompletion/X/_x_keysym Completion/X/_x_keysym
--- oldcompletion/X/_x_keysym Wed Sep 22 23:48:30 1999
+++ Completion/X/_x_keysym Wed Sep 22 22:33:22 1999
@@ -0,0 +1,20 @@
+#autoload
+
+local expl
+
+if (( ! $+_keysym_cache )); then
+ local file
+
+ file=( /usr/{include,{{X11R6,openwin},local{,/X11{,R6}}}/include}/X11/keysymdef.h(N) )
+
+ if (( $#file )); then
+ _keysym_cache=( "${(@)${(@)${(M@)${(@f)$(< $file[1])}:#\#define[ ]##XK_*}#\#define[ ]##XK_}%%[ ]*}" )
+ else
+ _keysym_cache=( BackSpace Tab Linefeed Clear Return Pause Escape
+ Delete Left Right Up Down Space Home Begin End
+ F{1,2,3,4,5,6,7,8,9,10,11,12} )
+ fi
+fi
+
+_description expl 'key symbol'
+compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - $_keysym_cache
diff -u -r oldcompletion/X/_x_modifier Completion/X/_x_modifier
--- oldcompletion/X/_x_modifier Wed Sep 22 23:48:30 1999
+++ Completion/X/_x_modifier Wed Sep 22 22:22:25 1999
@@ -0,0 +1,7 @@
+#autoload
+
+local expl
+
+_description expl modifier
+compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z}' - \
+ Shift Lock Control Mod1 Mod2 Mod3 Mod4 Mod5
diff -u -r oldcompletion/X/_xmodmap Completion/X/_xmodmap
--- oldcompletion/X/_xmodmap Wed Sep 22 23:48:30 1999
+++ Completion/X/_xmodmap Wed Sep 22 22:52:39 1999
@@ -0,0 +1,93 @@
+#compdef xmodmap
+
+setopt localoptions extendedglob
+
+local state line ret=1
+typeset -A options
+
+_x_arguments \
+ -{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 '*[ ]'
+ _description expl 'button code'
+ 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
+ _description expl command
+ compadd "$expl[@]" -S ' ' keycode keysym clear add remove && ret=0
+ compadd "$expl[@]" -S ' = ' pointer && ret=0
+ fi
+fi
+
+return ret
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author