" Vimball Archiver by Charles E. Campbell, Jr., Ph.D.
UseVimball
finish
MangleImageTag.vim [[[1
296
" MangleImageTag() - updates an 's width and height tags.
"
" Requirements:
" VIM 7 or later
"
" Copyright (C) 2004-2008 Christian J. Robinson
"
" Based on "mangleImageTag" by Devin Weaver
"
" This program is free software; you can redistribute it and/or modify it
" under the terms of the GNU General Public License as published by the Free
" Software Foundation; either version 2 of the License, or (at your option)
" any later version.
"
" This program is distributed in the hope that it will be useful, but WITHOUT
" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
" more details.
"
" You should have received a copy of the GNU General Public License along with
" this program; if not, write to the Free Software Foundation, Inc., 59 Temple
" Place - Suite 330, Boston, MA 02111-1307, USA.
"
" RCS info: -------------------------------------------------------------- {{{
" $Id: MangleImageTag.vim,v 1.12 2008/05/30 00:53:28 infynity Exp $
" $Log: MangleImageTag.vim,v $
" Revision 1.12 2008/05/30 00:53:28 infynity
" - Clarify an error message
" - Don't move the cursor when updating the tag
"
" Revision 1.11 2008/05/26 01:11:25 infynity
" *** empty log message ***
"
" Revision 1.10 2008/05/01 05:01:02 infynity
" Code changed for Vim 7:
" - Computed sizes should always be correct now
" - Code is a bit cleaner, but unfortunately slower
"
" Revision 1.9 2007/05/04 02:03:42 infynity
" Computed sizes were very wrong when 'encoding' was set to UTF8 or similar
"
" Revision 1.8 2007/05/04 01:32:27 infynity
" Missing quotes
"
" Revision 1.7 2007/01/04 04:29:55 infynity
" Enclose the values of the width/height in quotes by default
"
" Revision 1.6 2006/09/22 06:25:14 infynity
" Search for the image file in the current directory and the buffer's directory.
"
" Revision 1.5 2006/06/09 07:56:08 infynity
" Was resetting 'autoindent' globally, switch it to locally.
"
" Revision 1.4 2006/06/08 04:16:17 infynity
" Temporarily reset 'autoindent' (required for Vim7)
"
" Revision 1.3 2005/05/19 18:31:31 infynity
" SizeGif was returning width as height and vice-versa.
"
" Revision 1.2 2004/03/22 10:04:24 infynity
" Update the right tag if more than one IMG tag appears on the line.
"
" Revision 1.1 2004/03/22 05:58:34 infynity
" Initial revision
" ------------------------------------------------------------------------ }}}
if v:version < 700 || exists("*MangleImageTag")
finish
endif
function! MangleImageTag() "{{{1
let start_linenr = line('.')
let end_linenr = start_linenr
let col = col('.') - 1
let line = getline(start_linenr)
if line !~? ']*$'
let end_linenr = end_linenr + 1
let line = line . "\n" . getline(end_linenr)
endwhile
" Make sure we modify the right tag if more than one is on the line:
if line[col] != '<'
let tmp = strpart(line, 0, col)
let tagstart = strridx(tmp, '<')
else
let tagstart = col
endif
let savestart = strpart(line, 0, tagstart)
let tag = strpart(line, tagstart)
let tagend = stridx(tag, '>') + 1
let saveend = strpart(tag, tagend)
let tag = strpart(tag, 0, tagend)
if tag[0] != '<' || col > strlen(savestart . tag) - 1
echohl ErrorMsg
echomsg "Cursor isn't on an IMG tag."
echohl None
return
endif
if tag =~? "src=\\(\".\\{-}\"\\|'.\\{-}\'\\)"
let src = substitute(tag, ".\\{-}src=\\([\"']\\)\\(.\\{-}\\)\\1.*", '\2', '')
if tag =~# 'src'
let case = 0
else
let case = 1
endif
else
echohl ErrorMsg
echomsg "Image src not specified in the tag."
echohl None
return
endif
if ! filereadable(src)
if filereadable(expand("%:p:h") . '/' . src)
let src = expand("%:p:h") . '/' . src
else
echohl ErrorMsg
echomsg "Can't find image file: " . src
echohl None
return
endif
endif
let size = s:ImageSize(src)
if len(size) != 2
return
endif
if tag =~? "height=\\(\"\\d\\+\"\\|'\\d\\+\'\\|\\d\\+\\)"
let tag = substitute(tag,
\ "\\c\\(height=\\)\\([\"']\\=\\)\\(\\d\\+\\)\\(\\2\\)",
\ '\1\2' . size[1] . '\4', '')
else
let tag = substitute(tag,
\ "\\csrc=\\([\"']\\)\\(.\\{-}\\|.\\{-}\\)\\1",
\ '\0 ' . (case ? 'HEIGHT' : 'height') . '="' . size[1] . '"', '')
endif
if tag =~? "width=\\(\"\\d\\+\"\\|'\\d\\+\'\\|\\d\\+\\)"
let tag = substitute(tag,
\ "\\c\\(width=\\)\\([\"']\\=\\)\\(\\d\\+\\)\\(\\2\\)",
\ '\1\2' . size[0] . '\4', '')
else
let tag = substitute(tag,
\ "\\csrc=\\([\"']\\)\\(.\\{-}\\|.\\{-}\\)\\1",
\ '\0 ' . (case ? 'WIDTH' : 'width') . '="' . size[0] . '"', '')
endif
let line = savestart . tag . saveend
let saveautoindent=&autoindent
let &l:autoindent=0
call setline(start_linenr, split(line, "\n"))
let &l:autoindent=saveautoindent
endfunction
function! s:ImageSize(image) "{{{1
let ext = fnamemodify(a:image, ':e')
if ext !~? 'png\|gif\|jpe\?g'
echohl ErrorMsg
echomsg "Image type not recognized: " . tolower(ext)
echohl None
return
endif
if filereadable(a:image)
let ldsave=&lazyredraw
set lazyredraw
let buf=readfile(a:image, 'b', 1024)
let buf2=[]
let i=0
for l in buf
let string = split(l, '\zs')
for c in string
let char = char2nr(c)
call add(buf2, (char == 10 ? '0' : char))
" Keep the script from being too slow, but could cause a JPG
" (and GIF/PNG?) to return as "malformed":
let i+=1
if i > 1024 * 4
break
endif
endfor
call add(buf2, '10')
endfor
if ext ==? 'png'
let size = s:SizePng(buf2)
elseif ext ==? 'gif'
let size = s:SizeGif(buf2)
elseif ext ==? 'jpg' || ext ==? 'jpeg'
let size = s:SizeJpg(buf2)
endif
else
echohl ErrorMsg
echomsg "Can't read file: " . a:image
echohl None
return
endif
return size
endfunction
function! s:SizeGif(lines) "{{{1
let i=0
let len=len(a:lines)
while i <= len
if join(a:lines[i : i+9], ' ') =~ '^71 73 70\( \d\+\)\{7}'
let width=s:Vec(reverse(a:lines[i+6 : i+7]))
let height=s:Vec(reverse(a:lines[i+8 : i+9]))
return [width, height]
endif
let i+=1
endwhile
echohl ErrorMsg
echomsg "Malformed GIF file."
echohl None
return
endfunction
function! s:SizeJpg(lines) "{{{1
let i=0
let len=len(a:lines)
while i <= len
if join(a:lines[i : i+8], ' ') =~ '^255 192\( \d\+\)\{7}'
let height = s:Vec(a:lines[i+5 : i+6])
let width = s:Vec(a:lines[i+7 : i+8])
return [width, height]
endif
let i+=1
endwhile
echohl ErrorMsg
echomsg "Malformed JPEG file."
echohl None
return
endfunction
function! s:SizePng(lines) "{{{1
let i=0
let len=len(a:lines)
while i <= len
if join(a:lines[i : i+11], ' ') =~ '^73 72 68 82\( \d\+\)\{8}'
let width = s:Vec(a:lines[i+4 : i+7])
let height = s:Vec(a:lines[i+8 : i+11])
return [width, height]
endif
let i+=1
endwhile
echohl ErrorMsg
echomsg "Malformed PNG file."
echohl None
return
endfunction
function! s:Vec(nums) "{{{1
let n = 0
for i in a:nums
let n = n * 256 + i
endfor
return n
endfunction
" vim:ts=4:sw=4:
" vim600:fdm=marker:fdc=2:cms=\ \"%s:
bitmaps/Blist.xpm [[[1
29
/* XPM */
static char *Blist[] = {
/* width height num_colors chars_per_pixel */
" 20 20 3 1",
/* colors */
". c #000000",
"# c None",
"a c #ffffff",
/* pixels */
"####################",
"####################",
"####################",
"####.###############",
"###.a.##.........###",
"####.###############",
"####################",
"####################",
"####################",
"####.###############",
"###.a.##.........###",
"####.###############",
"####################",
"####################",
"####################",
"####.###############",
"###.a.##.........###",
"####.###############",
"####################",
"####################"};
bitmaps/Bold.xpm [[[1
28
/* XPM */
static char *Bold[] = {
/* width height num_colors chars_per_pixel */
" 20 20 2 1",
/* colors */
". c #333366",
"# c None",
/* pixels */
"####################",
"####################",
"####################",
"#########..#########",
"#########..#########",
"########....########",
"########....########",
"#######......#######",
"#######......#######",
"######..##....######",
"######..##....######",
"#####..####....#####",
"#####..####....#####",
"####............####",
"####..######....####",
"###..########....###",
"##...########....###",
"#.....#####........#",
"####################",
"####################"};
bitmaps/Break.xpm [[[1
25
/* XPM */
static char * Break_xpm[] = {
"20 20 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" ",
" ",
" .. ",
" .. ",
" .. ",
" . .. ",
" .. .. ",
" .............. ",
" ............... ",
" .............. ",
" .. ",
" . ",
" ",
" ",
" ",
" ",
" "};
bitmaps/Browser.xpm [[[1
28
/* XPM */
static char * Browser_xpm[] = {
"20 20 5 1",
" c None",
". c #FFFFFF",
"+ c #CCFFFF",
"@ c #009933",
"# c #000000",
" ###### ",
" ##@@@@@@## ",
" ##.@...@...@## ",
" #@@..@@@@@@@.@@# ",
" #.@.@@..@@@@@.@# ",
" #@.@@.@.@.@.@.@.@# ",
" #@@@..@@.@..@..@.# ",
"#@..@.@..@@..@..@@@#",
"#@..@@...@@.@.@.@@.#",
"#@..@@..@..@@@@@.@.#",
"#@.@@.@@...@..@..@.#",
"#@@@...@...@..@..@.#",
"#@@....@@@@@..@..@@#",
" #@@..@...@@@@@@@@# ",
" #..@@@...@...@..@# ",
" #..@@...@...@..# ",
" #..@.@@@@...@@@# ",
" ##@...@@@@@@## ",
" ##..@...## ",
" ###### "};
bitmaps/Firefox.xpm [[[1
74
/* XPM */
static char * Firefox_xpm[] = {
"20 20 51 1",
" c None",
". c #111C42",
"+ c #621F36",
"@ c #3A76A2",
"# c #4E6E7E",
"$ c #F8DD11",
"% c #657B81",
"& c #274161",
"* c #F4B41B",
"= c #6A163E",
"- c #6A321E",
"; c #8E8B63",
"> c #1E69A5",
", c #ACA270",
"' c #BA300F",
") c #9E7E38",
"! c #8E553A",
"~ c #9A9242",
"{ c #C4450F",
"] c #2D8FCD",
"^ c #DD7319",
"/ c #4E5E75",
"( c #9A5222",
"_ c #AE8E5A",
": c #F9D744",
"< c #860E2A",
"[ c #D1A737",
"} c #A26A46",
"| c #E8961C",
"1 c #367AB2",
"2 c #419CD0",
"3 c #CB5317",
"4 c #1D518A",
"5 c #AE8222",
"6 c #2779B4",
"7 c #9B0F1B",
"8 c #EECA6E",
"9 c #FCF258",
"0 c #F0A61F",
"a c #10366C",
"b c #E4891C",
"c c #37A0DC",
"d c #6E5E48",
"e c #E1984B",
"f c #D6641A",
"g c #DF7F1F",
"h c #F7DE72",
"i c #5E3837",
"j c #B6160D",
"k c #F8C51E",
"l c #1D6099",
" ",
" >66]>># ",
" 44>6]c]l4%[k ",
" gd.&}_1cc@>d[k* ",
" 3^e[_g/1]6]2l&5k*h ",
" ge0|gfd%2ccc2>450: ",
" e|bbg^fg%ccc]2];0: ",
"0bbbg^ge/6]66>]6~:$ ",
"ebbb^^b[4]]>ll6>~h:*",
"|bb^3ji&46]6l44#[$:*",
"fg^^''!4>61144a;*$k8",
"'^^^'{f5}^b,4aa;kkh ",
" 3^^ff3{{(-...d[k:h ",
" '^^^^f3+....i^kk98 ",
" 7{^^^^^f(ii!^^|99 ",
" j'fff^^^g^gf^$$[ ",
" jj''{ffff^g*$[ ",
" jjjjjj{{fg|g ",
" <7jjj''{} ",
" === "};
bitmaps/Hline.xpm [[[1
30
/* XPM */
static char *Hline[] = {
/* width height num_colors chars_per_pixel */
" 20 20 4 1",
/* colors */
". c #333366",
"# c #6666cc",
"a c None",
"b c #ffffff",
/* pixels */
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"a.................#a",
"a##################a",
"abbbbbbbbbbbbbbbbb#a",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa"};
bitmaps/IE.xpm [[[1
95
/* XPM */
static char * IE_xpm[] = {
"20 20 72 1",
" c None",
". c #000000",
"+ c #808000",
"@ c #000080",
"# c #008080",
"$ c #C0C0C0",
"% c #C0DCC0",
"& c #161616",
"* c #222222",
"= c #292929",
"- c #555555",
"; c #4D4D4D",
"> c #393939",
", c #EFD6C6",
"' c #E7E7D6",
") c #ADA990",
"! c #000033",
"~ c #333333",
"{ c #666633",
"] c #999933",
"^ c #000066",
"/ c #003366",
"( c #333366",
"_ c #336666",
": c #666666",
"< c #999966",
"[ c #CC9966",
"} c #99CC66",
"| c #CCCC66",
"1 c #FFCC66",
"2 c #000099",
"3 c #333399",
"4 c #006699",
"5 c #336699",
"6 c #669999",
"7 c #CC9999",
"8 c #99CC99",
"9 c #CCCC99",
"0 c #FFCC99",
"a c #FFFF99",
"b c #003399",
"c c #3333CC",
"d c #0066CC",
"e c #3366CC",
"f c #666699",
"g c #0099CC",
"h c #3399CC",
"i c #6699CC",
"j c #99CCCC",
"k c #FFFFCC",
"l c #0033CC",
"m c #0066FF",
"n c #3366FF",
"o c #6666CC",
"p c #0099FF",
"q c #3399FF",
"r c #00CCFF",
"s c #33CCFF",
"t c #66CCFF",
"u c #33FFFF",
"v c #99FFFF",
"w c #CCFFFF",
"x c #66FFFF",
"y c #5F5F5F",
"z c #777777",
"A c #969696",
"B c #B2B2B2",
"C c #A0A0A4",
"D c #808080",
"E c #FFFF00",
"F c #0000FF",
"G c #FFFFFF",
" ",
" ",
" FFFF ",
" FFFFFF F ",
" @FFFFFFF@ F ",
" @FFEFFFFFF@ ",
" @@+EFF@@FFFF@ ",
" @+EFFF .FFF@ ",
" @+EFFF .FFF@ ",
" +EFFFFFFFFFFFF@ ",
" +E+FFFF@@@@@@@@@ ",
" + F@FFF ",
" ++F@FFF .FFF@ ",
" +FF@@FFFDD.FFFF@ ",
" +F .@@FFFFFFFF@ ",
" +F ..@@FFFF@@ ",
" FF F...... ",
" FFF ",
" ",
" "};
bitmaps/Image.xpm [[[1
35
/* XPM */
static char *Image[] = {
/* width height num_colors chars_per_pixel */
" 20 20 9 1",
/* colors */
". c #00373c",
"# c #008000",
"a c #333366",
"b c #808000",
"c c #808080",
"d c None",
"e c #ff6633",
"f c #ff66cc",
"g c #ffffff",
/* pixels */
"dddddddddddddddddddd",
"dddddddddddddddddddd",
"dddddddddddddddddddd",
"ddaaaaaaaaaaaaaaaadd",
"ddaggggggggggggggadd",
"ddagggggg##ggggggadd",
"ddaggggg###.gggggadd",
"ddaggggg.#.#gggggadd",
"ddagggggg.#gggfggadd",
"ddaggggggggggfcggadd",
"ddaggebebgggfcfggadd",
"ddaggbebeggfcfcggadd",
"ddaggebebgggfcfggadd",
"ddaggbebeggggfcggadd",
"ddagggggggggggfggadd",
"ddaggggggggggggggadd",
"ddaaaaaaaaaaaaaaaadd",
"dddddddddddddddddddd",
"dddddddddddddddddddd",
"dddddddddddddddddddd"};
bitmaps/Italic.xpm [[[1
28
/* XPM */
static char *Italic[] = {
/* width height num_colors chars_per_pixel */
" 20 20 2 1",
/* colors */
". c #333366",
"# c None",
/* pixels */
"####################",
"####################",
"####################",
"##############.#####",
"#############..#####",
"#############..#####",
"############...#####",
"###########.#..#####",
"##########.##..#####",
"##########.##..#####",
"#########.###..#####",
"########.####..#####",
"########.......#####",
"#######.#####..#####",
"######.######..#####",
"#####.#######..#####",
"###.....###......###",
"####################",
"####################",
"####################"};
bitmaps/Link.xpm [[[1
30
/* XPM */
static char *Link[] = {
/* width height num_colors chars_per_pixel */
"20 20 4 1",
/* colors */
"a c None",
". c #333366",
"# c #6666cc",
"b c #ffffff",
/* pixels */
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaa..aaaa",
"aaaaaaaaaaaaa.ab.aaa",
"aaaaaaaaa....ab#.aaa",
"aaaaaaaa.ab.ab#.aaaa",
"aaaaaaa.ab.ab#.aaaaa",
"aaaaaa.ab..##..aaaaa",
"aaaaa.ab.aa..a.aaaaa",
"aaaa.ab.aab.ab.aaaaa",
"aaaa.b..ab.ab.aaaaaa",
"aaaa..aa..ab.aaaaaaa",
"aaaa.ab#.ab.aaaaaaaa",
"aaa.ab#.ab.aaaaaaaaa",
"aaa.b#....aaaaaaaaaa",
"aaa...aaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa"};
bitmaps/Litem.xpm [[[1
25
/* XPM */
static char * ListItem_xpm[] = {
"20 20 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" . ",
" ... ",
" ..... ......... ",
" ... ......... ",
" . ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "};
bitmaps/Lynx.xpm [[[1
46
/* XPM */
static char * Lynx_xpm[] = {
"22 19 24 1",
" c None",
". c #000000",
"+ c #ADADAD",
"@ c #D6D6D6",
"# c #EAEAEA",
"$ c #999999",
"% c #FFFFFF",
"& c #666666",
"* c #707070",
"= c #C1C1C1",
"- c #CCCCCC",
"; c #A3A3A3",
"> c #515151",
", c #7A7A7A",
"' c #5B5B5B",
") c #E0E0E0",
"! c #F4F4F4",
"~ c #B7B7B7",
"{ c #3D3D3D",
"] c #333333",
"^ c #848484",
"/ c #141414",
"( c #282828",
"_ c #8E8E8E",
" . ",
" + ",
" .+. ",
" .. .@. ",
" .#. .$@. ",
" .%&.. *$*.&=%- ",
" .-;>,....%'$>)#. ",
" .-!,~-{~%%%#;)#. ",
" .#]%#+%%%%%%%). ",
" .%#@=%%=$@%%%~. ",
" .%#'=%%%#&;!),.& ",
" .+#^#%%%*/,({{., ..",
" .#{,@%@=%#*=%%.. ",
".. *.@)!%@#%%#%%%%. ..",
" ..'$%@*+%@#+^$_. * ",
".. .^=%%@$$*%#$+. ",
" ({.!##%%%... ",
" _..%%.. ",
" .. "};
bitmaps/Mozilla.xpm [[[1
26
/* XPM */
static char * Mozilla_xpm[] = {
"20 20 3 1",
" c None",
". c #000000",
"+ c #FF0000",
" ",
" ",
" .... ... ",
" ..++++..... ",
" ..++..+..+.. ",
" ...++.+.++.... ",
" ....+++..++++++.. ",
" ..++++++++.+++++..",
"....++.++++...++++..",
" ..++..+++.....+++.",
" ...+++.++++++......",
" ...+++...+..+++.. ",
" ...+++++... ... ",
" ..+++++.. ",
" ..++++.. ",
" ..+++.. ",
" .... ",
" ",
" ",
" "};
bitmaps/Netscape.xpm [[[1
35
/* XPM */
static char *netscape[] = {
/* width height num_colors chars_per_pixel */
" 20 20 9 1",
/* colors */
". c #ffff00",
"# c #c0c0c0",
"a c #c00000",
"b c #a0a0a4",
"c c #808080",
"d c #800000",
"e c None",
"f c #0000c0",
"g c #000000",
/* pixels */
"eeeeeeeeeeeeeeeeeeee",
"eeeeeeeeeeeeeeeeeeee",
"eefffffffgfffffffgee",
"eeffggfff#fffggfgeee",
"eeff#dggg#gggd#geeee",
"eefff#b..#..b#geeeee",
"eefff#.ag#ga#geeeeee",
"eeffb#a#g#g#a#ceeeee",
"eeff#dgf###gedceeeee",
"ee##...##.#####ccgee",
"eegg#gda###adg#gggee",
"eeff.gf#g#gceg.eeeee",
"eeffd##gg#gec#deeeee",
"eefff.bgd#dgbceeeeee",
"eeff#ba.###.abceeeee",
"eef#bgegc#cgegbceeee",
"eefgceeed#deeeggeeee",
"eegeeeeeegeeeeeeeeee",
"eeeeeeeeeeeeeeeeeeee",
"eeeeeeeeeeeeeeeeeeee"};
bitmaps/Nlist.xpm [[[1
28
/* XPM */
static char *Nlist[] = {
/* width height num_colors chars_per_pixel */
" 20 20 2 1",
/* colors */
". c #000000",
"# c None",
/* pixels */
"####################",
"####################",
"###.################",
"##..################",
"###.#####.........##",
"##...#.#############",
"####################",
"####################",
"##..################",
"####.###############",
"###.#####.........##",
"##...#.#############",
"####################",
"####################",
"##...###############",
"###.################",
"####.####.........##",
"##..##.#############",
"####################",
"####################"};
bitmaps/Opera.xpm [[[1
28
/* XPM */
static char * Opera_xpm[] = {
"20 20 5 1",
" c None",
". c #000000",
"+ c #FF0000",
"@ c #7F7F7F",
"# c #999999",
" ",
" ",
" ",
" .... ",
" .++++. ",
" .+. .+. ",
" .++. .++. ",
" .+. .+. ",
" @#@@@@.++. .++.",
" @@@ @.++.# .++.",
"@@@@ .++.#@ .++.",
"@@@@@ .++.@@@#.++.",
" #@@@@ .++.#@@#.++.",
" @#@@@@ .++.@@@@.++.",
" @@@@@@ .+. #@.+. ",
" #@#@@@.++. #.++. ",
" @@@@@.+. .+. ",
" @@#@.++++. ",
" @@.... ",
" "};
bitmaps/Paragraph.xpm [[[1
25
/* XPM */
static char * Paragraph_xpm[] = {
"20 20 2 1",
" c None",
". c #000000",
" ",
" ",
" ",
" ....... ",
" ... . ",
" .... . ",
" .... . ",
" .... . ",
" ... . ",
" .. . ",
" . . ",
" . . ",
" . . ",
" . . ",
" . . ",
" . . ",
" . . ",
" ",
" ",
" "};
bitmaps/Preview.xpm [[[1
28
/* XPM */
static char * Preview_xpm[] = {
"24 20 5 1",
" c None",
". c #000000",
"+ c #7B7B7B",
"@ c #BDBDBD",
"# c #FFFFFF",
" ",
" ",
" ....... ",
" ........... ",
" ............. ",
" .........+++... ",
" ......###..@@+... ",
" .......###...@@++.. ",
" ...........#...#@@+.. ",
"............#...@#@@+.. ",
"............#...#@#@+...",
"....#.......#...@#@@+.. ",
" ...#......#....#@@+.. ",
" ...#....#....@@@+.. ",
" ...####....@@@+.. ",
" .........@@++.. ",
" .......+++... ",
" .......... ",
" ",
" "};
bitmaps/Table.xpm [[[1
31
/* XPM */
static char *Table[] = {
/* width height num_colors chars_per_pixel */
" 20 20 5 1",
/* colors */
"- c None",
". c #333366",
"# c #9999ff",
"a c #c0c0c0",
"b c #ffffff",
/* pixels */
"--------------------",
"--------------------",
"--------------------",
"--bbbbbbbbbbbbbbb.--",
"--baaaaaaaaaaaaaa.--",
"--ba...a...a...aa.--",
"--ba.#ba.#ba.#baa.--",
"--ba.#ba.#ba.#baa.--",
"--ba.#ba.#ba.#baa.--",
"--babbbabbbabbbaa.--",
"--baaaaaaaaaaaaaa.--",
"--ba...a...a...aa.--",
"--ba.#ba.#ba.#baa.--",
"--ba.#ba.#ba.#baa.--",
"--ba.#ba.#ba.#baa.--",
"--babbbabbbabbbaa.--",
"--baaaaaaaaaaaaaa.--",
"--................--",
"--------------------",
"--------------------"};
bitmaps/Target.xpm [[[1
29
/* XPM */
static char *Target[] = {
/* width height num_colors chars_per_pixel */
" 20 20 3 1",
/* colors */
". c #000080",
"a c None",
"b c #ff0000",
/* pixels */
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaabaaaa...aaaaaaa",
"aaaabbbaba....aaaaaa",
"aaaaabbbbaaa...aaaaa",
"aaaaaabbba.aa...aaaa",
"aaaaabbbbaa.aa..aaaa",
"aaaaaaaaa..a.a..aaaa",
"aaaa..a.a..a.a..aaaa",
"aaaa..aa.aa.aa..aaaa",
"aaaa...aa..aa...aaaa",
"aaaaa...aaaa...aaaaa",
"aaaaaa........aaaaaa",
"aaaaaaa......aaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa"};
bitmaps/Template.xpm [[[1
34
/* XPM */
static char *Template[] = {
/* width height num_colors chars_per_pixel */
" 20 20 8 1",
/* colors */
". c #6666cc",
"# c #808080",
"a c #9999ff",
"b c None",
"c c #ff0000",
"d c #ff6633",
"e c #ffff00",
"f c #ffffff",
/* pixels */
"bbbbbbbbbbbbbbbbbbbb",
"bbbbbbbbbbbbbbbbbbbb",
"bbebbfbfbbebbbbbbbbb",
"bbbebebebebbbbbbbbbb",
"bbbbeedeef......bbbb",
"befeeeceeeefaf.f.bbb",
"bbeddcecd#bafa.ff.bb",
"beffeeceeeefaf....bb",
"bbbbeedeebfafafaf.bb",
"bbbebe.eaeafafafa.bb",
"bbfbbf.afafafafaf.bb",
"bbbbbe.eafafafafa.bb",
"bbbbbb.afafafafaf.bb",
"bbbbbb.fafafafafa.bb",
"bbbbbb.afafafafaf.bb",
"bbbbbb.fafafafafa.bb",
"bbbbbb.afafafafaf.bb",
"bbbbbb............bb",
"bbbbbbbbbbbbbbbbbbbb",
"bbbbbbbbbbbbbbbbbbbb"};
bitmaps/Underline.xpm [[[1
29
/* XPM */
static char *Underline[] = {
/* width height num_colors chars_per_pixel */
" 20 20 3 1",
/* colors */
". c #222222",
"# c #333366",
"a c None",
/* pixels */
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaa#aaaaaaaaa",
"aaaaaaaaa###aaaaaaaa",
"aaaaaaaaa###aaaaaaaa",
"aaaaaaaa#####aaaaaaa",
"aaaaaaaa#a###aaaaaaa",
"aaaaaaa##aa###aaaaaa",
"aaaaaaa#aaa###aaaaaa",
"aaaaaa##aaaa###aaaaa",
"aaaaaa#aaaaa###aaaaa",
"aaaaa###########aaaa",
"aaaaa#aaaaaaa###aaaa",
"aaaa##aaaaaaaa###aaa",
"aaa###aaaaaaaa####aa",
"aa#####aaaaa#######a",
"aaaaaaaaaaaaaaaaaaaa",
"aa.................a",
"aaaaaaaaaaaaaaaaaaaa",
"aaaaaaaaaaaaaaaaaaaa"};
bitmaps/w3m.xpm [[[1
33
/* XPM */
static char * W3m_xpm[] = {
"20 20 10 1",
" c None",
". c #FF0000",
"+ c #00FF00",
"@ c #679900",
"# c #FB0400",
"$ c #0300FC",
"% c #0600F9",
"& c #0000FF",
"* c #009F60",
"= c #0005FA",
" . ",
" .. ",
" ... .. ",
" .. .... ",
" ....... ",
" ++++ ....... .. ",
" ++++++@#.. ...... ",
" ++++ . ..... ",
" ++++++ .... ",
" ++++ .. ",
" +++++ $% ",
" ++++++ &&&& ",
" ++++ & &&&&& ",
" ++++++*=&& &&&&&& ",
" ++++ &&&&&& &&& ",
" &&&&&&& ",
" && &&&& ",
" && && ",
" && ",
" & "};
browser_launcher.vim [[[1
346
"--------------------------------------------------------------------------
"
" Vim script to launch/control browsers
"
" Copyright ????-2008 Christian J. Robinson
"
" Distributable under the terms of the GNU GPL.
"
" Currently supported browsers:
" - Firefox (remote [new window / new tab] / launch) [1]
" - Mozilla (remote [new window / new tab] / launch) [1]
" - Netscape (remote [new window] / launch) [1]
" - Opera (remote [new window / new tab] / launch)
" - Lynx (Under the current TTY if not running the GUI, or a new xterm
" window if DISPLAY is set.)
" - w3m (Under the current TTY if not running the GUI, or a new xterm
" window if DISPLAY is set.)
"
" TODO:
"
" Support more browsers?
" - links (text browser)
"
" Defaulting to lynx if the the GUI isn't available may be undesirable.
"
" Note: Various browsers such as galeon, nautilus, phoenix, &c use the
" same HTML rendering engine as mozilla/firefox, so supporting them
" isn't as important.
"
" BUGS:
" * [1] The remote control for firefox/mozilla/netscape will probably
" default to firefox if more than one is running.
"
" * Since the commands to start the browsers are run in the backgorund
" there's no way to actually get v:shell_error, so execution errors
" aren't actually seen when not issuing a command to an already running
" browser.
"
" * The code is a mess. Oh well.
"
"--------------------------------------------------------------------------
if v:version < 700
finish
endif
command! -nargs=+ BERROR :echohl ErrorMsg | echomsg | echohl None
command! -nargs=+ BMESG :echohl Todo | echo | echohl None
" Attempt to detect which browsers are installed: {{{1
if has('unix')
let s:Browsers = {}
let s:BrowsersExist = 'fmnolw'
let s:Browsers['f'] = ['firefox', 0]
let s:Browsers['m'] = ['mozilla', 0]
let s:Browsers['n'] = ['netscape', 0]
let s:Browsers['o'] = ['opera', 0]
let s:Browsers['l'] = ['lynx', 0]
let s:Browsers['w'] = ['w3m', 0]
for s:temp1 in keys(s:Browsers)
let s:temp2 = system("which " . s:Browsers[s:temp1][0])
if v:shell_error == 0
let s:Browsers[s:temp1][1] = substitute(s:temp2, "\n$", '', '')
else
let s:BrowsersExist = substitute(s:BrowsersExist, s:temp1, '', 'g')
endif
endfor
unlet s:temp1 s:temp2
let s:NetscapeRemoteCmd = substitute(system("which mozilla-xremote-client"), "\n$", '', '')
if v:shell_error != 0
let s:NetscapeRemoteCmd = substitute(system("which netscape-remote"), "\n$", '', '')
endif
if v:shell_error != 0
if s:Browsers['f'][1] != 0
let s:NetscapeRemoteCmd = s:Browsers['f'][1]
elseif s:Browsers['m'][1] != 0
let s:NetscapeRemoteCmd = s:Browsers['m'][1]
elseif s:Browsers['n'][1] != 0
let s:NetscapeRemoteCmd = s:Browsers['n'][1]
else
"BERROR Can't set up remote-control preview code.
"BERROR (netscape-remote/firefox/mozilla/netscape not installed?)
"finish
let s:NetscapeRemoteCmd = 'false'
endif
endif
elseif has('win32') || has('win64')
BERROR Currently there's no browser control support for Windows.
BERROR See ":help html-author-notes"
"let s:Browsers = {}
"let s:BrowsersExist = ''
"if filereadable('C:\Program Files\Mozilla Firefox\firefox.exe')
" let s:Browsers['f'] = ['firefox', '"C:\Program Files\Mozilla Firefox\firefox.exe"']
" let s:BrowsersExist .= 'f'
"endif
"if s:Browsers['f'][1] != ''
" let s:NetscapeRemoteCmd = s:Browsers['f'][1]
"endif
elseif has('mac') || has('macunix')
BERROR Currently there's no browser control support for Macintosh.
BERROR See ":help html-author-notes"
endif
" }}}1
if exists("*LaunchBrowser")
finish
endif
function! s:ShellEscape(str)
if exists('*shellescape')
return shellescape(a:str)
else
return "'" . substitute(a:str, "'", "'\\\\''", 'g') . "'"
endif
endfunction
" LaunchBrowser() {{{1
"
" Usage:
" :call LaunchBrowser({[nolmf]},{[012]},[url])
" The first argument is which browser to launch:
" f - Firefox
" m - Mozilla
" n - Netscape
" o - Opera
" l - Lynx
" w - w3m
"
" default - This launches the first browser that was actually found.
"
" The second argument is whether to launch a new window:
" 0 - No
" 1 - Yes
" 2 - New Tab (or new window if the browser doesn't provide a way to
" open a new tab)
"
" The optional third argument is an URL to go to instead of loading the
" current file.
"
" Return value:
" 0 - Failure (No browser was launched/controlled.)
" 1 - Success
"
" A special case of no arguments returns a character list of what browsers
" were found.
function! LaunchBrowser(...)
let err = 0
if a:0 == 0
return s:BrowsersExist
elseif a:0 >= 2
let which = a:1
let new = a:2
else
let err = 1
endif
let file = 'file://' . expand('%:p')
if a:0 == 3
let file = a:3
elseif a:0 > 3
let err = 1
endif
if err
exe 'BERROR E119: Wrong number of arguments for function: '
\ . substitute(expand(''), '^function ', '', '')
return 0
endif
if which ==? 'default'
let which = strpart(s:BrowsersExist, 0, 1)
endif
if s:BrowsersExist !~? which
if exists('s:Browsers[which]')
exe 'BERROR ' . s:Browsers[which][0] . ' not found'
else
exe 'BERROR Unknown browser ID: ' . which
endif
return 0
endif
if has('unix') && (! strlen($DISPLAY) || which ==? 'l') " {{{
BMESG Launching lynx...
if (has("gui_running") || new) && strlen($DISPLAY)
let command='xterm -T Lynx -e lynx ' . s:ShellEscape(file) . ' &'
else
sleep 1
execute "!lynx " . s:ShellEscape(file)
if v:shell_error
BERROR Unable to launch lynx.
return 0
endif
endif
endif " }}}
if (which ==? 'w') " {{{
BMESG Launching w3m...
if (has("gui_running") || new) && strlen($DISPLAY)
let command='xterm -T w3m -e w3m ' . s:ShellEscape(file) . ' &'
else
sleep 1
execute "!w3m " . s:ShellEscape(file)
if v:shell_error
BERROR Unable to launch w3m.
return 0
endif
endif
endif " }}}
if (which ==? 'o') " {{{
if new == 2
BMESG Opening new Opera tab...
let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " -remote 'openURL('" . s:ShellEscape(file) . "',new-page)' &\""
elseif new
BMESG Opening new Opera window...
let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " -remote 'openURL('" . s:ShellEscape(file) . "',new-window)' &\""
else
BMESG Sending remote command to Opera...
let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " " . s:ShellEscape(file) . " &\""
endif
endif " }}}
" Find running instances firefox/mozilla/netscape: {{{
if has('unix')
let FirefoxRunning = 0
let MozillaRunning = 0
let NetscapeRunning = 0
let windows = system("xwininfo -root -children | egrep \"[Ff]irefox|[Nn]etscape|[Mm]ozilla\"; return 0")
if windows =~? 'firefox'
let FirefoxRunning = 1
endif
if windows =~? 'mozilla'
let MozillaRunning = 1
endif
if windows =~? 'netscape'
let NetscapeRunning = 1
endif
else
" ... Make some assumptions:
"let FirefoxRunning = 1
endif " }}}
if (which ==? 'f') " {{{
if ! FirefoxRunning
BMESG Launching firefox, please wait...
let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " " . s:ShellEscape(file) . " &\""
else
if new == 2
BMESG Opening new Firefox tab...
let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-tab)'"
elseif new
BMESG Opening new Firefox window...
let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-window)'"
else
BMESG Sending remote command to Firefox...
let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "')'"
endif
endif
endif " }}}
if (which ==? 'm') " {{{
if ! MozillaRunning
BMESG Launching mozilla, please wait...
let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " " . s:ShellEscape(file) . " &\""
else
if new == 2
BMESG Opening new Mozilla tab...
let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-tab)'"
elseif new
BMESG Opening new Mozilla window...
let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-window)'"
else
BMESG Sending remote command to Mozilla...
let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "')'"
endif
endif
endif " }}}
if (which ==? 'n') " {{{
if ! NetscapeRunning
BMESG Launching netscape, please wait...
let command="sh -c \"trap '' HUP; " . s:Browsers[which][1] . " " . s:ShellEscape(file) . " &\""
else
if new
BMESG Opening new Netscape window...
let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "',new-window)'"
else
BMESG Sending remote command to Netscape...
let command=s:NetscapeRemoteCmd . " -remote 'openURL('" . s:ShellEscape(file) . "')'"
endif
endif
endif " }}}
if exists('l:command')
if command =~ 'mozilla-xremote-client'
let command = substitute(command, '-remote', '-a ' . s:Browsers[which][0], '')
endif
if ! has('unix')
let command = substitute(command, "sh -c \"trap '' HUP; \\(.\\+\\) &\"", '\1', '')
let command = substitute(command, '"\(openURL(.\+)\)"', '\1', '')
endif
call system(command)
if has('unix') && v:shell_error
exe 'BERROR Command failed: ' . command
return 0
endif
return 1
endif
" Should never get here...if we do, something went wrong:
BERROR Something went wrong, shouln't ever get here...
return 0
endfunction " }}}1
" vim: set ts=2 sw=2 ai nu tw=75 fo=croq2 fdm=marker fdc=3:
doc/HTML.txt [[[1
1042
*HTML.txt* Set of HTML/XHTML macros, menus and toolbar buttons.
Last change: 2008 Jun 18
Author: Christian J. Robinson
*HTML.vim* *HTML-macros*
*XHTML-macros*
This is a set of HTML/XHTML macros, menus, and toolbar buttons to make editing
HTML files easier. The original Copyright goes to Doug Renze, although nearly
all of his efforts have been modified in this implementation. All the changes
are Copyright Christian J. Robinson. These macros and the supporting scripts
are distributable under the terms of the GNU GPL version 2 or later.
------------------------------------------------------------------------------
1. Introduction |html-intro|
2. Customization Variables |html-variables|
3. Commands |html-commands|
4. Mappings for Normal <> Tags |html-tags|
5. Mappings for &...; Codes, such as < > & and so on
|character-codes|
6. How to Use Browser Mappings |browser-control|
7. Miscellaneous Extras |html-misc|
==============================================================================
1. Introduction *html-intro*
To start, you should familiarize yourself with Vim enough to know the
terminology, and you should know HTML to some degree.
The mappings are local to the buffer the script was sourced from, and the menu
and toolbar are active only for buffers the script was sourced from.
This help file follows the Vim help file standards. To see what modes a
mapping works in see the tags between the **'s. For example, the |;;| mapping
below works in normal, insert mode and visual mode.
In the descriptions of the mappings I often use to mean a literal
newline.
*html-smart-tag*
Noted tags are "smart"--if syntax highlighting is enabled it can be used to
detect whether to close then open a tag instead of open then close the tag.
For example, if the cursor is in italicized text and you type ;it, it will
insert instead of .
This can not be done on most tags due to its dependence on the syntax
highlighting.
NOTE: Some tags are synonyms and Vim can't distinguish between them. For
example, if you're within and type |;em| it will assume you want
rather than , which you should not be doing anyway.
*n_;;* *i_;;* *v_;;*
;; Most of the mappings start with ; so ;; is mapped to insert a single
; character in insert mode, behave like a single ; in normal mode,
etc. (The semicolons in this mapping are changed to whatever
|g:html_map_leader| is set to.)
*i_;&*
;& The HTML |character-entities| insert mode mappings start with &, so
typing ;& in insert mode will insert a literal & character.
(In actuality this mapping is defined as |g:html_map_leader| +
|g:html_map_entity_leader| to insert whatever is in
|g:html_map_entity_leader|.) (See also |n_;&|)
*html-* *html-tab* *html-CTRL-I*
*i_html-* *i_html-tab* *i_html-CTRL-I*
*v_html-* *v_html-tab* *v_html-CTRL-I*
If the cursor is on a closing tag the tab key jumps the cursor after
the tag. Otherwise the tab key will jump the cursor to an unfilled
tag somewhere in the file. For example, if you had the tag:
>
<
And you hit tab, your cursor would be placed on the second " so you
could insert text easily. Next time you hit tab it would be placed on
the < character of . And the third time you hit tab the cursor
would be placed on the > of , and so on. This works for tags
split across lines, such as:
>