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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
" NetrwFileHandlers: contains various extension-based file handlers for
" netrw's browsers' x command ("eXecute launcher")
" Author: Charles E. Campbell, Jr.
" Date: Aug 15, 2005
" Version: 6
" Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
" NetrwFileHandlers.vim is provided *as is* and comes with no
" warranty of any kind, either expressed or implied. In no
" event will the copyright holder be liable for any damages
" resulting from the use of this software.
"
" Rom 6:23 (WEB) For the wages of sin is death, but the free gift of God {{{1
" is eternal life in Christ Jesus our Lord.
" ---------------------------------------------------------------------
" Load Once: {{{1
if exists("g:loaded_NetrwFileHandlers") || &cp
finish
endif
let s:keepcpo= &cpo
set cpo&vim
let g:loaded_NetrwFileHandlers= "v6"
" ---------------------------------------------------------------------
" NetrwFileHandler_html: handles html when the user hits "x" when the {{{1
" cursor is atop a *.html file
fun! NetrwFileHandler_html(pagefile)
" call Dfunc("NetrwFileHandler_html(".a:pagefile.")")
let page= substitute(a:pagefile,'^','file://','')
if executable("mozilla")
" call Decho("executing !mozilla ".page)
exe "!mozilla \"".page.'"'
elseif executable("netscape")
" call Decho("executing !netscape ".page)
exe "!netscape \"".page.'"'
else
" call Dret("NetrwFileHandler_html 0")
return 0
endif
" call Dret("NetrwFileHandler_html 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_htm: handles html when the user hits "x" when the {{{1
" cursor is atop a *.htm file
fun! NetrwFileHandler_htm(pagefile)
" call Dfunc("NetrwFileHandler_htm(".a:pagefile.")")
let page= substitute(a:pagefile,'^','file://','')
if executable("mozilla")
" call Decho("executing !mozilla ".page)
exe "!mozilla \"".page.'"'
elseif executable("netscape")
" call Decho("executing !netscape ".page)
exe "!netscape \"".page.'"'
else
" call Dret("NetrwFileHandler_htm 0")
return 0
endif
" call Dret("NetrwFileHandler_htm 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_jpg: {{{1
fun! NetrwFileHandler_jpg(jpgfile)
" call Dfunc("NetrwFileHandler_jpg(jpgfile<".a:jpgfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".a:jpgfile
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
" call Decho("silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".escape(a:jpgfile," []|'"))
exe "!".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:jpgfile.'"'
else
" call Dret("NetrwFileHandler_jpg 0")
return 0
endif
" call Dret("NetrwFileHandler_jpg 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_gif: {{{1
fun! NetrwFileHandler_gif(giffile)
" call Dfunc("NetrwFileHandler_gif(giffile<".a:giffile.">)")
if executable("gimp")
exe "silent! !gimp -s ".a:giffile
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:giffile.'"'
else
" call Dret("NetrwFileHandler_gif 0")
return 0
endif
" call Dret("NetrwFileHandler_gif 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_png: {{{1
fun! NetrwFileHandler_png(pngfile)
" call Dfunc("NetrwFileHandler_png(pngfile<".a:pngfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".a:pngfile
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:pngfile.'"'
else
" call Dret("NetrwFileHandler_png 0")
return 0
endif
" call Dret("NetrwFileHandler_png 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_pnm: {{{1
fun! NetrwFileHandler_pnm(pnmfile)
" call Dfunc("NetrwFileHandler_pnm(pnmfile<".a:pnmfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".a:pnmfile
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:pnmfile.'"'
else
" call Dret("NetrwFileHandler_pnm 0")
return 0
endif
" call Dret("NetrwFileHandler_pnm 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_bmp: visualize bmp files {{{1
fun! NetrwFileHandler_bmp(bmpfile)
" call Dfunc("NetrwFileHandler_bmp(bmpfile<".a:bmpfile.">)")
if executable("gimp")
exe "silent! !gimp -s ".a:bmpfile
elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE")
exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT \"".a:bmpfile.'"'
else
" call Dret("NetrwFileHandler_bmp 0")
return 0
endif
" call Dret("NetrwFileHandler_bmp 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_pdf: visualize pdf files {{{1
fun! NetrwFileHandler_pdf(pdf)
" " call Dfunc("NetrwFileHandler_pdf(pdf<".a:pdf.">)")
if executable("gs")
exe 'silent! !gs "'.a:pdf.'"'
else
" " call Dret("NetrwFileHandler_pdf 0")
return 0
endif
" " call Dret("NetrwFileHandler_pdf 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_doc: visualize doc files {{{1
fun! NetrwFileHandler_doc(doc)
" " call Dfunc("NetrwFileHandler_doc(doc<".a:doc.">)")
if executable("oowriter")
exe 'silent! !oowriter "'.a:doc.'"'
redraw!
else
" " call Dret("NetrwFileHandler_doc 0")
return 0
endif
" " call Dret("NetrwFileHandler_doc 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_sxw: visualize sxw files {{{1
fun! NetrwFileHandler_sxw(sxw)
" " call Dfunc("NetrwFileHandler_sxw(sxw<".a:sxw.">)")
if executable("oowriter")
exe 'silent! !oowriter "'.a:sxw.'"'
redraw!
else
" " call Dret("NetrwFileHandler_sxw 0")
return 0
endif
" " call Dret("NetrwFileHandler_sxw 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_xls: visualize xls files {{{1
fun! NetrwFileHandler_xls(xls)
" " call Dfunc("NetrwFileHandler_xls(xls<".a:xls.">)")
if executable("oocalc")
exe 'silent! !oocalc "'.a:xls.'"'
redraw!
else
" " call Dret("NetrwFileHandler_xls 0")
return 0
endif
" " call Dret("NetrwFileHandler_xls 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_ps: handles PostScript files {{{1
fun! NetrwFileHandler_ps(ps)
" call Dfunc("NetrwFileHandler_ps()")
if executable("gs")
exe "silent! !gs ".a:ps
redraw!
elseif executable("ghostscript")
exe "silent! !ghostscript ".a:ps
redraw!
elseif executable("ghostscript")
exe "silent! !ghostscript ".a:ps
redraw!
elseif executable("gswin32")
exe "silent! !gswin32 \"".a:ps.'"'
redraw!
else
" call Dret("NetrwFileHandler_ps 0")
return 0
endif
" call Dret("NetrwFileHandler_ps 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_eps: handles encapsulated PostScript files {{{1
fun! NetrwFileHandler_eps(eps)
" call Dfunc("NetrwFileHandler_ps()")
if executable("gs")
exe "silent! !gs ".a:eps
redraw!
elseif executable("ghostscript")
exe "silent! !ghostscript ".a:eps
redraw!
elseif executable("ghostscript")
exe "silent! !ghostscript ".a:eps
redraw!
elseif executable("gswin32")
exe "silent! !gswin32 \"".a:eps.'"'
redraw!
else
" call Dret("NetrwFileHandler_ps 0")
return 0
endif
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_fig: handles xfig files {{{1
fun! NetrwFileHandler_fig(fig)
" call Dfunc("NetrwFileHandler_fig()")
if executable("xfig")
exe "silent! !xfig ".a:fig
redraw!
else
" call Dret("NetrwFileHandler_fig 0")
return 0
endif
" call Dret("NetrwFileHandler_fig 1")
return 1
endfun
" ---------------------------------------------------------------------
" NetrwFileHandler_obj: handles tgif's obj files {{{1
fun! NetrwFileHandler_obj(obj)
" call Dfunc("NetrwFileHandler_obj()")
if has("unix") && executable("tgif")
exe "silent! !tgif ".a:obj
redraw!
else
" call Dret("NetrwFileHandler_obj 0")
return 0
endif
" call Dret("NetrwFileHandler_obj 1")
return 1
endfun
let &cpo= s:keepcpo
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim: ts=4 fdm=marker
|