* PATCH: completion for more X commands
@ 1999-09-20 11:03 Sven Wischnowsky
1999-09-20 11:52 ` Peter Stephenson
0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 1999-09-20 11:03 UTC (permalink / raw)
To: zsh-workers
This adds `_xutils' containing completion code for some of the
standard X utilities. If this is accepted, `_xrdb' and `_xsetroot'
should be removed. Or should I have split `_xutils' into a set of
small functions?
This doesn't contain completion code for all of the commands, only for
some of those I thought to be interesting enough. Even so, `xset',
`xauth', and `xmodmap' are still missing, I thought that maybe they
deserve their own functions (being somewhat more complicated).
This also changes `_x_color' to exclude the color names with spaces --
they should have equivalents with PascalishNames anyway.
Bye
Sven
diff -u -r ooldcompletion/X/_x_color Completion/X/_x_color
--- ooldcompletion/X/_x_color Mon Sep 20 12:46:52 1999
+++ Completion/X/_x_color Mon Sep 20 12:34:13 1999
@@ -21,7 +21,7 @@
file=( /usr/{lib,{{X11R6,openwin},local{,/X11{,R6}}}/lib}/X11/rgb.txt(N) )
(( $#file )) &&
- _color_cache=( "${(@)${(@f)$(< $file[1])}[2,-1]##* }" )
+ _color_cache=( "${(@)${(@)${(@f)$(< $file[1])}[2,-1]##* }:#* *}" )
fi
# Stupid default value.
diff -u -r ooldcompletion/X/_x_extension Completion/X/_x_extension
--- ooldcompletion/X/_x_extension Mon Sep 20 12:54:20 1999
+++ Completion/X/_x_extension Mon Sep 20 12:55:44 1999
@@ -0,0 +1,17 @@
+#autoload
+
+local expl
+
+(( $+_xe_cache )) || _xe_cache=( "${(@)${(@f)$(xdpyinfo)}[(r)number of extensions:*,-1][2,(r)default screen number:*][1,-2]//[ ]}" )
+
+_description expl 'X extension'
+
+if [[ "$1" = -a ]]; then
+ shift
+
+ compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - all "$_xe_cache[@]"
+else
+ [[ "$1" = - ]] && shift
+
+ compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z} r:|-=* r:|=*' - "$_xe_cache[@]"
+fi
diff -u -r ooldcompletion/X/_x_window Completion/X/_x_window
--- ooldcompletion/X/_x_window Mon Sep 20 12:54:20 1999
+++ Completion/X/_x_window Mon Sep 20 12:57:31 1999
@@ -0,0 +1,19 @@
+#autoload
+
+setopt localoptions extendedglob
+
+local list expl
+
+list=( "${(@)${(M@)${(@f)$(xwininfo -root -tree)}:#[ ]#0x[0-9a-f]# \"*}##[ ]#}" )
+
+if [[ "$1" = -n ]]; then
+ shift
+
+ _description expl 'window name'
+ compadd "$@" "$expl[@]" -d list - "${(@)${(@)list#*\"}%%\"*}"
+else
+ [[ "$1" = - ]] && shift
+
+ _description expl 'window ID'
+ compadd "$@" "$expl[@]" -d list - "${(@)list%% *}"
+fi
diff -u -r ooldcompletion/X/_xutils Completion/X/_xutils
--- ooldcompletion/X/_xutils Mon Sep 20 12:54:20 1999
+++ Completion/X/_xutils Mon Sep 20 12:45:49 1999
@@ -0,0 +1,136 @@
+#compdef xdpyinfo xwininfo xkill xfontsel xfd xev xhost xon xsetroot xwd xwud xrdb
+
+case "$words[1]" in
+xdpyinfo)
+ _x_arguments \
+ -queryExtensions \
+ '-ext:extension: _x_extension -a'
+ ;;
+xwininfo)
+ _x_arguments \
+ -{help,int,stats,bits,events,size,wm,shape,frame,all,english,metric} \
+ '(-id -name)-root' \
+ '(-id -root)-name:name: _x_window -n' \
+ '(-name -root)-id:id: _x_window'
+ ;;
+xkill)
+ _x_arguments \
+ -frame \
+ '(-id)-all' \
+ '(-all)-id:window: _x_window' \
+ '-button:selection button:(any 1 2 3 4 5)'
+ ;;
+xfontsel)
+ _xt_arguments \
+ -{print,noscaled} \
+ '-pattern:font pattern:_x_font' \
+ '-sample:sample text:' \
+ '-sample16:16-bit sample text:'
+ ;;
+xfd)
+ _xt_arguments \
+ '-fn:font: _x_font' \
+ -{box,center} \
+ '-start:first character number:' \
+ '-bc:box border color:_x_color' \
+ '-rows:number of rows:' \
+ '-columns:number of columns:'
+ ;;
+xev)
+ _x_arguments \
+ '-bw:border width:' \
+ '-bs:type of backing store:(NotUseful WhenMapped Always)' \
+ '-id:id:_x_window' \
+ '-s[use save-under]' \
+ '-name:window name:' \
+ '-rv'
+ ;;
+xhost)
+ local expl type ret=1
+
+ if compset -P '-'; then
+ _description expl 'disallow access'
+ compadd "$expl[@]" -M 'm:{a-z}={A-Z} r:|[:.]=* r:|=*' - \
+ "${${(@M)${(@f)$(xhost)}[2,-1]:#LOCAL:*}#INET:}"
+ else
+ compset -P +
+
+ if [[ "$PREFIX" = *:* ]]; then
+ type="${(L)PREFIX%%:*}"
+ compset -P '*:'
+
+ case "$type" in
+ inet) _hosts && ret=0;;
+ dnet) _message 'DECnet host';;
+ nis) _message 'Secure RPC network name';;
+ krb) _message 'Kerberos V5 principal';;
+ esac
+ else
+ _description expl 'name family'
+ compadd -S: - inet dnet nis krb && ret=0
+ _hosts && ret=0
+ fi
+ return ret
+ fi
+ ;;
+xon)
+ _arguments \
+ -{access,debug,nols} \
+ '-name:window name:' \
+ '-screen:screen number:' \
+ '-user:remote user name:_users' \
+ ':remote host:_hosts' \
+ '*:command::command:_normal'
+ ;;
+xsetroot)
+ _x_arguments \
+ -{help,def,gray,grey,rv} \
+ '-cursor:cursor file:_files -g \*.\(\#i\)\(xbm\|curs\(\|or\)\):mask file:_files -g \*.\(\#i\)\(xbm\|curs\(\|or\)\|mask\)' \
+ '-cursor_name:cursor name:_x_cursor' \
+ '-bitmap:bitmap file:_files -g \*.\(\#i\)xbm' \
+ '-mod:x grid distance (1-16): :y grid distance (1-16):' \
+ '-fg:foreground color:_x_color' \
+ '-bg:background color:_x_color' \
+ '-solid:screen solid color:_x_color' \
+ '-name:root window name:'
+ ;;
+xwd)
+ _x_arguments \
+ -{debug,help,nobdrs,xy,frame,root,icmap,screen,silent} \
+ '-out:output file:_files' \
+ '-add:pixel change value:' \
+ '-id:id: _x_window' \
+ '-name:name: _x_window -n'
+ ;;
+xwud)
+ _x_arguments \
+ -{help,new,noclick,raw,rv,scale} \
+ '-bg:background color:_x_color' \
+ '-fg:foreground color:_x_color' \
+ '-in:input file:_files -g \*.\(\#i\)xwd' \
+ '-plane:image plane to display:' \
+ '-std:standard colormap:(best default gray red blue green)' \
+ '-vis:visual class:(StaticGray GrayScale StaticColor PseudoColor DirectColor TrueColor)'
+ ;;
+xrdb)
+ _x_arguments \
+ -{help,quiet,symbols,retain} \
+ '(-all -screen -screens)-global' \
+ '(-global -screen -screens)-all' \
+ '(-global -all -screens)-screen' \
+ '(-global -all -screen)-screens' \
+ '-n[only display on stdout]' \
+ '(-nocpp)-cpp:preprocessor program:_files -g \*\(\*\)' \
+ '(-cpp)-nocpp' \
+ '(-load -override -merge -remove)-query' \
+ '(-query -override -merge -remove)-load' \
+ '(-query -load -merge -remove)-override' \
+ '(-query -load -override -remove)-merge' \
+ '(-query -load -override -merge)-remove' \
+ '-edit:output file:_files' \
+ '-backup:backup extension:' \
+ '*-D-:symbol to define:' \
+ '*-U-:symbol to undefine:' \
+ '*-I-:include directory:_files -/'
+ ;;
+esac
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: completion for more X commands
1999-09-20 11:03 PATCH: completion for more X commands Sven Wischnowsky
@ 1999-09-20 11:52 ` Peter Stephenson
0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 1999-09-20 11:52 UTC (permalink / raw)
To: zsh-workers
Sven Wischnowsky wrote:
> This adds `_xutils' containing completion code for some of the
> standard X utilities. If this is accepted, `_xrdb' and `_xsetroot'
> should be removed.
Except that xrdb now doesn't complete *exactly* the thing I needed _xrdb to
do in the first place.
I thought the theory was there should be some way for the user to intercept
choices with functions of their own by testing something or other?
--- Completion/X/_xutils.xrdb Mon Sep 20 13:38:45 1999
+++ Completion/X/_xutils Mon Sep 20 13:44:24 1999
@@ -131,6 +131,7 @@
'-backup:backup extension:' \
'*-D-:symbol to define:' \
'*-U-:symbol to undefine:' \
- '*-I-:include directory:_files -/'
+ '*-I-:include directory:_files -/' \
+ '*:defaults file:_files'
;;
esac
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PATCH: completion for more X commands
@ 1999-09-20 12:32 Sven Wischnowsky
0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 1999-09-20 12:32 UTC (permalink / raw)
To: zsh-workers
Peter Stephenson wrote:
> Sven Wischnowsky wrote:
> > This adds `_xutils' containing completion code for some of the
> > standard X utilities. If this is accepted, `_xrdb' and `_xsetroot'
> > should be removed.
>
> Except that xrdb now doesn't complete *exactly* the thing I needed _xrdb to
> do in the first place.
Urgh, sorry.
> I thought the theory was there should be some way for the user to intercept
> choices with functions of their own by testing something or other?
That's only needed for sub-commands/states as in `_rpm' (or `_cvs' if
that wouldn't use functions anyway). Functions with `#compdef's with
multiple commands can be overridden by placing a file with a
`#compdef' for the command(s) wanted ealier in the `fpath'.
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-09-20 12:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-20 11:03 PATCH: completion for more X commands Sven Wischnowsky
1999-09-20 11:52 ` Peter Stephenson
1999-09-20 12:32 Sven Wischnowsky
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).