about summary refs log tree commit diff
path: root/Completion/Unix/Command/_enscript
blob: 3e09da5a458b2581b88bd844cf6909810f85441c (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#compdef enscript

local curcontext="$curcontext" state line match
typeset -A opt_args
local -a libpath

_arguments -C -s -S \
  '(   -2 --columns)-1' \
  '(-1    --columns)-2' \
  '(-1 -2          )--columns=:columns:' \
  '(--pages)-a+:pages:(even odd)' \
  '(-a)--pages=:pages:(even odd)' \
  '(--file-align)-A+:align:' \
  '(-A)--file-align=:align:' \
  '(--header -b -B --no-header --lineprinter -l)'{-b+,--header=}':page header:->formats' \
  '(--header -b -B --no-header --lineprinter -l)'{-B,--no-header} \
  '(--truncate-lines)-c' \
  '(-c)--truncate-lines' \
  '(--line-numbers -C)'{-C-,--line-numbers=-}'::start line [1]' \
  '(--printer -d   )-P+:printer name: _printers' \
  '(--printer    -P)-d+:printer name: _printers' \
  '(          -d -P)--printer=:printer name: _printers' \
  '*-D+:key\:value:' \
  '*--setpagedevice=:key\:value:' \
  '(--escapes)-e-:escape character:' \
  '(-e)--escapes=-:escape character:' \
  '(-E --highlight)'{-E-,--highlight=-}':input language:->inputlang' \
  '(--font -f)'{-f+,--font=}':fontname:->fonts' \
  '(--header-font -F)'{-F+,--header-font=}':fontname:->fonts' \
  '(--print-anyway)-g' \
  '(-g)--print-anyway' \
  '(--fancy-header)-G' \
  '(-G)--fancy-header=:header:->headers' \
  '(--no-job-header)-h' \
  '(-h)--no-job-header' \
  '(--highlight-bars -H)'{-H-,--highlight-bars=-}'::height (lines) [2]' \
  '(--indent -i)'{-i+,--indent=}':indent width' \
  '(--filter -I)'{-I+,--filter=}':input filter:_cmdstring' \
  '(--borders)-j' \
  '(-j)--borders' \
  '(-k --page-prefeed -K --no-page-prefeed)'{-k,--page-prefeed} \
  '!(-k --page-prefeed -K --no-page-prefeed)'{-K,--no-page-prefeed} \
  '(--lineprinter -l --lines-per-page -L --header -b -B --no-header)'{-l,--lineprinter} \
  '(--lines-per-page -L --lineprinter -l)'{-L+,--lines-per-page=}':lines per page' \
  '(--mail)-m' \
  '(-m)--mail' \
  '(--media)-M+:media name:(A4)' \
  '(-M)--media=:media name:(A4)' \
  '(--copies -n   )-#+:number of copies:' \
  '(--copies    -#)-n+:number of copies:' \
  '(         -n -#)--copies=:number of copies:' \
  '(--newline)-N+:newline type:((n\:unix r\:mac))' \
  '(-N)--newline=:newline type:((n\:unix r\:mac))' \
  '(-o -p --output -p)'{-o+,-p+,--output=}':output file:_files' \
  '(--missing-characters)-O' \
  '(-O)--missing-characters' \
  '(--quiet --silent)-q' \
  '(-q --silent)--quiet' \
  '(-q --quiet)--silent' \
  '(-r --landscape -R --portrait)'{-r,--landscape} \
  '(-r --landscape -R --portrait)'{-R,--portrait} \
  '(--baselineskip -s)'{-s+,--baselineskip=}':baseline skip (PostScript points) [1]' \
  '*-S+:key\:value:' \
  '*--statusdict=:key\:value:' \
  '(--title -t   )-J+:banner title:' \
  '(--title    -J)-t+:banner title:' \
  '(        -t -J)--title=:banner title:' \
  '(--tabsize -T)'{-T+,--tabsize=}':tabsize [8]' \
  '(--underlay)-u-:underlay text:' \
  '(-u)--underlay=-:underlay text:' \
  '(--nup)-U+:pages:(4)' \
  '(-U)--nup=:pages:(4)' \
  '(--verbose)-v' \
  '(-v)--verbose=-:level:' \
  '(- *)'{-V,--version} \
  '(-w --language)'{-w-,--language=}':output language:(PostScript html overstrike rtf)' \
  '(-W --option)'{-W-,--option=}':helper option' \
  '(--encoding)-X+:character encoding:(88591 latin1 88592 latin2 88593 latin3 88594 latin4 88595 cyrillic 88597 greek 88599 latin5 885910 latin6 ascii asciifise asciifi asciise asciidkno asciidk asciino ibmpc pc dos mac vms hp8 koi8 ps PS pslatin1 ISOLatin1Encoding)' \
  '(-X)--encoding=:character encoding:(88591 latin1 88592 latin2 88593 latin3 88594 latin4 88595 cyrillic 88597 greek 88599 latin5 885910 latin6 ascii asciifise asciifi asciise asciidkno asciidk asciino ibmpc pc dos mac vms hp8 koi8 ps PS pslatin1 ISOLatin1Encoding)' \
  '(--no-formfeed)-z' \
  '(-z)--no-formfeed' \
  '(--pass-through)-Z' \
  '(-Z)--pass-through' \
  '--color=-:use color:(false true)' \
  '--continuous-page-numbers' \
  '--download-font=:fontname:' \
  '--extended-return-values' \
  '--filter-stdin=:stdin name:(-)' \
  '--footer=:page footer:->formats' \
  '--h-column-height=:horizontal column height:' \
  '(- *)--help' \
  '(- *)--help-highlight' \
  '--highlight-bar-gray=:gray level (0-1):' \
  '--list-media' \
  '--margins=:left\:right\:top\:bottom:' \
  '--mark-wrapped-lines=-:wrapped line style [none]:(none plus box arrow)' \
  '--non-printable-format=:rendering of non-printable characters:(caret octal questionmark space)' \
  '--nup-columnwise' \
  '--nup-xpad=:x-padding [10]' \
  '--nup-ypad=:y-padding [10]' \
  '--page-label-format=:page label format:(short long)' \
  '--ps-level=:PostScript language level:(1 2)' \
  '--printer-options=:extra options:' \
  '--rotate-even-pages' \
  '--slice=:vertical slice number' \
  '--style=:highlighting style:(a2ps emacs emacs_verbose ifh msvc)' \
  '--swap-even-page-margins' \
  '--toc' \
  '--word-wrap' \
  '--ul-angle=:angle' \
  '--ul-font=:fontname [Times-Roman200]:->fonts' \
  '--ul-gray=:gray level (0..1) [.8]' \
  '--ul-position=:position [+0+0 -0-0]' \
  '--ul-style=:style [outline]:(outline filled)' \
  '*:filename:_files' && return 0

case "$state" in
  fonts)
    if compset -P 1 '*@'; then
      _message -e size 'pointsize, optionally width/height'
    else
      libpath=( {${commands[enscript]:h:h},/usr}/share/enscript/afm/font.map(N) )
      _wanted fonts expl font compadd -qS @ - ${${(f)"$(<$libpath[1])"}%% *}
    fi
  ;;
  formats)
    local -a specs
    local suf='{'
    compquote suf
    if [[ ${PREFIX} = *[%$]D${suf}[^}]# ]]; then
      _strftime
    elif [[ ${(Q)PREFIX} = *\$\([^\)]# ]]; then
      compset -P '*\('
      _parameters -g '*export*' -S '\)'
    elif [[ ${(Q)PREFIX} = *\$ ]]; then
      specs=(
	'$:a dollar symbol'
	'%:current page number'
	'=:number of pages in the current file'
	'p:number of pages processed so far'
	{C,\*}':file modification time (hh:mm:ss)'
	'n:basename of the input file name'
	'N:full input file name'
	'E:file modification date (yy/mm/dd)'
	'F:file modification date (dd.mm.yyyy)'
	't:file modification time (12-hour)'
	'T:file modification time (24-hour)'
	'v:sequence number of current input file'
	'V:sequence number of current input file in table of contents format'
	'W:file modification date (mm/dd/yy)'
	'\(:environment variable'
      )
      compset -P "*"
      _describe -t format-specifiers 'format specifier' specs -S '' -- '( D:modification\ date )' -qS $suf
    elif [[ ${(Q)PREFIX} = *% ]]; then
      specs=(
	'c:trailing component of the current working directory'
	{C,\*}':current time (hh:mm:ss)'
	'E:current date (yy/mm/dd)'
	'F:current date (dd.mm.yyyy)'
	'H:document title'
	'L:lines in the input file'
	'm:hostname in short form'
        'M:hostname in fully qualified form'
	'n:user login name'
	'N:user gecos field first component'
	't:current time (12-hour)'
	'T:current time (24-hour)'
	'W:current date (mm/dd/yy)'
      )
      compset -P "*"
      _describe -t format-specifiers 'format specifier' specs -S '' -- '( D:current\ time )' -qS $suf
    else
      compset -P "*"
      _wanted format-specifiers expl 'format specifier' compadd -S '' % \$
    fi
  ;;
  headers)
    libpath=( {${commands[enscript]:h:h},/usr}/share/enscript(N/) ~/.enscript(N/) )
    _wanted headers expl header compadd $^libpath/*.hdr(N:r:t)
  ;;
  inputlang)
    if (( ! $+_cache_enscript_languages )); then
      typeset -ga _cache_enscript_languages
      _cache_enscript_languages=(${${(f)${(F)${(M)${(f)"$(_call_program languages enscript --help-pretty-print)"}:#(Name|Description):*}}//(#b)Name: ([^
]##)(
Description: ([^
]##)|)/$match[1]:$match[3]}%:})
    fi
    _describe -t languages 'input language' _cache_enscript_languages
  ;;
esac