about summary refs log tree commit diff
path: root/Completion/X/_xwit
blob: 7ec216e7652ad8bc6a9d5e604e8dc69ae3c76931 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#compdef xwit

local word=$'[^\0]#\0'
local nul=$'\0'

local guard='-_xwit_guard -${match[1]%?}'

_xwit_guard () {
  local opt="$1" o
  (( no[$opt]-- ))
  for o in ${=eo[$opt]}; do
    no[$o]=0
  done 
  :
}

_xwit_compopts () {
  compadd "$expl[@]" - ${(k)no[(R)*~0]} ||
    compadd "$expl[@]" - ${(k)no}
}

_regex_arguments _xwit_parse \
  "/$word/" \
  \( \
    "/-/+" \
    \( "/display$nul/" "$guard" "/$word/" ':option-display:display:_x_display' \
    \| "/(sync|pop|open|iconify|unmap|root|current|select|(no|)(save|backingstore|saveunder))$nul/" "$guard" \
    \| "/resize$nul/" "$guard" \
       "/$word/" ':option-resize-width:width:_message width' \
       "/$word/" ':option-resize-height:height:_message height' \
    \| "/rows$nul/" "$guard" "/$word/" ':option-rows:rows:_message rows' \
    \| "/columns$nul/" "$guard" "/$word/" ':option-columns:columns:_message columns' \
    \| "/move$nul/" "$guard" \
       "/$word/" ':option-move-x:x:_message x' \
       "/$word/" ':option-move-y:y:_message y' \
    \| "/rmove$nul/" "$guard" \
       "/$word/" ':option-rmove-x:x:_message x' \
       "/$word/" ':option-rmove-y:y:_message y' \
    \| "/warp$nul/" "$guard" \
       "/$word/" ':option-warp-x:x:_message x' \
       "/$word/" ':option-warp-y:y:_message y' \
    \| "/rwarp$nul/" "$guard" \
       "/$word/" ':option-rwarp-x:x:_message x' \
       "/$word/" ':option-rwarp-y:y:_message y' \
    \| "/colormap$nul/" "$guard" \
       "/$word/" ':option-colormap:colormapid:_x_colormapid' \
    \| "/(name|label)$nul/" "$guard" \
       "/$word/" ':option-name:name:_x_name "$expl[@]"' \
    \| "/iconname$nul/" "$guard" \
       "/$word/" ':option-name:iconname:_x_name "$expl[@]"' \
    \| "/bitmap$nul/" "$guard" \
       "/$word/" ':option-bitmap:bitmap file:_files "$expl[@]" -g \*.xbm' \
    \| "/mask$nul/" "$guard" \
       "/$word/" ':option-mask:mask file:_files "$expl[@]" -g \*.xbm' \
    \| "/iconmove$nul/" "$guard" \
       "/$word/" ':option-iconmove-x:x:_message x' \
       "/$word/" ':option-iconmove-y:y:_message y' \
    \| "/id$nul/" "$guard" "/$word/" ':option-id:window id:_x_window' \
    \| "/(no|)keyrepeat$nul/" "$guard" \
        \( "/[0-9]##$nul/" ':option-keyrepeat-keycode:keycode:[[ -prefix [0-9]# ]] && _message keycode' \
	  \( "/-$nul/" "/[0-9]##$nul/" ':option-keyrepeat-last-keycode:last keycode:[[ -prefix [0-9]# ]] && _message "last keycode"' \| \) \) \# \
    \| "/names$nul/" "$guard" \
       "/$word/" ':option-names:window name:_x_window -n' \# \
    \| "/[]/" ':options:option:_xwit_compopts' \
    \) \
  \) \#

_xwit () {
  typeset -A no eo

  no=(
    -display 1
    -sync 1
    -pop 1 -open 0
    -iconify 1
    -unmap 1
    -root 1
    -current 1
    -select 1
    -save 1
    -backingstore 1
    -saveunder 1
    -nosave 1
    -nobackingstore 1
    -nosaveunder 1
    -resize 1
    -rows 1
    -columns 1
    -move 1
    -rmove 1
    -warp 1
    -rwarp 1
    -colormap 1
    -name 1 -label 0
    -iconname 1
    -bitmap 1
    -mask 1
    -iconmove 1
    -id 1
    -keyrepeat 1
    -nokeyrepeat 1
    -names 1
  )

  eo=(
    -root    '-root -current -select -id -names'
    -current '-root -current -select -id -names'
    -select  '-root -current -select -id -names'
    -id      '-root -current -select -id -names'
    -names   '-root -current -select -id -names'
  )

  _xwit_parse
}

[[ -o kshautoload ]] || _xwit "$@"