about summary refs log tree commit diff
path: root/Completion/X/Command/_acroread
blob: 4a5cb5cb8ce658d701de50c5e142f482a00bb1af (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
#compdef acroread

local curcontext="$curcontext" state line
local cmdfile

if [[ -z $_acroread_version ]]; then
  _acroread_version="$($words[1] -version 2>/dev/null)"
fi

if [[ -z $_acroread_version ]]; then
  if [[ $words[1] = */* && -x $words[1] ]]; then
    cmdfile=$words[1]
  elif [[ -x $commands[$words[1]] ]]; then
    cmdfile=$commands[$words[1]]
  fi

  # Try extracting the version number directly from the executable.
  # (This will fail if the executable is a wrapper script for acroread.)
  _acroread_version=${${(M)${(f)"$(<$cmdfile)"}:#ver=*}##ver=}

  if [[ -z $_acroread_version ]]; then
    local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
    if [[ -r $acropath ]]; then
      _acroread_version=${${(M)${(f)"$(<$acropath)"}:#ver=*}##ver=}
    fi
  fi
fi

if [[ $_acroread_version == [789].* ]]; then
  local -a extra_args
  extra_args=()
  if [[ $_acroread_version == [89].* ]]; then
    extra_args+=(-man '-installCertificate:server ip::server port')
  fi
  if [[ $_acroread_version == 9.* ]]; then
    extra_args+=(-openInNewInstance)
  fi
  _arguments -C \
    "${extra_args[@]}" \
    '--display=:X display:_x_display' \
    '--screen=:X screen (overrides the screen part of DISPLAY)' \
    --sync \
    '-geometry:[<width>x<height>][{+|-}<x offset>{+|-}<y offset>]' \
    -help \
    -iconic \
    '*-setenv:<var>=<value>' \
    -tempFile \
    '-tempFileTitle:title' \
    -openInNewWindow \
    -version \
    '-visual:X visual:_x_visual' \
    '-toPostScript:*::PostScript conversion options:= ->tops' \
    '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return

  [[ -n "$state" ]] && _arguments \
    '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \
    -binary \
    '-start:integer' \
    '-end:integer' \
    -optimizeForSpeed \
    -landscape \
    -reverse \
    '(-even)-odd' \
    '(-odd)-even' \
    -commentsOff \
    -annotsOff \
    -stampsOff \
    -markupsOn \
    '(-level3)-level2' \
    '(-level2)-level3' \
    -printerhalftones \
    -saveVM \
    '-scale:integer' \
    -shrink \
    -expand \
    '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \
    '-transQuality:transparency flattening level:(1 2 3 4 5)' \
    '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return
else
  _x_arguments -C \
    -help \
    -helpall \
    \*-iconic \
    \*+iconic \
    '-name:application name:_x_name' \
    '*-setenv:<var>=<value>' \
    -tempFile \
    '-tempFileTitle:title' \
    '(+useFrontEndProgram)-useFrontEndProgram' \
    '(-useFrontEndProgram)+useFrontEndProgram' \
    '-visual:X visual:_x_visual' \
    '-xrm:X resource specification:_x_resource' \
    '-toPostScript:*::PostScript conversion options:= ->tops' \
    '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return

  [[ -n "$state" ]] && _arguments \
    '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \
    -binary \
    '-start:integer' \
    '-end:integer' \
    -optimizeForSpeed \
    -landscape \
    -reverse \
    '(-even)-odd' \
    '(-odd)-even' \
    -commentsOff \
    '(-level2 -level3)-level1' \
    '(-level1 -level3)-level2' \
    '(-level1 -level2)-level3' \
    -printerhalftones \
    -saveVM \
    '-scale:integer' \
    -shrink \
    '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \
    '-transQuality:transparency flattening level:(1 2 3 4 5)' \
    '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return
fi

return 1