1#compdef xwit 2 3local word=$'[^\0]#\0' 4local nul=$'\0' 5 6local guard='-_xwit_guard ${match[1]%?}' 7 8_xwit_guard () { 9 local opt="$1" o 10 (( no[$opt]-- )) 11 for o in ${=eo[$opt]}; do 12 no[$o]=0 13 done 14 : 15} 16 17_xwit_compopts () { 18 local expl 19 local opt tmp 20 21 tmp=() 22 for opt in ${(k)no[(R)*~0]} 23 do 24 if (( $+desc[$opt] )); then 25 tmp=("$tmp[@]" "$opt:$desc[$opt]") 26 else 27 tmp=("$tmp[@]" "$opt") 28 fi 29 done 30 _describe -o options tmp -- || 31 _describe -o options allopts -- 32 33# compadd "$expl[@]" - ${(k)no[(R)*~0]} || 34# compadd "$expl[@]" - ${(k)no} 35} 36 37_regex_arguments _xwit_parse \ 38 "/$word/" \ 39 \( "/-display$nul/" "$guard" "/$word/" ':option-display:display:_x_display' \ 40 \| "/-(sync|pop|open|iconify|unmap|root|current|select|(no|)(save|backingstore|saveunder))$nul/" "$guard" \ 41 \| "/-resize$nul/" "$guard" \ 42 "/$word/" ':option-resize-width:width:' \ 43 "/$word/" ':option-resize-height:height:' \ 44 \| "/-rows$nul/" "$guard" "/$word/" ':option-rows:rows:' \ 45 \| "/-columns$nul/" "$guard" "/$word/" ':option-columns:columns:' \ 46 \| "/-move$nul/" "$guard" \ 47 "/$word/" ':option-move-x:x:' \ 48 "/$word/" ':option-move-y:y:' \ 49 \| "/-rmove$nul/" "$guard" \ 50 "/$word/" ':option-rmove-x:x:' \ 51 "/$word/" ':option-rmove-y:y:' \ 52 \| "/-warp$nul/" "$guard" \ 53 "/$word/" ':option-warp-x:x:' \ 54 "/$word/" ':option-warp-y:y:' \ 55 \| "/-rwarp$nul/" "$guard" \ 56 "/$word/" ':option-rwarp-x:x:' \ 57 "/$word/" ':option-rwarp-y:y:' \ 58 \| "/-colormap$nul/" "$guard" \ 59 "/$word/" ':option-colormap:colormapid:_x_colormapid' \ 60 \| "/-(name|label)$nul/" "$guard" \ 61 "/$word/" ':option-name:name:_x_name' \ 62 \| "/-iconname$nul/" "$guard" \ 63 "/$word/" ':option-name:iconname:_x_name' \ 64 \| "/-bitmap$nul/" "$guard" \ 65 "/$word/" ':option-bitmap:bitmap file:_files -g *.xbm\(-.\)' \ 66 \| "/-mask$nul/" "$guard" \ 67 "/$word/" ':option-mask:mask file:_files -g *.xbm\(-.\)' \ 68 \| "/-iconmove$nul/" "$guard" \ 69 "/$word/" ':option-iconmove-x:x:' \ 70 "/$word/" ':option-iconmove-y:y:' \ 71 \| "/-id$nul/" "$guard" "/$word/" ':option-id:window id:_x_window' \ 72 \| "/-(no|)keyrepeat$nul/" "$guard" \ 73 \( "/[0-9]##$nul/" ':option-keyrepeat-keycode:keycode:{[[ -prefix [0-9]# ]] && _message -e keycodes keycode}' \ 74 \( "/-$nul/" "/[0-9]##$nul/" \ 75 ':option-keyrepeat-last-keycode:last keycode:{[[ -prefix [0-9]# ]] && _message -e keycodes "last keycode"}' \| \) \) \# \ 76 \| "/-names$nul/" "$guard" \ 77 "/$word/" ':option-names:window name:_x_window -n' \# \ 78 \| "/[]/" ':options:option:_xwit_compopts' \ 79 \) \# 80 81_xwit () { 82 local expl allopts 83 typeset -A desc no eo 84 85 desc=( 86 -display 'specify display' 87 -sync 'synchronous mode' 88 -pop 'pop up window' 89 -open 'pop up window' 90 -iconify 'iconify window' 91 -unmap 'iconify window by unmapping' 92 -root 'select the root window' 93 -current 'select the window under current pointer' 94 -select 'select the window interactively' 95 -save 'activate screen saver' 96 -backingstore 'enable backingstore' 97 -saveunder 'enable saveunder' 98 -nosave 'reset screen saver' 99 -nobackingstore 'disable backingstore' 100 -nosaveunder 'disable saveunder' 101 -resize 'resize window' 102 -rows 'resize window rows' 103 -columns 'resize window columns' 104 -move 'move window' 105 -rmove 'move window relatively' 106 -warp 'warp pointer' 107 -rwarp 'warp pointer relatively' 108 -colormap 'install colormap' 109 -name 'specify window name' 110 -label 'specify window name' 111 -iconname 'specify icon name' 112 -bitmap 'specify icon bitmap' 113 -mask 'specify icon mask' 114 -iconmove 'move icon' 115 -id 'select the window by window-ID' 116 -keyrepeat 'enable keyrepeat' 117 -nokeyrepeat 'disable keyrepeat' 118 -names 'select the window by name' 119 ) 120 121 no=( 122 -display 1 123 -sync 1 124 -pop 1 -open 0 125 -iconify 1 126 -unmap 1 127 -root 1 128 -current 1 129 -select 1 130 -save 1 131 -backingstore 1 132 -saveunder 1 133 -nosave 1 134 -nobackingstore 1 135 -nosaveunder 1 136 -resize 1 137 -rows 1 138 -columns 1 139 -move 1 140 -rmove 1 141 -warp 1 142 -rwarp 1 143 -colormap 1 144 -name 1 -label 0 145 -iconname 1 146 -bitmap 1 147 -mask 1 148 -iconmove 1 149 -id 1 150 -keyrepeat 1 151 -nokeyrepeat 1 152 -names 1 153 ) 154 155 allopts=() 156 for opt in ${(k)no} 157 do 158 if (( $+desc[$opt] )); then 159 allopts=("$allopts[@]" "$opt:$desc[$opt]") 160 else 161 allopts=("$allopts[@]" "$opt") 162 fi 163 done 164 165 eo=( 166 -root '-root -current -select -id -names' 167 -current '-root -current -select -id -names' 168 -select '-root -current -select -id -names' 169 -id '-root -current -select -id -names' 170 -names '-root -current -select -id -names' 171 ) 172 173 _xwit_parse 174} 175 176_xwit "$@" 177