1#compdef netscape
2
3local curcontext="$curcontext" state line expl ret=1 suf files
4typeset -A opt_args
5
6_x_arguments -C \
7  '-xrm:resource:_x_resource' \
8  '-help[show usage message]' \
9  '-version[show the version number and build date]' \
10  '-visual[use a specific server visual]:visual:_x_visual -b' \
11  '-install[install a private colormap]' \
12  '-no-install[use the default colormap]' \
13  '-ncols[max no. of colors to allocate for images]:n:' \
14  '-mono[force 1-bit-deep image display]' \
15  '-iconic[start up iconified]' \
16  '-remote[execute a command in an existing Netscape]:remote command:->remote' \
17  '-id[id of X window to send remote commands to]:window-id:' \
18  '-raise[raise window following remote command]' \
19  "-noraise[don't raise window following remote command]" \
20  '-nethelp[show nethelp]' \
21  -{dont-force-window-stacking,no-about-splash} \
22  -{,no-}{,irix-}session-management \
23  -{done-save,ignore}-geometry-prefs \
24  -{component-bar,composer,edit,messenger,mail,discussions,news} \
25  '*:location:->urls' && ret=0
26
27# Handle netscape remote commands
28if [[ "$state" = "remote" ]]; then  
29  local -a remote_commands
30  remote_commands=(openURL openFile saveAs mailto addBookmark)
31
32  compset -P '*\('
33  if compset -S '(|\\)\)*'; then
34    set - -S "" "$@"
35  else
36    set - -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " "$@"
37  fi
38  case $IPREFIX in
39    openURL*|addBookmark*) state=urls;;
40    openFile*) _files "$@" -W ~;;
41    saveAs*) 
42      if compset -P "*,"; then
43        _wanted types expl 'data type' \
44            compadd "$@" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && ret=0
45      else
46        compset -S ",*" || suf=","
47        _files -qS "$suf" -W ~ && ret=0
48      fi
49    ;;
50    mailto*)
51      _email_addresses -s, -c && ret=0
52    ;;
53    *)
54      compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}"
55      _wanted commands expl 'remote commands' \
56          compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' -a \
57                  remote_commands && ret=0
58    ;;
59  esac
60fi
61
62if [[ "$state" = "urls" ]]; then
63  _tags files urls
64  while _tags; do
65    _requested files expl 'file' _files "$@" && files=yes ret=0
66    if _requested urls; then
67      # Complete netscape urls
68      if compset -P about: ; then
69	_wanted values expl 'about what' \
70            compadd "$@" authors blank cache document fonts global hype \
71	    	image-cache license logo memory-cache mozilla plugins && ret=0
72      elif compset -P news: ; then
73	_newsgroups "$@" && ret=0
74      elif compset -P mailto: ; then
75        _email_addresses -c && ret=0
76      else
77	_tags prefixes
78	while _tags; do
79	  while _next_label prefixes expl 'URL prefix' "$@"; do
80            _urls "$expl[@]" && ret=0
81	    compset -S '[^:]*'
82            compadd -S '' "$expl[@]" about: news: mailto: mocha: javascript: && ret=0
83	  done
84	  (( ret )) || return 0
85	done
86        [[ -z "$files" ]] && _tags files
87      fi
88    fi
89    (( ret )) || return 0
90  done
91fi
92
93return ret
94