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