1#autoload
2
3# How to convert XrmOptionDescRec:
4
5# XrmOptionDescRec optionDescList[] = {
6#   ...
7#   {option, specifier, argKind, value},
8#   ...
9# };
10
11#  argKind		argument for _xt_arguments
12#  XrmoptionNoArg	option
13#  XrmoptionIsArg	option
14#  XrmoptionStickyArg	option-:message:action
15#  XrmoptionSepArg	option:message:action
16#  XrmoptionResArg	option:message:_x_resource
17#  XrmoptionSkipArg	option:message:action
18#  XrmoptionSkipLine	option:*::message:action
19#  XrmoptionSkipNArgs	option:message[1]:action[1]:...:message[value]:action[value]
20
21# cf. XrmParseCommand(3X11), X11R6.4/xc/lib/Xt/Initialize.c, X(5)
22
23local ret long xargs opts rawret nm="$compstate[nmatches]"
24
25xargs=(
26  -+{rv,synchronous}
27  -{reverse,iconic}
28  '-background:background color:_x_color'
29  '-bd:border color:_x_color'
30  '-bg:background color:_x_color'
31  '-bordercolor:border color:_x_color'
32  '-borderwidth:border width:_x_borderwidth'
33  '-bw:border width:_x_borderwidth'
34  '-display:display:_x_display'
35  '-fg:foreground color:_x_color'
36  '-font:font:_x_font'
37  '-fn:font:_x_font'
38  '-foreground:foreground color:_x_color'
39  '-geometry:geometry:_x_geometry'
40  '-name:name:_x_name'
41  '-selectionTimeout:selection timeout (milliseconds):_x_selection_timeout'
42  '-title:title:_x_title'
43  '-xnllanguage:locale:_x_locale'
44  '*-xrm:resource:_x_resource'
45  '-xtsessionID:session ID:_xt_session_id'
46)
47
48long=$argv[(I)--]
49if (( long )); then
50  argv[long]=( "$xargs[@]" -- )
51else
52  set -- "$@" "$xargs[@]"
53fi
54
55opts=()
56while [[ $1 = -(O*|[CRWsw]) ]]; do
57  opts=($opts $1)
58  [[ $1 = -R ]] && rawret=yes
59  shift
60done
61
62_arguments -R "$opts[@]" "$@"
63
64ret=$?
65
66if [[ "$ret" = 300 ]]; then
67  compstate[restore]=''
68  [[ -z $rawret ]] && ret=$(( nm == $compstate[nmatches] ))
69fi
70
71return ret
72