11
|
1 " NetrwFileHandlers: contains various extension-based file handlers for
|
21
|
2 " netrw's browsers' x command ("eXecute launcher")
|
458
|
3 " Author: Charles E. Campbell, Jr.
|
|
4 " Date: Apr 07, 2005
|
|
5 " Version: 4a NOT RELEASED
|
22
|
6
|
11
|
7 " ---------------------------------------------------------------------
|
458
|
8 " Load Once: {{{1
|
22
|
9 if exists("g:loaded_netrwfilehandlers") || &cp
|
458
|
10 finish
|
22
|
11 endif
|
458
|
12 let s:keepcpo= &cpo
|
|
13 set cpo&vim
|
|
14 let g:loaded_netrwfilehandlers= "v4a"
|
11
|
15
|
22
|
16 " ---------------------------------------------------------------------
|
|
17 " NetrwFileHandler_html: handles html when the user hits "x" when the {{{1
|
12
|
18 " cursor is atop a *.html file
|
15
|
19 fun! NetrwFileHandler_html(pagefile)
|
458
|
20 " call Dfunc("NetrwFileHandler_html(".a:pagefile.")")
|
|
21
|
|
22 let page= substitute(a:pagefile,'^','file://','')
|
11
|
23
|
15
|
24 if executable("mozilla")
|
458
|
25 " call Decho("executing !mozilla ".page)
|
|
26 exe "!mozilla \"".page.'"'
|
15
|
27 elseif executable("netscape")
|
458
|
28 " call Decho("executing !netscape ".page)
|
|
29 exe "!netscape \"".page.'"'
|
11
|
30 else
|
458
|
31 " call Dret("NetrwFileHandler_html 0")
|
|
32 return 0
|
11
|
33 endif
|
12
|
34
|
458
|
35 " call Dret("NetrwFileHandler_html 1")
|
15
|
36 return 1
|
|
37 endfun
|
|
38
|
|
39 " ---------------------------------------------------------------------
|
22
|
40 " NetrwFileHandler_htm: handles html when the user hits "x" when the {{{1
|
15
|
41 " cursor is atop a *.htm file
|
|
42 fun! NetrwFileHandler_htm(pagefile)
|
458
|
43 " call Dfunc("NetrwFileHandler_htm(".a:pagefile.")")
|
|
44
|
|
45 let page= substitute(a:pagefile,'^','file://','')
|
15
|
46
|
12
|
47 if executable("mozilla")
|
458
|
48 " call Decho("executing !mozilla ".page)
|
|
49 exe "!mozilla \"".page.'"'
|
12
|
50 elseif executable("netscape")
|
458
|
51 " call Decho("executing !netscape ".page)
|
|
52 exe "!netscape \"".page.'"'
|
15
|
53 else
|
458
|
54 " call Dret("NetrwFileHandler_htm 0")
|
|
55 return 0
|
12
|
56 endif
|
11
|
57
|
458
|
58 " call Dret("NetrwFileHandler_htm 1")
|
15
|
59 return 1
|
11
|
60 endfun
|
|
61
|
|
62 " ---------------------------------------------------------------------
|
22
|
63 " NetrwFileHandler_jpg: {{{1
|
15
|
64 fun! NetrwFileHandler_jpg(jpgfile)
|
458
|
65 " call Dfunc("NetrwFileHandler_jpg(jpgfile<".a:jpgfile.">)")
|
|
66
|
15
|
67 if executable("gimp")
|
458
|
68 exe "silent! !gimp -s ".a:jpgfile
|
15
|
69 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
|
458
|
70 " call Decho("silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".escape(a:jpgfile," []|'"))
|
|
71 exe "!".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:jpgfile.'"'
|
15
|
72 else
|
458
|
73 " call Dret("NetrwFileHandler_jpg 0")
|
|
74 return 0
|
15
|
75 endif
|
|
76
|
458
|
77 " call Dret("NetrwFileHandler_jpg 1")
|
15
|
78 return 1
|
|
79 endfun
|
|
80
|
|
81 " ---------------------------------------------------------------------
|
22
|
82 " NetrwFileHandler_gif: {{{1
|
15
|
83 fun! NetrwFileHandler_gif(giffile)
|
458
|
84 " call Dfunc("NetrwFileHandler_gif(giffile<".a:giffile.">)")
|
|
85
|
15
|
86 if executable("gimp")
|
458
|
87 exe "silent! !gimp -s ".a:giffile
|
|
88 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
|
|
89 exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:giffile.'"'
|
15
|
90 else
|
458
|
91 " call Dret("NetrwFileHandler_gif 0")
|
15
|
92 return 0
|
|
93 endif
|
|
94
|
458
|
95 " call Dret("NetrwFileHandler_gif 1")
|
15
|
96 return 1
|
|
97 endfun
|
|
98
|
|
99 " ---------------------------------------------------------------------
|
22
|
100 " NetrwFileHandler_png: {{{1
|
|
101 fun! NetrwFileHandler_png(pngfile)
|
458
|
102 " call Dfunc("NetrwFileHandler_png(pngfile<".a:pngfile.">)")
|
|
103
|
22
|
104 if executable("gimp")
|
458
|
105 exe "silent! !gimp -s ".a:pngfile
|
|
106 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
|
|
107 exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:pngfile.'"'
|
22
|
108 else
|
458
|
109 " call Dret("NetrwFileHandler_png 0")
|
22
|
110 return 0
|
|
111 endif
|
|
112
|
458
|
113 " call Dret("NetrwFileHandler_png 1")
|
22
|
114 return 1
|
|
115 endfun
|
|
116
|
|
117 " ---------------------------------------------------------------------
|
|
118 " NetrwFileHandler_pnm: {{{1
|
15
|
119 fun! NetrwFileHandler_pnm(pnmfile)
|
458
|
120 " call Dfunc("NetrwFileHandler_pnm(pnmfile<".a:pnmfile.">)")
|
|
121
|
15
|
122 if executable("gimp")
|
458
|
123 exe "silent! !gimp -s ".a:pnmfile
|
|
124 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
|
|
125 exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:pnmfile.'"'
|
15
|
126 else
|
458
|
127 " call Dret("NetrwFileHandler_pnm 0")
|
15
|
128 return 0
|
|
129 endif
|
|
130
|
458
|
131 " call Dret("NetrwFileHandler_pnm 1")
|
15
|
132 return 1
|
|
133 endfun
|
|
134
|
|
135 " ---------------------------------------------------------------------
|
22
|
136 " NetrwFileHandler_bmp: visualize bmp files {{{1
|
15
|
137 fun! NetrwFileHandler_bmp(bmpfile)
|
458
|
138 " call Dfunc("NetrwFileHandler_bmp(bmpfile<".a:bmpfile.">)")
|
|
139
|
15
|
140 if executable("gimp")
|
458
|
141 exe "silent! !gimp -s ".a:bmpfile
|
15
|
142 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
|
458
|
143 exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:bmpfile.'"'
|
15
|
144 else
|
458
|
145 " call Dret("NetrwFileHandler_bmp 0")
|
15
|
146 return 0
|
|
147 endif
|
|
148
|
458
|
149 " call Dret("NetrwFileHandler_bmp 1")
|
15
|
150 return 1
|
|
151 endfun
|
|
152
|
|
153 " ---------------------------------------------------------------------
|
22
|
154 " NetrwFileHandler_pdf: visualize pdf files {{{1
|
21
|
155 fun! NetrwFileHandler_pdf(pdf)
|
458
|
156 " " call Dfunc("NetrwFileHandler_pdf(pdf<".a:pdf.">)")
|
|
157 if executable("gs")
|
|
158 exe 'silent! !gs "'.a:pdf.'"'
|
21
|
159 else
|
458
|
160 " " call Dret("NetrwFileHandler_pdf 0")
|
21
|
161 return 0
|
|
162 endif
|
|
163
|
458
|
164 " " call Dret("NetrwFileHandler_pdf 1")
|
21
|
165 return 1
|
|
166 endfun
|
|
167
|
|
168 " ---------------------------------------------------------------------
|
22
|
169 " NetrwFileHandler_sxw: visualize sxw files {{{1
|
21
|
170 fun! NetrwFileHandler_sxw(sxw)
|
458
|
171 " " call Dfunc("NetrwFileHandler_sxw(sxw<".a:sxw.">)")
|
21
|
172 if executable("gs")
|
458
|
173 exe 'silent! !gs "'.a:sxw.'"'
|
21
|
174 else
|
458
|
175 " " call Dret("NetrwFileHandler_sxw 0")
|
21
|
176 return 0
|
|
177 endif
|
|
178
|
458
|
179 " " call Dret("NetrwFileHandler_sxw 1")
|
21
|
180 return 1
|
|
181 endfun
|
|
182
|
|
183 " ---------------------------------------------------------------------
|
22
|
184 " NetrwFileHandler_doc: visualize doc files {{{1
|
21
|
185 fun! NetrwFileHandler_doc(doc)
|
458
|
186 " " call Dfunc("NetrwFileHandler_doc(doc<".a:doc.">)")
|
|
187
|
21
|
188 if executable("oowriter")
|
458
|
189 exe 'silent! !oowriter "'.a:doc.'"'
|
21
|
190 redraw!
|
|
191 else
|
458
|
192 " " call Dret("NetrwFileHandler_doc 0")
|
21
|
193 return 0
|
|
194 endif
|
|
195
|
458
|
196 " " call Dret("NetrwFileHandler_doc 1")
|
21
|
197 return 1
|
|
198 endfun
|
|
199
|
|
200 " ---------------------------------------------------------------------
|
22
|
201 " NetrwFileHandler_sxw: visualize sxw files {{{1
|
21
|
202 fun! NetrwFileHandler_sxw(sxw)
|
458
|
203 " " call Dfunc("NetrwFileHandler_sxw(sxw<".a:sxw.">)")
|
|
204
|
21
|
205 if executable("oowriter")
|
458
|
206 exe 'silent! !oowriter "'.a:sxw.'"'
|
21
|
207 redraw!
|
|
208 else
|
458
|
209 " " call Dret("NetrwFileHandler_sxw 0")
|
21
|
210 return 0
|
|
211 endif
|
|
212
|
458
|
213 " " call Dret("NetrwFileHandler_sxw 1")
|
21
|
214 return 1
|
|
215 endfun
|
|
216
|
|
217 " ---------------------------------------------------------------------
|
22
|
218 " NetrwFileHandler_xls: visualize xls files {{{1
|
21
|
219 fun! NetrwFileHandler_xls(xls)
|
458
|
220 " " call Dfunc("NetrwFileHandler_xls(xls<".a:xls.">)")
|
|
221
|
21
|
222 if executable("oocalc")
|
458
|
223 exe 'silent! !oocalc "'.a:xls.'"'
|
21
|
224 redraw!
|
|
225 else
|
458
|
226 " " call Dret("NetrwFileHandler_xls 0")
|
21
|
227 return 0
|
|
228 endif
|
|
229
|
458
|
230 " " call Dret("NetrwFileHandler_xls 1")
|
21
|
231 return 1
|
|
232 endfun
|
|
233
|
|
234 " ---------------------------------------------------------------------
|
22
|
235 " NetrwFileHandler_ps: handles PostScript files {{{1
|
|
236 fun! NetrwFileHandler_ps(ps)
|
458
|
237 " call Dfunc("NetrwFileHandler_ps()")
|
22
|
238 if executable("gs")
|
458
|
239 exe "silent! !gs ".a:ps
|
22
|
240 redraw!
|
|
241 elseif executable("ghostscript")
|
458
|
242 exe "silent! !ghostscript ".a:ps
|
22
|
243 redraw!
|
|
244 elseif executable("ghostscript")
|
458
|
245 exe "silent! !ghostscript ".a:ps
|
22
|
246 redraw!
|
|
247 elseif executable("gswin32")
|
458
|
248 exe "silent! !gswin32 \"".a:ps.'"'
|
22
|
249 redraw!
|
24
|
250 else
|
458
|
251 " call Dret("NetrwFileHandler_ps 0")
|
22
|
252 return 0
|
|
253 endif
|
|
254
|
458
|
255 " call Dret("NetrwFileHandler_ps 1")
|
22
|
256 return 1
|
|
257 endfun
|
|
258
|
|
259 " ---------------------------------------------------------------------
|
24
|
260 " NetrwFileHandler_eps: handles encapsulated PostScript files {{{1
|
|
261 fun! NetrwFileHandler_eps(eps)
|
458
|
262 " call Dfunc("NetrwFileHandler_ps()")
|
24
|
263 if executable("gs")
|
458
|
264 exe "silent! !gs ".a:eps
|
24
|
265 redraw!
|
|
266 elseif executable("ghostscript")
|
458
|
267 exe "silent! !ghostscript ".a:eps
|
24
|
268 redraw!
|
|
269 elseif executable("ghostscript")
|
458
|
270 exe "silent! !ghostscript ".a:eps
|
24
|
271 redraw!
|
|
272 elseif executable("gswin32")
|
458
|
273 exe "silent! !gswin32 \"".a:eps.'"'
|
24
|
274 redraw!
|
|
275 else
|
458
|
276 " call Dret("NetrwFileHandler_ps 0")
|
24
|
277 return 0
|
|
278 endif
|
|
279 endfun
|
|
280
|
|
281 " ---------------------------------------------------------------------
|
|
282 " NetrwFileHandler_fig: handles xfig files {{{1
|
|
283 fun! NetrwFileHandler_fig(fig)
|
458
|
284 " call Dfunc("NetrwFileHandler_fig()")
|
24
|
285 if executable("xfig")
|
458
|
286 exe "silent! !xfig ".a:fig
|
24
|
287 redraw!
|
|
288 else
|
458
|
289 " call Dret("NetrwFileHandler_fig 0")
|
24
|
290 return 0
|
|
291 endif
|
|
292
|
458
|
293 " call Dret("NetrwFileHandler_fig 1")
|
24
|
294 return 1
|
|
295 endfun
|
|
296
|
|
297 " ---------------------------------------------------------------------
|
|
298 " NetrwFileHandler_obj: handles tgif's obj files {{{1
|
|
299 fun! NetrwFileHandler_obj(obj)
|
458
|
300 " call Dfunc("NetrwFileHandler_obj()")
|
24
|
301 if has("unix") && executable("tgif")
|
458
|
302 exe "silent! !tgif ".a:obj
|
24
|
303 redraw!
|
|
304 else
|
458
|
305 " call Dret("NetrwFileHandler_obj 0")
|
24
|
306 return 0
|
|
307 endif
|
|
308
|
458
|
309 " call Dret("NetrwFileHandler_obj 1")
|
24
|
310 return 1
|
|
311 endfun
|
|
312
|
458
|
313 let &cpo= s:keepcpo
|
24
|
314 " ---------------------------------------------------------------------
|
458
|
315 " Modelines: {{{1
|
|
316 " vim: ts=4 fdm=marker
|