Mercurial > vim
annotate runtime/autoload/netrwFileHandlers.vim @ 12346:51a433bd74bf
Added tag v8.0.1052 for changeset 76ab57a791830b36345cfd05007573ef99d139db
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 03 Sep 2017 21:00:05 +0200 |
parents | 605c9ce57ec3 |
children | 75ff30a78189 |
rev | line source |
---|---|
555 | 1 " netrwFileHandlers: contains various extension-based file handlers for |
2 " netrw's browsers' x command ("eXecute launcher") | |
4339 | 3 " Author: Charles E. Campbell |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
4 " Date: May 03, 2013 |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
5 " Version: 11b ASTRO-ONLY |
4339 | 6 " Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 |
555 | 7 " Permission is hereby granted to use and distribute this code, |
8 " with or without modifications, provided that this copyright | |
9 " notice is copied with it. Like anything else that's free, | |
10 " netrwFileHandlers.vim is provided *as is* and comes with no | |
11 " warranty of any kind, either expressed or implied. In no | |
12 " event will the copyright holder be liable for any damages | |
13 " resulting from the use of this software. | |
14 " | |
15 " Rom 6:23 (WEB) For the wages of sin is death, but the free gift of God {{{1 | |
16 " is eternal life in Christ Jesus our Lord. | |
17 | |
18 " --------------------------------------------------------------------- | |
19 " Load Once: {{{1 | |
20 if exists("g:loaded_netrwFileHandlers") || &cp | |
21 finish | |
22 endif | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
23 let g:loaded_netrwFileHandlers= "v11b" |
2034 | 24 if v:version < 702 |
25 echohl WarningMsg | |
26 echo "***warning*** this version of netrwFileHandlers needs vim 7.2" | |
27 echohl Normal | |
28 finish | |
29 endif | |
555 | 30 let s:keepcpo= &cpo |
31 set cpo&vim | |
32 | |
33 " --------------------------------------------------------------------- | |
857 | 34 " netrwFileHandlers#Invoke: {{{1 |
720 | 35 fun! netrwFileHandlers#Invoke(exten,fname) |
36 " call Dfunc("netrwFileHandlers#Invoke(exten<".a:exten."> fname<".a:fname.">)") | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
37 let exten= a:exten |
1125 | 38 " list of supported special characters. Consider rcs,v --- that can be |
39 " supported with a NFH_rcsCOMMAv() handler | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
40 if exten =~ '[@:,$!=\-+%?;~]' |
1125 | 41 let specials= { |
42 \ '@' : 'AT', | |
43 \ ':' : 'COLON', | |
44 \ ',' : 'COMMA', | |
45 \ '$' : 'DOLLAR', | |
46 \ '!' : 'EXCLAMATION', | |
47 \ '=' : 'EQUAL', | |
48 \ '-' : 'MINUS', | |
49 \ '+' : 'PLUS', | |
50 \ '%' : 'PERCENT', | |
51 \ '?' : 'QUESTION', | |
52 \ ';' : 'SEMICOLON', | |
53 \ '~' : 'TILDE'} | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
54 let exten= substitute(a:exten,'[@:,$!=\-+%?;~]','\=specials[submatch(0)]','ge') |
1125 | 55 " call Decho('fname<'.fname.'> done with dictionary') |
56 endif | |
720 | 57 |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
58 if a:exten != "" && exists("*NFH_".exten) |
1125 | 59 " support user NFH_*() functions |
60 " call Decho("let ret= netrwFileHandlers#NFH_".a:exten.'("'.fname.'")') | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
61 exe "let ret= NFH_".exten.'("'.a:fname.'")' |
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
62 elseif a:exten != "" && exists("*s:NFH_".exten) |
1125 | 63 " use builtin-NFH_*() functions |
64 " call Decho("let ret= netrwFileHandlers#NFH_".a:exten.'("'.fname.'")') | |
4502
605c9ce57ec3
Updated runtime files, language files and translations.
Bram Moolenaar <bram@vim.org>
parents:
4339
diff
changeset
|
65 exe "let ret= s:NFH_".a:exten.'("'.a:fname.'")' |
720 | 66 endif |
3456 | 67 |
720 | 68 " call Dret("netrwFileHandlers#Invoke 0 : ret=".ret) |
69 return 0 | |
555 | 70 endfun |
71 | |
72 " --------------------------------------------------------------------- | |
720 | 73 " s:NFH_html: handles html when the user hits "x" when the {{{1 |
555 | 74 " cursor is atop a *.html file |
720 | 75 fun! s:NFH_html(pagefile) |
76 " call Dfunc("s:NFH_html(".a:pagefile.")") | |
555 | 77 |
78 let page= substitute(a:pagefile,'^','file://','') | |
79 | |
80 if executable("mozilla") | |
81 " call Decho("executing !mozilla ".page) | |
2034 | 82 exe "!mozilla ".shellescape(page,1) |
555 | 83 elseif executable("netscape") |
84 " call Decho("executing !netscape ".page) | |
2034 | 85 exe "!netscape ".shellescape(page,1) |
555 | 86 else |
720 | 87 " call Dret("s:NFH_html 0") |
555 | 88 return 0 |
89 endif | |
90 | |
720 | 91 " call Dret("s:NFH_html 1") |
555 | 92 return 1 |
93 endfun | |
94 | |
95 " --------------------------------------------------------------------- | |
720 | 96 " s:NFH_htm: handles html when the user hits "x" when the {{{1 |
555 | 97 " cursor is atop a *.htm file |
720 | 98 fun! s:NFH_htm(pagefile) |
99 " call Dfunc("s:NFH_htm(".a:pagefile.")") | |
555 | 100 |
101 let page= substitute(a:pagefile,'^','file://','') | |
102 | |
103 if executable("mozilla") | |
104 " call Decho("executing !mozilla ".page) | |
2034 | 105 exe "!mozilla ".shellescape(page,1) |
555 | 106 elseif executable("netscape") |
107 " call Decho("executing !netscape ".page) | |
2034 | 108 exe "!netscape ".shellescape(page,1) |
555 | 109 else |
720 | 110 " call Dret("s:NFH_htm 0") |
555 | 111 return 0 |
112 endif | |
113 | |
720 | 114 " call Dret("s:NFH_htm 1") |
555 | 115 return 1 |
116 endfun | |
117 | |
118 " --------------------------------------------------------------------- | |
720 | 119 " s:NFH_jpg: {{{1 |
120 fun! s:NFH_jpg(jpgfile) | |
121 " call Dfunc("s:NFH_jpg(jpgfile<".a:jpgfile.">)") | |
555 | 122 |
123 if executable("gimp") | |
2034 | 124 exe "silent! !gimp -s ".shellescape(a:jpgfile,1) |
555 | 125 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") |
126 " call Decho("silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".escape(a:jpgfile," []|'")) | |
2034 | 127 exe "!".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:jpgfile,1) |
555 | 128 else |
720 | 129 " call Dret("s:NFH_jpg 0") |
555 | 130 return 0 |
131 endif | |
132 | |
720 | 133 " call Dret("s:NFH_jpg 1") |
555 | 134 return 1 |
135 endfun | |
136 | |
137 " --------------------------------------------------------------------- | |
720 | 138 " s:NFH_gif: {{{1 |
139 fun! s:NFH_gif(giffile) | |
140 " call Dfunc("s:NFH_gif(giffile<".a:giffile.">)") | |
555 | 141 |
142 if executable("gimp") | |
2034 | 143 exe "silent! !gimp -s ".shellescape(a:giffile,1) |
555 | 144 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") |
2034 | 145 exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:giffile,1) |
555 | 146 else |
720 | 147 " call Dret("s:NFH_gif 0") |
555 | 148 return 0 |
149 endif | |
150 | |
720 | 151 " call Dret("s:NFH_gif 1") |
555 | 152 return 1 |
153 endfun | |
154 | |
155 " --------------------------------------------------------------------- | |
720 | 156 " s:NFH_png: {{{1 |
157 fun! s:NFH_png(pngfile) | |
158 " call Dfunc("s:NFH_png(pngfile<".a:pngfile.">)") | |
555 | 159 |
160 if executable("gimp") | |
2034 | 161 exe "silent! !gimp -s ".shellescape(a:pngfile,1) |
555 | 162 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") |
2034 | 163 exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:pngfile,1) |
555 | 164 else |
720 | 165 " call Dret("s:NFH_png 0") |
555 | 166 return 0 |
167 endif | |
168 | |
720 | 169 " call Dret("s:NFH_png 1") |
555 | 170 return 1 |
171 endfun | |
172 | |
173 " --------------------------------------------------------------------- | |
720 | 174 " s:NFH_pnm: {{{1 |
175 fun! s:NFH_pnm(pnmfile) | |
176 " call Dfunc("s:NFH_pnm(pnmfile<".a:pnmfile.">)") | |
555 | 177 |
178 if executable("gimp") | |
2034 | 179 exe "silent! !gimp -s ".shellescape(a:pnmfile,1) |
555 | 180 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") |
2034 | 181 exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:pnmfile,1) |
555 | 182 else |
720 | 183 " call Dret("s:NFH_pnm 0") |
555 | 184 return 0 |
185 endif | |
186 | |
720 | 187 " call Dret("s:NFH_pnm 1") |
555 | 188 return 1 |
189 endfun | |
190 | |
191 " --------------------------------------------------------------------- | |
720 | 192 " s:NFH_bmp: visualize bmp files {{{1 |
193 fun! s:NFH_bmp(bmpfile) | |
194 " call Dfunc("s:NFH_bmp(bmpfile<".a:bmpfile.">)") | |
555 | 195 |
196 if executable("gimp") | |
197 exe "silent! !gimp -s ".a:bmpfile | |
198 elseif executable(expand("$SystemRoot")."/SYSTEM32/MSPAINT.EXE") | |
2034 | 199 exe "silent! !".expand("$SystemRoot")."/SYSTEM32/MSPAINT ".shellescape(a:bmpfile,1) |
555 | 200 else |
720 | 201 " call Dret("s:NFH_bmp 0") |
555 | 202 return 0 |
203 endif | |
204 | |
720 | 205 " call Dret("s:NFH_bmp 1") |
555 | 206 return 1 |
207 endfun | |
208 | |
209 " --------------------------------------------------------------------- | |
720 | 210 " s:NFH_pdf: visualize pdf files {{{1 |
211 fun! s:NFH_pdf(pdf) | |
212 " call Dfunc("s:NFH_pdf(pdf<".a:pdf.">)") | |
555 | 213 if executable("gs") |
2034 | 214 exe 'silent! !gs '.shellescape(a:pdf,1) |
1125 | 215 elseif executable("pdftotext") |
2034 | 216 exe 'silent! pdftotext -nopgbrk '.shellescape(a:pdf,1) |
555 | 217 else |
720 | 218 " call Dret("s:NFH_pdf 0") |
555 | 219 return 0 |
220 endif | |
221 | |
720 | 222 " call Dret("s:NFH_pdf 1") |
555 | 223 return 1 |
224 endfun | |
225 | |
226 " --------------------------------------------------------------------- | |
720 | 227 " s:NFH_doc: visualize doc files {{{1 |
228 fun! s:NFH_doc(doc) | |
229 " call Dfunc("s:NFH_doc(doc<".a:doc.">)") | |
555 | 230 |
231 if executable("oowriter") | |
2034 | 232 exe 'silent! !oowriter '.shellescape(a:doc,1) |
555 | 233 redraw! |
234 else | |
720 | 235 " call Dret("s:NFH_doc 0") |
555 | 236 return 0 |
237 endif | |
238 | |
720 | 239 " call Dret("s:NFH_doc 1") |
555 | 240 return 1 |
241 endfun | |
242 | |
243 " --------------------------------------------------------------------- | |
720 | 244 " s:NFH_sxw: visualize sxw files {{{1 |
245 fun! s:NFH_sxw(sxw) | |
246 " call Dfunc("s:NFH_sxw(sxw<".a:sxw.">)") | |
555 | 247 |
248 if executable("oowriter") | |
2034 | 249 exe 'silent! !oowriter '.shellescape(a:sxw,1) |
555 | 250 redraw! |
251 else | |
720 | 252 " call Dret("s:NFH_sxw 0") |
555 | 253 return 0 |
254 endif | |
255 | |
720 | 256 " call Dret("s:NFH_sxw 1") |
555 | 257 return 1 |
258 endfun | |
259 | |
260 " --------------------------------------------------------------------- | |
720 | 261 " s:NFH_xls: visualize xls files {{{1 |
262 fun! s:NFH_xls(xls) | |
263 " call Dfunc("s:NFH_xls(xls<".a:xls.">)") | |
555 | 264 |
265 if executable("oocalc") | |
2034 | 266 exe 'silent! !oocalc '.shellescape(a:xls,1) |
555 | 267 redraw! |
268 else | |
720 | 269 " call Dret("s:NFH_xls 0") |
555 | 270 return 0 |
271 endif | |
272 | |
720 | 273 " call Dret("s:NFH_xls 1") |
555 | 274 return 1 |
275 endfun | |
276 | |
277 " --------------------------------------------------------------------- | |
720 | 278 " s:NFH_ps: handles PostScript files {{{1 |
279 fun! s:NFH_ps(ps) | |
280 " call Dfunc("s:NFH_ps(ps<".a:ps.">)") | |
555 | 281 if executable("gs") |
720 | 282 " call Decho("exe silent! !gs ".a:ps) |
2034 | 283 exe "silent! !gs ".shellescape(a:ps,1) |
555 | 284 redraw! |
285 elseif executable("ghostscript") | |
720 | 286 " call Decho("exe silent! !ghostscript ".a:ps) |
2034 | 287 exe "silent! !ghostscript ".shellescape(a:ps,1) |
555 | 288 redraw! |
289 elseif executable("gswin32") | |
2034 | 290 " call Decho("exe silent! !gswin32 ".shellescape(a:ps,1)) |
291 exe "silent! !gswin32 ".shellescape(a:ps,1) | |
555 | 292 redraw! |
293 else | |
720 | 294 " call Dret("s:NFH_ps 0") |
555 | 295 return 0 |
296 endif | |
297 | |
720 | 298 " call Dret("s:NFH_ps 1") |
555 | 299 return 1 |
300 endfun | |
301 | |
302 " --------------------------------------------------------------------- | |
720 | 303 " s:NFH_eps: handles encapsulated PostScript files {{{1 |
304 fun! s:NFH_eps(eps) | |
305 " call Dfunc("s:NFH_eps()") | |
555 | 306 if executable("gs") |
2034 | 307 exe "silent! !gs ".shellescape(a:eps,1) |
555 | 308 redraw! |
309 elseif executable("ghostscript") | |
2034 | 310 exe "silent! !ghostscript ".shellescape(a:eps,1) |
555 | 311 redraw! |
312 elseif executable("ghostscript") | |
2034 | 313 exe "silent! !ghostscript ".shellescape(a:eps,1) |
555 | 314 redraw! |
315 elseif executable("gswin32") | |
2034 | 316 exe "silent! !gswin32 ".shellescape(a:eps,1) |
555 | 317 redraw! |
318 else | |
720 | 319 " call Dret("s:NFH_eps 0") |
555 | 320 return 0 |
321 endif | |
720 | 322 " call Dret("s:NFH_eps 0") |
323 return 1 | |
555 | 324 endfun |
325 | |
326 " --------------------------------------------------------------------- | |
720 | 327 " s:NFH_fig: handles xfig files {{{1 |
328 fun! s:NFH_fig(fig) | |
329 " call Dfunc("s:NFH_fig()") | |
555 | 330 if executable("xfig") |
331 exe "silent! !xfig ".a:fig | |
332 redraw! | |
333 else | |
720 | 334 " call Dret("s:NFH_fig 0") |
555 | 335 return 0 |
336 endif | |
337 | |
720 | 338 " call Dret("s:NFH_fig 1") |
555 | 339 return 1 |
340 endfun | |
341 | |
342 " --------------------------------------------------------------------- | |
720 | 343 " s:NFH_obj: handles tgif's obj files {{{1 |
344 fun! s:NFH_obj(obj) | |
345 " call Dfunc("s:NFH_obj()") | |
555 | 346 if has("unix") && executable("tgif") |
347 exe "silent! !tgif ".a:obj | |
348 redraw! | |
349 else | |
720 | 350 " call Dret("s:NFH_obj 0") |
555 | 351 return 0 |
352 endif | |
353 | |
720 | 354 " call Dret("s:NFH_obj 1") |
555 | 355 return 1 |
356 endfun | |
357 | |
358 let &cpo= s:keepcpo | |
3456 | 359 unlet s:keepcpo |
555 | 360 " --------------------------------------------------------------------- |
361 " Modelines: {{{1 | |
1125 | 362 " vim: fdm=marker |