about summary refs log tree commit diff
path: root/Completion/X/_xwit
blob: 5e14fec89ddd3fea325c582b022c697a5c7071b6 (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
#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 () {
  local expl
  _description options expl option
  compadd "$expl[@]" - ${(k)no[(R)*~0]} || compadd "$expl[@]" - ${(k)no}
}

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