about summary refs log tree commit diff
path: root/Completion/Unix/Command/_w3m
blob: 6e83a6781a5eb52018903bc00263f295b3072bfd (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
#compdef w3m

# w3m version w3m/0.5.1

local curcontext="$curcontext" state line expl ret=1
typeset -A opt_args

_arguments -C \
  '-t[set tab width]:tab width:' \
  '-r[ignore backspace effect]' \
  '-l[specify number of preserved lines]:number of lines (default 10000):' \
  '-I[document charset]:charset:->charset' \
  '-O[display/output charset]:charset:->charset' \
  '(   -s -j)-e[EUC-JP]' \
  '(-e    -j)-s[Shift_JIS]' \
  '(-e -s   )-j[JIS]' \
  '(-v *)-B[load bookmark]' \
  '-bookmark[specify bookmark file]:bookmark file:_files' \
  '-T[specify content-type]:content type:_mime_types' \
  '-m[internet message mode]' \
  '(-B *)-v[visual startup mode]' \
  '-M[monochrome display]' \
  '-N[open URL of command line on each new tab]' \
  '-F[automatically render frame]' \
  '-cols[specify column width (used with -dump)]:column width' \
  '-ppc[specify the number of pixels per character (4.0...32.0)]:number of pixels (4.0...32.0):' \
  '-ppl[specify the number of pixels per line (4.0...64.0)]:number of pixels (4.0...64.0):' \
  '(      -dump_head -dump_source -dump_both -dump_extra)-dump[dump formatted page into stdout]' \
  '(-dump            -dump_source -dump_both -dump_extra)-dump_head[dump HEAD and source into stdout]' \
  '(-dump -dump_head              -dump_both -dump_extra)-dump_source[dump page source into stdout]' \
  '(-dump -dump_head -dump_source            -dump_extra)-dump_both[dump HEAD and source into stdout]' \
  '(-dump -dump_head -dump_source -dump_both            )-dump_extra[dump HEAD, source, and extra information into stdout]' \
  '-post[use POST method with file content]:POST data file:_files' \
  '-header[insert string as a header]:header:' \
  '+-[goto specified line]:line number:_guard "[0-9]#" "line number"' \
  '-num[show line number]' \
  "-no-proxy[don't use proxy]" \
  '(-6)-4[IPv4 only (-o dns_order=4)]' \
  '(-4)-6[IPv6 only (-o dns_order=6)]' \
  "-no-mouse[don't use mouse]" \
  '(-no-cookie)-cookie[use cookie]' \
  "(-cookie)-no-cookie[don't use cookie]" \
  '-pauth[proxy authentication]:user\:pass:->pauth' \
  '(-no-graph)-graph[use graphic character]' \
  "(-graph)-no-graph[don't use graphic character]" \
  '-S[squeeze multiple blank lines]' \
  '-W[toggle wrap search mode]' \
  "-X[don't use termcap init/deinit]" \
  '-title=[set buffer name to terminal title string]:terminal:_terminals' \
  '*-o[assign value to config option]:option=value:->option' \
  '(- *)-show-option[print all config options]' \
  '-config[specify config file]:configuration file:_files' \
  '(- *)-help[print usage information]' \
  '(- *)-version[print version information]' \
  '-debug' \
  '(-B -v)*:URL:->html' && ret=0

local -a suf

case "$state" in
  charset)
    local -a charsets
    charsets=(
      US-ASCII ISO-8859-1 ISO-8859-2 ISO-8859-3 ISO-8859-4 ISO-8859-5
      ISO-8859-6 ISO-8859-7 ISO-8859-8 ISO-8859-9 ISO-8859-10 ISO-8859-11
      ISO-8859-13 ISO-8859-14 ISO-8859-15 ISO-8859-16 EUC-JP Shift_JIS
      Shift_JISX0213 ISO-2022-JP ISO-2022-JP-2 ISO-2022-JP-3 EUC-CN GBK GB18030
      HZ-GB-2312 ISO-2022-CN EUC-TW Big5 HKSCS EUC-KR UHC Johab ISO-2022-KR
      TIS-620 TCVN-5712 VISCII VPS KOI8-R KOI8-U NeXTSTEP CP437 CP737 CP775
      CP850 CP852 CP855 CP856 CP857 CP860 CP861 CP862 CP863 CP864 CP865 CP866
      CP869 CP874 CP1006 CP1250 CP1251 CP1252 CP1253 CP1254 CP1255 CP1256
      CP1257 CP1258 UTF-8 UTF-7
    )
    _wanted charsets expl 'character set' compadd -a charsets && ret=0
  ;;
  html)
    local -a bookmarks w3mhistory
    if [[ -s ~/.w3m/bookmark.html ]]; then
      bookmarks=( ${${(M)${(f)"$(<~/.w3m/bookmark.html)"}:#<li>*}/(#b)<li><a href=\"(*)\">*/$match[1]} )
    fi
    if [[ -s ~/.w3m/history ]]; then
      w3mhistory=( ${(f)"$(<~/.w3m/history)"} )
    fi
    _alternative \
      'files:file:_files -g "*.x#html(-.)"' \
      'urls:URL:_urls' \
      'bookmarks:bookmarks:compadd -a bookmarks' \
      'history:history:compadd -a w3mhistory' && ret=0
  ;;
  option)
    local -a options
    options=( ${${(M)${(f)"$(_call_program options $words[1] -show-option 2>/dev/null)"}:#    -o *}/(#b)    -o (*)=[^ ]#[[:blank:]]##(*)/$match[1]:${match[2]:l}} )
    if compset -P 1 '*='; then
      _message -e values 'value'
    else
      compset -S '=*' || suf=( -S '=' )
      _describe -t options 'option' options "$suf[@]" && ret=0
    fi
  ;;
  pauth)
    if compset -P 1 '*:'; then
      _message -e passwords 'password'
    else
      compset -S ':*' || suf=( -S ':' )
      _users "$suf[@]" && ret=0
    fi
  ;;
esac

return ret