annotate runtime/syntax/2html.vim @ 11158:501f46f7644c v8.0.0466

patch 8.0.0466: still macros that should be all-caps commit https://github.com/vim/vim/commit/8820b48654b62472821d9b155fe03ab7ac13a05c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 16 17:23:31 2017 +0100 patch 8.0.0466: still macros that should be all-caps Problem: There are still a few macros that should be all-caps. Solution: Make a few more macros all-caps.
author Christian Brabandt <cb@256bit.org>
date Thu, 16 Mar 2017 17:30:06 +0100
parents 30042ddff503
children f8b0f1e42f2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax support file
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
2 " Maintainer: Ben Fritz <fritzophrenic@gmail.com>
7176
30042ddff503 commit https://github.com/vim/vim/commit/60cce2fb736c8ff6fdb9603f502d3c15f1f7a25d
Christian Brabandt <cb@256bit.org>
parents: 5161
diff changeset
3 " Last Change: 2015 Sep 08
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
4 "
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
5 " Additional contributors:
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
6 "
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
7 " Original by Bram Moolenaar <Bram@vim.org>
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
8 " Modified by David Ne\v{c}as (Yeti) <yeti@physics.muni.cz>
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
9 " XHTML support by Panagiotis Issaris <takis@lumumba.luc.ac.be>
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
10 " Made w3 compliant by Edd Barrett <vext01@gmail.com>
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
11 " Added html_font. Edd Barrett <vext01@gmail.com>
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
12 " Progress bar based off code from "progressbar widget" plugin by
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
13 " Andreas Politz, heavily modified:
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
14 " http://www.vim.org/scripts/script.php?script_id=2006
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
15 "
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
16 " See Mercurial change logs for more!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 " Transform a file into HTML, using the current syntax highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
20 " this file uses line continuations
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
21 let s:cpo_sav = &cpo
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
22 let s:ls = &ls
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
23 set cpo&vim
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
24
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
25 let s:end=line('$')
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
26
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
27 " Font
2304
a59e6ac5ed28 When the buffer is in diff mode, have :TOhtml create HTML to show the diff
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
28 if exists("g:html_font")
7176
30042ddff503 commit https://github.com/vim/vim/commit/60cce2fb736c8ff6fdb9603f502d3c15f1f7a25d
Christian Brabandt <cb@256bit.org>
parents: 5161
diff changeset
29 if type(g:html_font) == type([])
30042ddff503 commit https://github.com/vim/vim/commit/60cce2fb736c8ff6fdb9603f502d3c15f1f7a25d
Christian Brabandt <cb@256bit.org>
parents: 5161
diff changeset
30 let s:htmlfont = "'". join(g:html_font,"','") . "', monospace"
30042ddff503 commit https://github.com/vim/vim/commit/60cce2fb736c8ff6fdb9603f502d3c15f1f7a25d
Christian Brabandt <cb@256bit.org>
parents: 5161
diff changeset
31 else
30042ddff503 commit https://github.com/vim/vim/commit/60cce2fb736c8ff6fdb9603f502d3c15f1f7a25d
Christian Brabandt <cb@256bit.org>
parents: 5161
diff changeset
32 let s:htmlfont = "'". g:html_font . "', monospace"
30042ddff503 commit https://github.com/vim/vim/commit/60cce2fb736c8ff6fdb9603f502d3c15f1f7a25d
Christian Brabandt <cb@256bit.org>
parents: 5161
diff changeset
33 endif
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
34 else
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
35 let s:htmlfont = "monospace"
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
36 endif
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
37
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
38 let s:settings = tohtml#GetUserSettings()
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
39
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
40 if !exists('s:FOLDED_ID')
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
41 let s:FOLDED_ID = hlID("Folded") | lockvar s:FOLDED_ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
42 let s:FOLD_C_ID = hlID("FoldColumn") | lockvar s:FOLD_C_ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
43 let s:LINENR_ID = hlID('LineNr') | lockvar s:LINENR_ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
44 let s:DIFF_D_ID = hlID("DiffDelete") | lockvar s:DIFF_D_ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
45 let s:DIFF_A_ID = hlID("DiffAdd") | lockvar s:DIFF_A_ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
46 let s:DIFF_C_ID = hlID("DiffChange") | lockvar s:DIFF_C_ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
47 let s:DIFF_T_ID = hlID("DiffText") | lockvar s:DIFF_T_ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
48 let s:CONCEAL_ID = hlID('Conceal') | lockvar s:CONCEAL_ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
49 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
50
2788
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
51 " Whitespace
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
52 if s:settings.pre_wrap
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
53 let s:whitespace = "white-space: pre-wrap; "
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
54 else
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
55 let s:whitespace = ""
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
56 endif
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
57
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
58 if !empty(s:settings.prevent_copy)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
59 if s:settings.no_invalid
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
60 " User has decided they don't want invalid markup. Still works in
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
61 " OpenOffice, and for text editors, but when pasting into Microsoft Word the
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
62 " input elements get pasted too and they cannot be deleted (at least not
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
63 " easily).
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
64 let s:unselInputType = ""
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
65 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
66 " Prevent from copy-pasting the input elements into Microsoft Word where
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
67 " they cannot be deleted easily by deliberately inserting invalid markup.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
68 let s:unselInputType = " type='invalid_input_type'"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
69 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
70 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
71
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 " When not in gui we can only guess the colors.
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
73 " TODO - is this true anymore?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 if has("gui_running")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 let s:whatterm = "gui"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 let s:whatterm = "cterm"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 if &t_Co == 8
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
79 let s:cterm_color = {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
80 \ 0: "#808080", 1: "#ff6060", 2: "#00ff00", 3: "#ffff00",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
81 \ 4: "#8080ff", 5: "#ff40ff", 6: "#00ffff", 7: "#ffffff"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
82 \ }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 else
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
84 let s:cterm_color = {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
85 \ 0: "#000000", 1: "#c00000", 2: "#008000", 3: "#804000",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
86 \ 4: "#0000c0", 5: "#c000c0", 6: "#008080", 7: "#c0c0c0",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
87 \ 8: "#808080", 9: "#ff6060", 10: "#00ff00", 11: "#ffff00",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
88 \ 12: "#8080ff", 13: "#ff40ff", 14: "#00ffff", 15: "#ffffff"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
89 \ }
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
90
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
91 " Colors for 88 and 256 come from xterm.
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
92 if &t_Co == 88
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
93 call extend(s:cterm_color, {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
94 \ 16: "#000000", 17: "#00008b", 18: "#0000cd", 19: "#0000ff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
95 \ 20: "#008b00", 21: "#008b8b", 22: "#008bcd", 23: "#008bff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
96 \ 24: "#00cd00", 25: "#00cd8b", 26: "#00cdcd", 27: "#00cdff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
97 \ 28: "#00ff00", 29: "#00ff8b", 30: "#00ffcd", 31: "#00ffff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
98 \ 32: "#8b0000", 33: "#8b008b", 34: "#8b00cd", 35: "#8b00ff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
99 \ 36: "#8b8b00", 37: "#8b8b8b", 38: "#8b8bcd", 39: "#8b8bff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
100 \ 40: "#8bcd00", 41: "#8bcd8b", 42: "#8bcdcd", 43: "#8bcdff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
101 \ 44: "#8bff00", 45: "#8bff8b", 46: "#8bffcd", 47: "#8bffff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
102 \ 48: "#cd0000", 49: "#cd008b", 50: "#cd00cd", 51: "#cd00ff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
103 \ 52: "#cd8b00", 53: "#cd8b8b", 54: "#cd8bcd", 55: "#cd8bff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
104 \ 56: "#cdcd00", 57: "#cdcd8b", 58: "#cdcdcd", 59: "#cdcdff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
105 \ 60: "#cdff00", 61: "#cdff8b", 62: "#cdffcd", 63: "#cdffff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
106 \ 64: "#ff0000"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
107 \ })
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
108 call extend(s:cterm_color, {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
109 \ 65: "#ff008b", 66: "#ff00cd", 67: "#ff00ff", 68: "#ff8b00",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
110 \ 69: "#ff8b8b", 70: "#ff8bcd", 71: "#ff8bff", 72: "#ffcd00",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
111 \ 73: "#ffcd8b", 74: "#ffcdcd", 75: "#ffcdff", 76: "#ffff00",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
112 \ 77: "#ffff8b", 78: "#ffffcd", 79: "#ffffff", 80: "#2e2e2e",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
113 \ 81: "#5c5c5c", 82: "#737373", 83: "#8b8b8b", 84: "#a2a2a2",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
114 \ 85: "#b9b9b9", 86: "#d0d0d0", 87: "#e7e7e7"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
115 \ })
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
116 elseif &t_Co == 256
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
117 call extend(s:cterm_color, {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
118 \ 16: "#000000", 17: "#00005f", 18: "#000087", 19: "#0000af",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
119 \ 20: "#0000d7", 21: "#0000ff", 22: "#005f00", 23: "#005f5f",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
120 \ 24: "#005f87", 25: "#005faf", 26: "#005fd7", 27: "#005fff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
121 \ 28: "#008700", 29: "#00875f", 30: "#008787", 31: "#0087af",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
122 \ 32: "#0087d7", 33: "#0087ff", 34: "#00af00", 35: "#00af5f",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
123 \ 36: "#00af87", 37: "#00afaf", 38: "#00afd7", 39: "#00afff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
124 \ 40: "#00d700", 41: "#00d75f", 42: "#00d787", 43: "#00d7af",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
125 \ 44: "#00d7d7", 45: "#00d7ff", 46: "#00ff00", 47: "#00ff5f",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
126 \ 48: "#00ff87", 49: "#00ffaf", 50: "#00ffd7", 51: "#00ffff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
127 \ 52: "#5f0000", 53: "#5f005f", 54: "#5f0087", 55: "#5f00af",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
128 \ 56: "#5f00d7", 57: "#5f00ff", 58: "#5f5f00", 59: "#5f5f5f",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
129 \ 60: "#5f5f87", 61: "#5f5faf", 62: "#5f5fd7", 63: "#5f5fff",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
130 \ 64: "#5f8700"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
131 \ })
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
132 call extend(s:cterm_color, {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
133 \ 65: "#5f875f", 66: "#5f8787", 67: "#5f87af", 68: "#5f87d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
134 \ 69: "#5f87ff", 70: "#5faf00", 71: "#5faf5f", 72: "#5faf87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
135 \ 73: "#5fafaf", 74: "#5fafd7", 75: "#5fafff", 76: "#5fd700",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
136 \ 77: "#5fd75f", 78: "#5fd787", 79: "#5fd7af", 80: "#5fd7d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
137 \ 81: "#5fd7ff", 82: "#5fff00", 83: "#5fff5f", 84: "#5fff87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
138 \ 85: "#5fffaf", 86: "#5fffd7", 87: "#5fffff", 88: "#870000",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
139 \ 89: "#87005f", 90: "#870087", 91: "#8700af", 92: "#8700d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
140 \ 93: "#8700ff", 94: "#875f00", 95: "#875f5f", 96: "#875f87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
141 \ 97: "#875faf", 98: "#875fd7", 99: "#875fff", 100: "#878700",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
142 \ 101: "#87875f", 102: "#878787", 103: "#8787af", 104: "#8787d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
143 \ 105: "#8787ff", 106: "#87af00", 107: "#87af5f", 108: "#87af87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
144 \ 109: "#87afaf", 110: "#87afd7", 111: "#87afff", 112: "#87d700"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
145 \ })
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
146 call extend(s:cterm_color, {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
147 \ 113: "#87d75f", 114: "#87d787", 115: "#87d7af", 116: "#87d7d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
148 \ 117: "#87d7ff", 118: "#87ff00", 119: "#87ff5f", 120: "#87ff87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
149 \ 121: "#87ffaf", 122: "#87ffd7", 123: "#87ffff", 124: "#af0000",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
150 \ 125: "#af005f", 126: "#af0087", 127: "#af00af", 128: "#af00d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
151 \ 129: "#af00ff", 130: "#af5f00", 131: "#af5f5f", 132: "#af5f87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
152 \ 133: "#af5faf", 134: "#af5fd7", 135: "#af5fff", 136: "#af8700",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
153 \ 137: "#af875f", 138: "#af8787", 139: "#af87af", 140: "#af87d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
154 \ 141: "#af87ff", 142: "#afaf00", 143: "#afaf5f", 144: "#afaf87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
155 \ 145: "#afafaf", 146: "#afafd7", 147: "#afafff", 148: "#afd700",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
156 \ 149: "#afd75f", 150: "#afd787", 151: "#afd7af", 152: "#afd7d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
157 \ 153: "#afd7ff", 154: "#afff00", 155: "#afff5f", 156: "#afff87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
158 \ 157: "#afffaf", 158: "#afffd7"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
159 \ })
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
160 call extend(s:cterm_color, {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
161 \ 159: "#afffff", 160: "#d70000", 161: "#d7005f", 162: "#d70087",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
162 \ 163: "#d700af", 164: "#d700d7", 165: "#d700ff", 166: "#d75f00",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
163 \ 167: "#d75f5f", 168: "#d75f87", 169: "#d75faf", 170: "#d75fd7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
164 \ 171: "#d75fff", 172: "#d78700", 173: "#d7875f", 174: "#d78787",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
165 \ 175: "#d787af", 176: "#d787d7", 177: "#d787ff", 178: "#d7af00",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
166 \ 179: "#d7af5f", 180: "#d7af87", 181: "#d7afaf", 182: "#d7afd7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
167 \ 183: "#d7afff", 184: "#d7d700", 185: "#d7d75f", 186: "#d7d787",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
168 \ 187: "#d7d7af", 188: "#d7d7d7", 189: "#d7d7ff", 190: "#d7ff00",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
169 \ 191: "#d7ff5f", 192: "#d7ff87", 193: "#d7ffaf", 194: "#d7ffd7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
170 \ 195: "#d7ffff", 196: "#ff0000", 197: "#ff005f", 198: "#ff0087",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
171 \ 199: "#ff00af", 200: "#ff00d7", 201: "#ff00ff", 202: "#ff5f00",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
172 \ 203: "#ff5f5f", 204: "#ff5f87"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
173 \ })
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
174 call extend(s:cterm_color, {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
175 \ 205: "#ff5faf", 206: "#ff5fd7", 207: "#ff5fff", 208: "#ff8700",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
176 \ 209: "#ff875f", 210: "#ff8787", 211: "#ff87af", 212: "#ff87d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
177 \ 213: "#ff87ff", 214: "#ffaf00", 215: "#ffaf5f", 216: "#ffaf87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
178 \ 217: "#ffafaf", 218: "#ffafd7", 219: "#ffafff", 220: "#ffd700",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
179 \ 221: "#ffd75f", 222: "#ffd787", 223: "#ffd7af", 224: "#ffd7d7",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
180 \ 225: "#ffd7ff", 226: "#ffff00", 227: "#ffff5f", 228: "#ffff87",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
181 \ 229: "#ffffaf", 230: "#ffffd7", 231: "#ffffff", 232: "#080808",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
182 \ 233: "#121212", 234: "#1c1c1c", 235: "#262626", 236: "#303030",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
183 \ 237: "#3a3a3a", 238: "#444444", 239: "#4e4e4e", 240: "#585858",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
184 \ 241: "#626262", 242: "#6c6c6c", 243: "#767676", 244: "#808080",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
185 \ 245: "#8a8a8a", 246: "#949494", 247: "#9e9e9e", 248: "#a8a8a8",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
186 \ 249: "#b2b2b2", 250: "#bcbcbc", 251: "#c6c6c6", 252: "#d0d0d0",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
187 \ 253: "#dadada", 254: "#e4e4e4", 255: "#eeeeee"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
188 \ })
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
189 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 " Return good color specification: in GUI no transformation is done, in
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
194 " terminal return RGB values of known colors and empty string for unknown
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 if s:whatterm == "gui"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 function! s:HtmlColor(color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 return a:color
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 function! s:HtmlColor(color)
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
201 if has_key(s:cterm_color, a:color)
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
202 return s:cterm_color[a:color]
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 return ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
209 " Find out the background and foreground color for use later
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
210 let s:fgc = s:HtmlColor(synIDattr(hlID("Normal"), "fg#", s:whatterm))
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
211 let s:bgc = s:HtmlColor(synIDattr(hlID("Normal"), "bg#", s:whatterm))
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
212 if s:fgc == ""
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
213 let s:fgc = ( &background == "dark" ? "#ffffff" : "#000000" )
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
214 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
215 if s:bgc == ""
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
216 let s:bgc = ( &background == "dark" ? "#000000" : "#ffffff" )
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
217 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
218
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
219 if !s:settings.use_css
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 " Return opening HTML tag for given highlight id
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
221 function! s:HtmlOpening(id, extra_attrs)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 let a = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 if synIDattr(a:id, "inverse")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 " For inverse, we always must set both colors (and exchange them)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
226 let a = a . '<span '.a:extra_attrs.'style="background-color: ' . ( x != "" ? x : s:fgc ) . '">'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 let a = a . '<font color="' . ( x != "" ? x : s:bgc ) . '">'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
231 if x != ""
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
232 let a = a . '<span '.a:extra_attrs.'style="background-color: ' . x . '">'
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
233 elseif !empty(a:extra_attrs)
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
234 let a = a . '<span '.a:extra_attrs.'>'
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
235 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 if x != "" | let a = a . '<font color="' . x . '">' | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 if synIDattr(a:id, "bold") | let a = a . "<b>" | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 if synIDattr(a:id, "italic") | let a = a . "<i>" | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 if synIDattr(a:id, "underline") | let a = a . "<u>" | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 return a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 " Return closing HTML tag for given highlight id
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
246 function! s:HtmlClosing(id, has_extra_attrs)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 let a = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 if synIDattr(a:id, "underline") | let a = a . "</u>" | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 if synIDattr(a:id, "italic") | let a = a . "</i>" | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 if synIDattr(a:id, "bold") | let a = a . "</b>" | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 if synIDattr(a:id, "inverse")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 let a = a . '</font></span>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 if x != "" | let a = a . '</font>' | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
257 if x != "" || a:has_extra_attrs | let a = a . '</span>' | endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 return a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
263 " Use a different function for formatting based on user options. This way we
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
264 " can avoid a lot of logic during the actual execution.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
265 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
266 " Build the function line by line containing only what is needed for the options
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
267 " in use for maximum code sharing with minimal branch logic for greater speed.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
268 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
269 " Note, 'exec' commands do not recognize line continuations, so must concatenate
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
270 " lines rather than continue them.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
271 if s:settings.use_css
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
272 " save CSS to a list of rules to add to the output at the end of processing
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
273
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
274 " first, get the style names we need
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
275 let wrapperfunc_lines = [
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
276 \ 'function! s:BuildStyleWrapper(style_id, diff_style_id, extra_attrs, text, make_unselectable, unformatted)',
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
277 \ '',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
278 \ ' let l:style_name = synIDattr(a:style_id, "name", s:whatterm)'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
279 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
280 if &diff
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
281 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
282 \ ' let l:diff_style_name = synIDattr(a:diff_style_id, "name", s:whatterm)']
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
283
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
284 " Add normal groups and diff groups to separate lists so we can order them to
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
285 " allow diff highlight to override normal highlight
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
286
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
287 " if primary style IS a diff style, grab it from the diff cache instead
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
288 " (always succeeds because we pre-populate it)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
289 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
290 \ '',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
291 \ ' if a:style_id == s:DIFF_D_ID || a:style_id == s:DIFF_A_ID ||'.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
292 \ ' a:style_id == s:DIFF_C_ID || a:style_id == s:DIFF_T_ID',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
293 \ ' let l:saved_style = get(s:diffstylelist,a:style_id)',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
294 \ ' else'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
295 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
296 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
297
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
298 " get primary style info from cache or build it on the fly if not found
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
299 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
300 \ ' let l:saved_style = get(s:stylelist,a:style_id)',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
301 \ ' if type(l:saved_style) == type(0)',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
302 \ ' unlet l:saved_style',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
303 \ ' let l:saved_style = s:CSS1(a:style_id)',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
304 \ ' if l:saved_style != ""',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
305 \ ' let l:saved_style = "." . l:style_name . " { " . l:saved_style . "}"',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
306 \ ' endif',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
307 \ ' let s:stylelist[a:style_id]= l:saved_style',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
308 \ ' endif'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
309 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
310 if &diff
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
311 let wrapperfunc_lines += [ ' endif' ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
312 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
313
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
314 " Build the wrapper tags around the text. It turns out that caching these
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
315 " gives pretty much zero performance gain and adds a lot of logic.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
316
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
317 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
318 \ '',
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
319 \ ' if l:saved_style == "" && empty(a:extra_attrs)'
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
320 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
321 if &diff
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
322 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
323 \ ' if a:diff_style_id <= 0'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
324 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
325 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
326 " no surroundings if neither primary nor diff style has any info
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
327 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
328 \ ' return a:text'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
329 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
330 if &diff
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
331 " no primary style, but diff style
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
332 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
333 \ ' else',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
334 \ ' return "<span class=\"" .l:diff_style_name . "\">".a:text."</span>"',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
335 \ ' endif'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
336 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
337 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
338 " open tag for non-empty primary style
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
339 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
340 \ ' else']
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
341 " non-empty primary style. handle either empty or non-empty diff style.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
342 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
343 " separate the two classes by a space to apply them both if there is a diff
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
344 " style name, unless the primary style is empty, then just use the diff style
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
345 " name
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
346 let diffstyle =
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
347 \ (&diff ? '(a:diff_style_id <= 0 ? "" : " ". l:diff_style_name) .'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
348 \ : "")
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
349 if s:settings.prevent_copy == ""
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
350 let wrapperfunc_lines += [
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
351 \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'.diffstyle.'"\">".a:text."</span>"'
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
352 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
353 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
354
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
355 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
356 " Wrap the <input> in a <span> to allow fixing the stupid bug in some fonts
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
357 " which cause browsers to display a 1px gap between lines when these
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
358 " <input>s have a background color (maybe not really a bug, this isn't
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
359 " well-defined)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
360 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
361 " use strwidth, because we care only about how many character boxes are
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
362 " needed to size the input, we don't care how many characters (including
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
363 " separately counted composing chars, from strchars()) or bytes (from
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
364 " len())the string contains. strdisplaywidth() is not needed because none of
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
365 " the unselectable groups can contain tab characters (fold column, fold
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
366 " text, line number).
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
367 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
368 " Note, if maxlength property needs to be added in the future, it will need
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
369 " to use strchars(), because HTML specifies that the maxlength parameter
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
370 " uses the number of unique codepoints for its limit.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
371 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
372 \ ' if a:make_unselectable',
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
373 \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'.diffstyle.'"\">'.
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
374 \ '<input'.s:unselInputType.' class=\"" . l:style_name .'.diffstyle.'"\"'.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
375 \ ' value=\"".substitute(a:unformatted,''\s\+$'',"","")."\"'.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
376 \ ' onselect=''this.blur(); return false;'''.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
377 \ ' onmousedown=''this.blur(); return false;'''.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
378 \ ' onclick=''this.blur(); return false;'''.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
379 \ ' readonly=''readonly'''.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
380 \ ' size=\"".strwidth(a:unformatted)."\"'.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
381 \ (s:settings.use_xhtml ? '/' : '').'></span>"',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
382 \ ' else',
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
383 \ ' return "<span ".a:extra_attrs."class=\"" . l:style_name .'. diffstyle .'"\">".a:text."</span>"'
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
384 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
385 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
386 let wrapperfunc_lines += [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
387 \ ' endif',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
388 \ 'endfun'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
389 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
390 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
391 " Non-CSS method just needs the wrapper.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
392 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
393 " Functions used to get opening/closing automatically return null strings if
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
394 " no styles exist.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
395 if &diff
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
396 let wrapperfunc_lines = [
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
397 \ 'function! s:BuildStyleWrapper(style_id, diff_style_id, extra_attrs, text, unusedarg, unusedarg2)',
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
398 \ ' return s:HtmlOpening(a:style_id, a:extra_attrs).(a:diff_style_id <= 0 ? "" :'.
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
399 \ 's:HtmlOpening(a:diff_style_id, "")).a:text.'.
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
400 \ '(a:diff_style_id <= 0 ? "" : s:HtmlClosing(a:diff_style_id, 0)).s:HtmlClosing(a:style_id, !empty(a:extra_attrs))',
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
401 \ 'endfun'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
402 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
403 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
404 let wrapperfunc_lines = [
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
405 \ 'function! s:BuildStyleWrapper(style_id, diff_style_id, extra_attrs, text, unusedarg, unusedarg2)',
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
406 \ ' return s:HtmlOpening(a:style_id, a:extra_attrs).a:text.s:HtmlClosing(a:style_id, !empty(a:extra_attrs))',
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
407 \ 'endfun'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
408 \ ]
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
409 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
410 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
411
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
412 " create the function we built line by line above
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
413 exec join(wrapperfunc_lines, "\n")
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
414
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
415 let s:diff_mode = &diff
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
416
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
417 " Return HTML valid characters enclosed in a span of class style_name with
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
418 " unprintable characters expanded and double spaces replaced as necessary.
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
419 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
420 " TODO: eliminate unneeded logic like done for BuildStyleWrapper
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
421 function! s:HtmlFormat(text, style_id, diff_style_id, extra_attrs, make_unselectable)
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
422 " Replace unprintable characters
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
423 let unformatted = strtrans(a:text)
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
424
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
425 let formatted = unformatted
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
426
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
427 " Replace the reserved html characters
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
428 let formatted = substitute(formatted, '&', '\&amp;', 'g')
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
429 let formatted = substitute(formatted, '<', '\&lt;', 'g')
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
430 let formatted = substitute(formatted, '>', '\&gt;', 'g')
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
431 let formatted = substitute(formatted, '"', '\&quot;', 'g')
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
432 " &apos; is not valid in HTML but it is in XHTML, so just use the numeric
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
433 " reference for it instead. Needed because it could appear in quotes
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
434 " especially if unselectable regions is turned on.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
435 let formatted = substitute(formatted, '"', '\&#0039;', 'g')
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
436
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
437 " Replace a "form feed" character with HTML to do a page break
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
438 " TODO: need to prevent this in unselectable areas? Probably it should never
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
439 " BE in an unselectable area...
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
440 let formatted = substitute(formatted, "\x0c", '<hr class="PAGE-BREAK">', 'g')
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
441
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
442 " Replace double spaces, leading spaces, and trailing spaces if needed
856
8cd729851562 updated for version 7.0g
vimboss
parents: 837
diff changeset
443 if ' ' != s:HtmlSpace
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
444 let formatted = substitute(formatted, ' ', s:HtmlSpace . s:HtmlSpace, 'g')
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 836
diff changeset
445 let formatted = substitute(formatted, '^ ', s:HtmlSpace, 'g')
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
446 let formatted = substitute(formatted, ' \+$', s:HtmlSpace, 'g')
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
447 endif
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
448
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
449 " Enclose in the correct format
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
450 return s:BuildStyleWrapper(a:style_id, a:diff_style_id, a:extra_attrs, formatted, a:make_unselectable, unformatted)
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
451 endfun
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
452
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
453 " set up functions to call HtmlFormat in certain ways based on whether the
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
454 " element is supposed to be unselectable or not
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
455 if s:settings.prevent_copy =~# 'n'
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
456 if s:settings.number_lines
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
457 if s:settings.line_ids
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
458 function! s:HtmlFormat_n(text, style_id, diff_style_id, lnr)
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
459 if a:lnr > 0
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
460 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, 'id="'.(exists('g:html_diff_win_num') ? 'W'.g:html_diff_win_num : "").'L'.a:lnr.s:settings.id_suffix.'" ', 1)
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
461 else
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
462 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 1)
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
463 endif
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
464 endfun
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
465 else
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
466 function! s:HtmlFormat_n(text, style_id, diff_style_id, lnr)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
467 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 1)
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
468 endfun
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
469 endif
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
470 elseif s:settings.line_ids
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
471 " if lines are not being numbered the only reason this function gets called
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
472 " is to put the line IDs on each line; "text" will be emtpy but lnr will
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
473 " always be non-zero, however we don't want to use the <input> because that
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
474 " won't work as nice for empty text
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
475 function! s:HtmlFormat_n(text, style_id, diff_style_id, lnr)
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
476 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, 'id="'.(exists('g:html_diff_win_num') ? 'W'.g:html_diff_win_num : "").'L'.a:lnr.s:settings.id_suffix.'" ', 0)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
477 endfun
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
478 endif
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
479 else
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
480 if s:settings.line_ids
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
481 function! s:HtmlFormat_n(text, style_id, diff_style_id, lnr)
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
482 if a:lnr > 0
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
483 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, 'id="'.(exists('g:html_diff_win_num') ? 'W'.g:html_diff_win_num : "").'L'.a:lnr.s:settings.id_suffix.'" ', 0)
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
484 else
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
485 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 0)
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
486 endif
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
487 endfun
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
488 else
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
489 function! s:HtmlFormat_n(text, style_id, diff_style_id, lnr)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
490 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 0)
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
491 endfun
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
492 endif
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
493 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
494 if s:settings.prevent_copy =~# 'd'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
495 function! s:HtmlFormat_d(text, style_id, diff_style_id)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
496 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 1)
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
497 endfun
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
498 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
499 function! s:HtmlFormat_d(text, style_id, diff_style_id)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
500 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 0)
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
501 endfun
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
502 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
503 if s:settings.prevent_copy =~# 'f'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
504 " Note the <input> elements for fill spaces will have a single space for
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
505 " content, to allow active cursor CSS selection to work.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
506 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
507 " Wrap the whole thing in a span for the 1px padding workaround for gaps.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
508 function! s:FoldColumn_build(char, len, numfill, char2, class, click)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
509 let l:input_open = "<input readonly='readonly'".s:unselInputType.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
510 \ " onselect='this.blur(); return false;'".
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
511 \ " onmousedown='this.blur(); ".a:click." return false;'".
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
512 \ " onclick='return false;' size='".
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
513 \ string(a:len + (empty(a:char2) ? 0 : 1) + a:numfill) .
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
514 \ "' "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
515 let l:common_attrs = "class='FoldColumn' value='"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
516 let l:input_close = (s:settings.use_xhtml ? "' />" : "'>")
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
517 return "<span class='".a:class."'>".
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
518 \ l:input_open.l:common_attrs.repeat(a:char, a:len).
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
519 \ (!empty(a:char2) ? a:char2 : "").
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
520 \ l:input_close . "</span>"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
521 endfun
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
522 function! s:FoldColumn_fill()
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
523 return s:FoldColumn_build('', s:foldcolumn, 0, '', 'FoldColumn', '')
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
524 endfun
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
525 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
526 " For normal fold columns, simply space-pad to the desired width (note that
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
527 " the FoldColumn definition includes a whitespace:pre rule)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
528 function! s:FoldColumn_build(char, len, numfill, char2, class, click)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
529 return "<a href='#' class='".a:class."' onclick='".a:click."'>".
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
530 \ repeat(a:char, a:len).a:char2.repeat(' ', a:numfill).
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
531 \ "</a>"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
532 endfun
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
533 function! s:FoldColumn_fill()
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
534 return s:HtmlFormat(repeat(' ', s:foldcolumn), s:FOLD_C_ID, 0, "", 0)
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
535 endfun
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
536 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
537 if s:settings.prevent_copy =~# 't'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
538 " put an extra empty span at the end for dynamic folds, so the linebreak can
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
539 " be surrounded. Otherwise do it as normal.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
540 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
541 " TODO: isn't there a better way to do this, than placing it here and using a
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
542 " substitute later?
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
543 if s:settings.dynamic_folds
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
544 function! s:HtmlFormat_t(text, style_id, diff_style_id)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
545 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 1) .
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
546 \ s:HtmlFormat("", a:style_id, 0, "", 0)
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
547 endfun
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
548 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
549 function! s:HtmlFormat_t(text, style_id, diff_style_id)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
550 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 1)
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
551 endfun
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
552 endif
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
553 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
554 function! s:HtmlFormat_t(text, style_id, diff_style_id)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
555 return s:HtmlFormat(a:text, a:style_id, a:diff_style_id, "", 0)
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
556 endfun
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
557 endif
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
558
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 " Return CSS style describing given highlight id (can be empty)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 function! s:CSS1(id)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 let a = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 if synIDattr(a:id, "inverse")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 " For inverse, we always must set both colors (and exchange them)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 let a = a . "color: " . ( x != "" ? x : s:bgc ) . "; "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 let a = a . "background-color: " . ( x != "" ? x : s:fgc ) . "; "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 let x = s:HtmlColor(synIDattr(a:id, "fg#", s:whatterm))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 if x != "" | let a = a . "color: " . x . "; " | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 let x = s:HtmlColor(synIDattr(a:id, "bg#", s:whatterm))
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
572 if x != ""
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
573 let a = a . "background-color: " . x . "; "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
574 " stupid hack because almost every browser seems to have at least one font
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
575 " which shows 1px gaps between lines which have background
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
576 let a = a . "padding-bottom: 1px; "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
577 elseif (a:id == s:FOLDED_ID || a:id == s:LINENR_ID || a:id == s:FOLD_C_ID) && !empty(s:settings.prevent_copy)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
578 " input elements default to a different color than the rest of the page
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
579 let a = a . "background-color: " . s:bgc . "; "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
580 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 if synIDattr(a:id, "bold") | let a = a . "font-weight: bold; " | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 if synIDattr(a:id, "italic") | let a = a . "font-style: italic; " | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 if synIDattr(a:id, "underline") | let a = a . "text-decoration: underline; " | endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 return a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 endfun
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
588 if s:settings.dynamic_folds
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
589 " compares two folds as stored in our list of folds
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
590 " A fold is "less" than another if it starts at an earlier line number,
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
591 " or ends at a later line number, ties broken by fold level
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
592 function! s:FoldCompare(f1, f2)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
593 if a:f1.firstline != a:f2.firstline
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
594 " put it before if it starts earlier
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
595 return a:f1.firstline - a:f2.firstline
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
596 elseif a:f1.lastline != a:f2.lastline
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
597 " put it before if it ends later
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
598 return a:f2.lastline - a:f1.lastline
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
599 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
600 " if folds begin and end on the same lines, put lowest fold level first
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
601 return a:f1.level - a:f2.level
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
602 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
603 endfunction
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
604
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
605 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
606
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 " Set some options to make it work faster.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 " Don't report changes for :substitute, there will be many of them.
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
610 " Don't change other windows; turn off scroll bind temporarily
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 let s:old_title = &title
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 let s:old_icon = &icon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 let s:old_et = &l:et
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
614 let s:old_bind = &l:scrollbind
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 let s:old_report = &report
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 let s:old_search = @/
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
617 let s:old_more = &more
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 set notitle noicon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 setlocal et
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
620 set nomore
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 set report=1000000
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
622 setlocal noscrollbind
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
624 if exists(':ownsyntax') && exists('w:current_syntax')
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
625 let s:current_syntax = w:current_syntax
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
626 elseif exists('b:current_syntax')
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
627 let s:current_syntax = b:current_syntax
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
628 else
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
629 let s:current_syntax = 'none'
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
630 endif
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
631
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
632 if s:current_syntax == ''
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
633 let s:current_syntax = 'none'
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
634 endif
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
635
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 " Split window to create a buffer with the HTML file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 let s:orgbufnr = winbufnr(0)
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
638 let s:origwin_stl = &l:stl
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 if expand("%") == ""
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
640 if exists('g:html_diff_win_num')
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
641 exec 'new Untitled_win'.g:html_diff_win_num.'.'.(s:settings.use_xhtml ? 'x' : '').'html'
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
642 else
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
643 exec 'new Untitled.'.(s:settings.use_xhtml ? 'x' : '').'html'
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
644 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 else
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
646 exec 'new %.'.(s:settings.use_xhtml ? 'x' : '').'html'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 endif
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
648
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
649 " Resize the new window to very small in order to make it draw faster
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
650 let s:old_winheight = winheight(0)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
651 let s:old_winfixheight = &l:winfixheight
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
652 if s:old_winheight > 2
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
653 resize 1 " leave enough room to view one line at a time
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
654 norm! G
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
655 norm! zt
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
656 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
657 setlocal winfixheight
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
658
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
659 let s:newwin_stl = &l:stl
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
660
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
661 " on the new window, set the least time-consuming fold method
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
662 let s:old_fen = &foldenable
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
663 setlocal foldmethod=manual
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
664 setlocal nofoldenable
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
665
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 let s:newwin = winnr()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 let s:orgwin = bufwinnr(s:orgbufnr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
669 setlocal modifiable
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 %d
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 let s:old_paste = &paste
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 set paste
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 let s:old_magic = &magic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 set magic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675
2642
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
676 " set the fileencoding to match the charset we'll be using
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
677 let &l:fileencoding=s:settings.vim_encoding
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
678
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
679 " According to http://www.w3.org/TR/html4/charset.html#doc-char-set, the byte
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
680 " order mark is highly recommend on the web when using multibyte encodings. But,
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
681 " it is not a good idea to include it on UTF-8 files. Otherwise, let Vim
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
682 " determine when it is actually inserted.
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
683 if s:settings.vim_encoding == 'utf-8'
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
684 setlocal nobomb
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
685 else
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
686 setlocal bomb
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
687 endif
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
688
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
689 let s:lines = []
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
690
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
691 if s:settings.use_xhtml
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
692 if s:settings.encoding != ""
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
693 call add(s:lines, "<?xml version=\"1.0\" encoding=\"" . s:settings.encoding . "\"?>")
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 34
diff changeset
694 else
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
695 call add(s:lines, "<?xml version=\"1.0\"?>")
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 34
diff changeset
696 endif
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
697 let s:tag_close = ' />'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 else
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
699 let s:tag_close = '>'
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
700 endif
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
701
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
702 let s:HtmlSpace = ' '
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 575
diff changeset
703 let s:LeadingSpace = ' '
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
704 let s:HtmlEndline = ''
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
705 if s:settings.no_pre
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
706 let s:HtmlEndline = '<br' . s:tag_close
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
707 let s:LeadingSpace = s:settings.use_xhtml ? '&#160;' : '&nbsp;'
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 575
diff changeset
708 let s:HtmlSpace = '\' . s:LeadingSpace
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 " HTML header, with the title and generator ;-). Left free space for the CSS,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 " to be filled at the end.
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
713 call extend(s:lines, [
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
714 \ "<html>",
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
715 \ "<head>"])
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
716 " include encoding as close to the top as possible, but only if not already
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
717 " contained in XML information (to avoid haggling over content type)
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
718 if s:settings.encoding != "" && !s:settings.use_xhtml
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
719 call add(s:lines, "<meta http-equiv=\"content-type\" content=\"text/html; charset=" . s:settings.encoding . '"' . s:tag_close)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 endif
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
721 call extend(s:lines, [
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
722 \ ("<title>".expand("%:p:~")."</title>"),
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
723 \ ("<meta name=\"Generator\" content=\"Vim/".v:version/100.".".v:version%100.'"'.s:tag_close),
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
724 \ ("<meta name=\"plugin-version\" content=\"".g:loaded_2html_plugin.'"'.s:tag_close)
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
725 \ ])
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
726 call add(s:lines, '<meta name="syntax" content="'.s:current_syntax.'"'.s:tag_close)
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
727 call add(s:lines, '<meta name="settings" content="'.
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
728 \ join(filter(keys(s:settings),'s:settings[v:val]'),',').
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
729 \ ',prevent_copy='.s:settings.prevent_copy.
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
730 \ '"'.s:tag_close)
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
731 call add(s:lines, '<meta name="colorscheme" content="'.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
732 \ (exists('g:colors_name')
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
733 \ ? g:colors_name
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
734 \ : 'none'). '"'.s:tag_close)
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
735
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
736 if s:settings.use_css
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
737 if s:settings.dynamic_folds
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
738 if s:settings.hover_unfold
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
739 " if we are doing hover_unfold, use css 2 with css 1 fallback for IE6
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
740 call extend(s:lines, [
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
741 \ "<style type=\"text/css\">",
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
742 \ s:settings.use_xhtml ? "" : "<!--",
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
743 \ ".FoldColumn { text-decoration: none; white-space: pre; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
744 \ "",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
745 \ "body * { margin: 0; padding: 0; }", "",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
746 \ ".open-fold > .Folded { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
747 \ ".open-fold > .fulltext { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
748 \ ".closed-fold > .fulltext { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
749 \ ".closed-fold > .Folded { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
750 \ "",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
751 \ ".open-fold > .toggle-open { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
752 \ ".open-fold > .toggle-closed { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
753 \ ".closed-fold > .toggle-open { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
754 \ ".closed-fold > .toggle-closed { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
755 \ "", "",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
756 \ '/* opening a fold while hovering won''t be supported by IE6 and other',
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
757 \ "similar browsers, but it should fail gracefully. */",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
758 \ ".closed-fold:hover > .fulltext { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
759 \ ".closed-fold:hover > .toggle-filler { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
760 \ ".closed-fold:hover > .Folded { display: none; }",
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
761 \ s:settings.use_xhtml ? "" : '-->',
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
762 \ '</style>'])
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
763 " TODO: IE7 doesn't *actually* support XHTML, maybe we should remove this.
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
764 " But if it's served up as tag soup, maybe the following will work, so
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
765 " leave it in for now.
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
766 call extend(s:lines, [
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
767 \ "<!--[if lt IE 7]><style type=\"text/css\">",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
768 \ ".open-fold .Folded { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
769 \ ".open-fold .fulltext { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
770 \ ".open-fold .toggle-open { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
771 \ ".closed-fold .toggle-closed { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
772 \ "",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
773 \ ".closed-fold .fulltext { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
774 \ ".closed-fold .Folded { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
775 \ ".closed-fold .toggle-open { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
776 \ ".closed-fold .toggle-closed { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
777 \ "</style>",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
778 \ "<![endif]-->",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
779 \])
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
780 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
781 " if we aren't doing hover_unfold, use CSS 1 only
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
782 call extend(s:lines, [
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
783 \ "<style type=\"text/css\">",
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
784 \ s:settings.use_xhtml ? "" :"<!--",
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
785 \ ".FoldColumn { text-decoration: none; white-space: pre; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
786 \ ".open-fold .Folded { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
787 \ ".open-fold .fulltext { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
788 \ ".open-fold .toggle-open { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
789 \ ".closed-fold .toggle-closed { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
790 \ "",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
791 \ ".closed-fold .fulltext { display: none; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
792 \ ".closed-fold .Folded { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
793 \ ".closed-fold .toggle-open { display: inline; }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
794 \ ".closed-fold .toggle-closed { display: none; }",
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
795 \ s:settings.use_xhtml ? "" : '-->',
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
796 \ '</style>'
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
797 \])
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
798 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
799 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
800 " if we aren't doing any dynamic folding, no need for any special rules
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
801 call extend(s:lines, [
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
802 \ "<style type=\"text/css\">",
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
803 \ s:settings.use_xhtml ? "" : "<!--",
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
804 \ s:settings.use_xhtml ? "" : '-->',
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
805 \ "</style>",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
806 \])
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
807 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
809
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
810 " insert script tag; javascript is always needed for the line number
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
811 " normalization for URL hashes
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
812 call extend(s:lines, [
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
813 \ "",
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
814 \ "<script type='text/javascript'>",
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
815 \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"])
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
816
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
817 " insert javascript to toggle folds open and closed
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
818 if s:settings.dynamic_folds
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
819 call extend(s:lines, [
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
820 \ "",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
821 \ "function toggleFold(objID)",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
822 \ "{",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
823 \ " var fold;",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
824 \ " fold = document.getElementById(objID);",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
825 \ " if(fold.className == 'closed-fold')",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
826 \ " {",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
827 \ " fold.className = 'open-fold';",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
828 \ " }",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
829 \ " else if (fold.className == 'open-fold')",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
830 \ " {",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
831 \ " fold.className = 'closed-fold';",
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
832 \ " }",
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
833 \ "}"
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
834 \ ])
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
835 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
836
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
837 if s:settings.line_ids
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
838 " insert javascript to get IDs from line numbers, and to open a fold before
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
839 " jumping to any lines contained therein
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
840 call extend(s:lines, [
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
841 \ "",
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
842 \ "/* function to open any folds containing a jumped-to line before jumping to it */",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
843 \ "function JumpToLine()",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
844 \ "{",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
845 \ " var lineNum;",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
846 \ " lineNum = window.location.hash;",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
847 \ " lineNum = lineNum.substr(1); /* strip off '#' */",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
848 \ "",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
849 \ " if (lineNum.indexOf('L') == -1) {",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
850 \ " lineNum = 'L'+lineNum;",
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
851 \ " }",
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
852 \ " lineElem = document.getElementById(lineNum);"
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
853 \ ])
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
854 if s:settings.dynamic_folds
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
855 call extend(s:lines, [
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
856 \ "",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
857 \ " /* navigate upwards in the DOM tree to open all folds containing the line */",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
858 \ " var node = lineElem;",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
859 \ " while (node && node.id != 'vimCodeElement".s:settings.id_suffix."')",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
860 \ " {",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
861 \ " if (node.className == 'closed-fold')",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
862 \ " {",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
863 \ " node.className = 'open-fold';",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
864 \ " }",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
865 \ " node = node.parentNode;",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
866 \ " }",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
867 \ ])
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
868 endif
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
869 call extend(s:lines, [
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
870 \ " /* Always jump to new location even if the line was hidden inside a fold, or",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
871 \ " * we corrected the raw number to a line ID.",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
872 \ " */",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
873 \ " if (lineElem) {",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
874 \ " lineElem.scrollIntoView(true);",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
875 \ " }",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
876 \ " return true;",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
877 \ "}",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
878 \ "if ('onhashchange' in window) {",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
879 \ " window.onhashchange = JumpToLine;",
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
880 \ "}"
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
881 \ ])
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
882 endif
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
883
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
884 " Small text columns like the foldcolumn and line number column need a weird
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
885 " hack to work around Webkit's and (in versions prior to 9) IE's lack of support
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
886 " for the 'ch' unit without messing up Opera, which also doesn't support it but
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
887 " works anyway.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
888 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
889 " The problem is that without the 'ch' unit, it is not possible to specify a
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
890 " size of an <input> in terms of character widths. Only Opera seems to do the
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
891 " "sensible" thing and make the <input> sized to fit exactly as many characters
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
892 " as specified by its "size" attribute, but the spec actually says "at least
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
893 " wide enough to fit 'size' characters", so the other browsers are technically
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
894 " correct as well.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
895 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
896 " Anyway, this leads to two diffculties:
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
897 " 1. The foldcolumn is made up of multiple elements side-by-side with
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
898 " different sizes, each of which has their own extra padding added. Thus, a
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
899 " column made up of one item of size 1 and another of size 2 would not
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
900 " necessarily be equal in size to another line's foldcolumn with a single
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
901 " item of size 3.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
902 " 2. The extra padding added to the <input> elements adds up to make the
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
903 " foldcolumn and line number column too wide, especially in Webkit
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
904 " browsers.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
905 "
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
906 " So, the full workaround is:
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
907 " 1. Define a default size in em, equal to the number of characters in the
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
908 " input element, in case javascript is disabled and the browser does not
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
909 " support the 'ch' unit. Unfortunately this makes Opera no longer work
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
910 " properly without javascript. 1em per character is much too wide but it
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
911 " looks better in webkit browsers than unaligned columns.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
912 " 2. Insert the following javascript to run at page load, which checks for the
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
913 " width of a single character (in an extraneous page element inserted
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
914 " before the page title, and set to hidden) and compares it to the width of
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
915 " another extra <input> element with only one character. If the width
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
916 " matches, the script does nothing more, but if not, it will figure out the
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
917 " fraction of an em unit which would correspond with a ch unit if there
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
918 " were one, and set the containing element (<pre> or <div>) to a class with
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
919 " pre-defined rules which is closest to that fraction of an em. Rules are
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
920 " defined from 0.05 em to 1em per ch.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
921 if !empty(s:settings.prevent_copy)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
922 call extend(s:lines, [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
923 \ '',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
924 \ '/* simulate a "ch" unit by asking the browser how big a zero character is */',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
925 \ 'function FixCharWidth() {',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
926 \ ' /* get the hidden element which gives the width of a single character */',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
927 \ ' var goodWidth = document.getElementById("oneCharWidth").clientWidth;',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
928 \ ' /* get all input elements, we''ll filter on class later */',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
929 \ ' var inputTags = document.getElementsByTagName("input");',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
930 \ ' var ratio = 5;',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
931 \ ' var inputWidth = document.getElementById("oneInputWidth").clientWidth;',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
932 \ ' var emWidth = document.getElementById("oneEmWidth").clientWidth;',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
933 \ ' if (inputWidth > goodWidth) {',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
934 \ ' while (ratio < 100*goodWidth/emWidth && ratio < 100) {',
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
935 \ ' ratio += 5;',
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
936 \ ' }',
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
937 \ ' document.getElementById("vimCodeElement'.s:settings.id_suffix.'").className = "em"+ratio;',
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
938 \ ' }',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
939 \ '}'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
940 \ ])
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
941 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
942
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
943 " insert script closing tag
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
944 call extend(s:lines, [
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
945 \ '',
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
946 \ s:settings.use_xhtml ? '//]]>' : '-->',
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
947 \ "</script>"
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
948 \ ])
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
949
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
950 call extend(s:lines, ["</head>"])
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
951 if !empty(s:settings.prevent_copy)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
952 call extend(s:lines,
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
953 \ ["<body onload='FixCharWidth();".(s:settings.line_ids ? " JumpToLine();" : "")."'>",
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
954 \ "<!-- hidden divs used by javascript to get the width of a char -->",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
955 \ "<div id='oneCharWidth'>0</div>",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
956 \ "<div id='oneInputWidth'><input size='1' value='0'".s:tag_close."</div>",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
957 \ "<div id='oneEmWidth' style='width: 1em;'></div>"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
958 \ ])
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
959 else
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
960 call extend(s:lines, ["<body".(s:settings.line_ids ? " onload='JumpToLine();'" : "").">"])
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
961 endif
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
962 if s:settings.no_pre
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
963 " if we're not using CSS we use a font tag which can't have a div inside
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
964 if s:settings.use_css
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
965 call extend(s:lines, ["<div id='vimCodeElement".s:settings.id_suffix."'>"])
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
966 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 else
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
968 call extend(s:lines, ["<pre id='vimCodeElement".s:settings.id_suffix."'>"])
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 exe s:orgwin . "wincmd w"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
973 " caches of style data
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
974 " initialize to include line numbers if using them
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
975 if s:settings.number_lines
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
976 let s:stylelist = { s:LINENR_ID : ".LineNr { " . s:CSS1( s:LINENR_ID ) . "}" }
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
977 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
978 let s:stylelist = {}
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
979 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
980 let s:diffstylelist = {
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
981 \ s:DIFF_A_ID : ".DiffAdd { " . s:CSS1( s:DIFF_A_ID ) . "}",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
982 \ s:DIFF_C_ID : ".DiffChange { " . s:CSS1( s:DIFF_C_ID ) . "}",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
983 \ s:DIFF_D_ID : ".DiffDelete { " . s:CSS1( s:DIFF_D_ID ) . "}",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
984 \ s:DIFF_T_ID : ".DiffText { " . s:CSS1( s:DIFF_T_ID ) . "}"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
985 \ }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
987 " set up progress bar in the status line
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
988 if !s:settings.no_progress
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
989 " ProgressBar Indicator
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
990 let s:progressbar={}
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
991
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
992 " Progessbar specific functions
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
993 func! s:ProgressBar(title, max_value, winnr)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
994 let pgb=copy(s:progressbar)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
995 let pgb.title = a:title.' '
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
996 let pgb.max_value = a:max_value
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
997 let pgb.winnr = a:winnr
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
998 let pgb.cur_value = 0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
999 let pgb.items = { 'title' : { 'color' : 'Statusline' },
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1000 \'bar' : { 'color' : 'Statusline' , 'fillcolor' : 'DiffDelete' , 'bg' : 'Statusline' } ,
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1001 \'counter' : { 'color' : 'Statusline' } }
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1002 let pgb.last_value = 0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1003 let pgb.needs_redraw = 0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1004 " Note that you must use len(split) instead of len() if you want to use
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1005 " unicode in title.
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1006 "
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1007 " Subtract 3 for spacing around the title.
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1008 " Subtract 4 for the percentage display.
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1009 " Subtract 2 for spacing before this.
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1010 " Subtract 2 more for the '|' on either side of the progress bar
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1011 let pgb.subtractedlen=len(split(pgb.title, '\zs'))+3+4+2+2
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1012 let pgb.max_len = 0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1013 set laststatus=2
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1014 return pgb
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1015 endfun
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1016
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1017 " Function: progressbar.calculate_ticks() {{{1
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1018 func! s:progressbar.calculate_ticks(pb_len)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1019 if a:pb_len<=0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1020 let pb_len = 100
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1021 else
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1022 let pb_len = a:pb_len
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1023 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1024 let self.progress_ticks = map(range(pb_len+1), "v:val * self.max_value / pb_len")
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1025 endfun
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1026
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1027 "Function: progressbar.paint()
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1028 func! s:progressbar.paint()
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1029 " Recalculate widths.
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1030 let max_len = winwidth(self.winnr)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1031 let pb_len = 0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1032 " always true on first call because of initial value of self.max_len
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1033 if max_len != self.max_len
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1034 let self.max_len = max_len
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1035
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1036 " Progressbar length
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1037 let pb_len = max_len - self.subtractedlen
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1038
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1039 call self.calculate_ticks(pb_len)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1040
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1041 let self.needs_redraw = 1
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1042 let cur_value = 0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1043 let self.pb_len = pb_len
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1044 else
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1045 " start searching at the last found index to make the search for the
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1046 " appropriate tick value normally take 0 or 1 comparisons
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1047 let cur_value = self.last_value
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1048 let pb_len = self.pb_len
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1049 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1050
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1051 let cur_val_max = pb_len > 0 ? pb_len : 100
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1052
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1053 " find the current progress bar position based on precalculated thresholds
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1054 while cur_value < cur_val_max && self.cur_value > self.progress_ticks[cur_value]
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1055 let cur_value += 1
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1056 endwhile
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1057
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1058 " update progress bar
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1059 if self.last_value != cur_value || self.needs_redraw || self.cur_value == self.max_value
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1060 let self.needs_redraw = 1
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1061 let self.last_value = cur_value
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1062
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1063 let t_color = self.items.title.color
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1064 let b_fcolor = self.items.bar.fillcolor
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1065 let b_color = self.items.bar.color
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1066 let c_color = self.items.counter.color
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1067
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1068 let stl = "%#".t_color."#%-( ".self.title." %)".
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1069 \"%#".b_color."#".
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1070 \(pb_len>0 ?
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1071 \ ('|%#'.b_fcolor."#%-(".repeat(" ",cur_value)."%)".
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1072 \ '%#'.b_color."#".repeat(" ",pb_len-cur_value)."|"):
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1073 \ ('')).
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1074 \"%=%#".c_color."#%( ".printf("%3.d ",100*self.cur_value/self.max_value)."%% %)"
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1075 call setwinvar(self.winnr, '&stl', stl)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1076 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1077 endfun
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1078
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1079 func! s:progressbar.incr( ... )
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1080 let self.cur_value += (a:0 ? a:1 : 1)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1081 " if we were making a general-purpose progress bar, we'd need to limit to a
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1082 " lower limit as well, but since we always increment with a positive value
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1083 " in this script, we only need limit the upper value
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1084 let self.cur_value = (self.cur_value > self.max_value ? self.max_value : self.cur_value)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1085 call self.paint()
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1086 endfun
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1087 " }}}
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1088 if s:settings.dynamic_folds
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1089 " to process folds we make two passes through each line
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1090 let s:pgb = s:ProgressBar("Processing folds:", line('$')*2, s:orgwin)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1091 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1092 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1093
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1094 " First do some preprocessing for dynamic folding. Do this for the entire file
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1095 " so we don't accidentally start within a closed fold or something.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1096 let s:allfolds = []
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1097
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1098 if s:settings.dynamic_folds
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1099 let s:lnum = 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1100 let s:end = line('$')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1101 " save the fold text and set it to the default so we can find fold levels
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1102 let s:foldtext_save = &foldtext
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1103 setlocal foldtext&
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1104
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1105 " we will set the foldcolumn in the html to the greater of the maximum fold
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1106 " level and the current foldcolumn setting
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1107 let s:foldcolumn = &foldcolumn
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1108
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1109 " get all info needed to describe currently closed folds
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1110 while s:lnum <= s:end
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1111 if foldclosed(s:lnum) == s:lnum
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1112 " default fold text has '+-' and then a number of dashes equal to fold
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1113 " level, so subtract 2 from index of first non-dash after the dashes
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1114 " in order to get the fold level of the current fold
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1115 let s:level = match(foldtextresult(s:lnum), '+-*\zs[^-]') - 2
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1116 " store fold info for later use
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1117 let s:newfold = {'firstline': s:lnum, 'lastline': foldclosedend(s:lnum), 'level': s:level,'type': "closed-fold"}
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1118 call add(s:allfolds, s:newfold)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1119 " open the fold so we can find any contained folds
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1120 execute s:lnum."foldopen"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1121 else
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1122 if !s:settings.no_progress
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1123 call s:pgb.incr()
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1124 if s:pgb.needs_redraw
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1125 redrawstatus
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1126 let s:pgb.needs_redraw = 0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1127 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1128 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1129 let s:lnum = s:lnum + 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1130 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1131 endwhile
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1132
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1133 " close all folds to get info for originally open folds
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1134 silent! %foldclose!
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1135 let s:lnum = 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1136
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1137 " the originally open folds will be all folds we encounter that aren't
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1138 " already in the list of closed folds
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1139 while s:lnum <= s:end
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1140 if foldclosed(s:lnum) == s:lnum
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1141 " default fold text has '+-' and then a number of dashes equal to fold
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1142 " level, so subtract 2 from index of first non-dash after the dashes
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1143 " in order to get the fold level of the current fold
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1144 let s:level = match(foldtextresult(s:lnum), '+-*\zs[^-]') - 2
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1145 let s:newfold = {'firstline': s:lnum, 'lastline': foldclosedend(s:lnum), 'level': s:level,'type': "closed-fold"}
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1146 " only add the fold if we don't already have it
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1147 if empty(s:allfolds) || index(s:allfolds, s:newfold) == -1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1148 let s:newfold.type = "open-fold"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1149 call add(s:allfolds, s:newfold)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1150 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1151 " open the fold so we can find any contained folds
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1152 execute s:lnum."foldopen"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1153 else
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1154 if !s:settings.no_progress
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1155 call s:pgb.incr()
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1156 if s:pgb.needs_redraw
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1157 redrawstatus
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1158 let s:pgb.needs_redraw = 0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1159 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1160 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1161 let s:lnum = s:lnum + 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1162 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1163 endwhile
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1164
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1165 " sort the folds so that we only ever need to look at the first item in the
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1166 " list of folds
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1167 call sort(s:allfolds, "s:FoldCompare")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1168
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1169 let &l:foldtext = s:foldtext_save
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1170 unlet s:foldtext_save
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1171
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1172 " close all folds again so we can get the fold text as we go
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1173 silent! %foldclose!
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1174
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1175 " Go through and remove folds we don't need to (or cannot) process in the
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1176 " current conversion range
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1177 "
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1178 " If a fold is removed which contains other folds, which are included, we need
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1179 " to adjust the level of the included folds as used by the conversion logic
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1180 " (avoiding special cases is good)
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1181 "
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1182 " Note any time we remove a fold, either all of the included folds are in it,
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1183 " or none of them, because we only remove a fold if neither its start nor its
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1184 " end are within the conversion range.
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1185 let leveladjust = 0
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1186 for afold in s:allfolds
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1187 let removed = 0
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1188 if exists("g:html_start_line") && exists("g:html_end_line")
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1189 if afold.firstline < g:html_start_line
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1190 if afold.lastline <= g:html_end_line && afold.lastline >= g:html_start_line
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1191 " if a fold starts before the range to convert but stops within the
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1192 " range, we need to include it. Make it start on the first converted
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1193 " line.
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1194 let afold.firstline = g:html_start_line
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1195 else
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1196 " if the fold lies outside the range or the start and stop enclose
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1197 " the entire range, don't bother parsing it
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1198 call remove(s:allfolds, index(s:allfolds, afold))
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1199 let removed = 1
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1200 if afold.lastline > g:html_end_line
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1201 let leveladjust += 1
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1202 endif
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1203 endif
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1204 elseif afold.firstline > g:html_end_line
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1205 " If the entire fold lies outside the range we need to remove it.
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1206 call remove(s:allfolds, index(s:allfolds, afold))
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1207 let removed = 1
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1208 endif
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1209 elseif exists("g:html_start_line")
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1210 if afold.firstline < g:html_start_line
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1211 " if there is no last line, but there is a first line, the end of the
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1212 " fold will always lie within the region of interest, so keep it
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1213 let afold.firstline = g:html_start_line
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1214 endif
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1215 elseif exists("g:html_end_line")
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1216 " if there is no first line we default to the first line in the buffer so
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1217 " the fold start will always be included if the fold itself is included.
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1218 " If however the entire fold lies outside the range we need to remove it.
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1219 if afold.firstline > g:html_end_line
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1220 call remove(s:allfolds, index(s:allfolds, afold))
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1221 let removed = 1
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1222 endif
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1223 endif
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1224 if !removed
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1225 let afold.level -= leveladjust
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1226 if afold.level+1 > s:foldcolumn
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1227 let s:foldcolumn = afold.level+1
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1228 endif
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1229 endif
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1230 endfor
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1231
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1232 " if we've removed folds containing the conversion range from processing,
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1233 " getting foldtext as we go won't know to open the removed folds, so the
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1234 " foldtext would be wrong; open them now.
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1235 "
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1236 " Note that only when a start and an end line is specified will a fold
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1237 " containing the current range ever be removed.
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1238 while leveladjust > 0
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1239 exe g:html_start_line."foldopen"
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1240 let leveladjust -= 1
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2788
diff changeset
1241 endwhile
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1242 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1243
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1244 " Now loop over all lines in the original text to convert to html.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 " Use html_start_line and html_end_line if they are set.
2304
a59e6ac5ed28 When the buffer is in diff mode, have :TOhtml create HTML to show the diff
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
1246 if exists("g:html_start_line")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 let s:lnum = html_start_line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 if s:lnum < 1 || s:lnum > line("$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 let s:lnum = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 let s:lnum = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 endif
2304
a59e6ac5ed28 When the buffer is in diff mode, have :TOhtml create HTML to show the diff
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
1254 if exists("g:html_end_line")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 let s:end = html_end_line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 if s:end < s:lnum || s:end > line("$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 let s:end = line("$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 let s:end = line("$")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1263 " stack to keep track of all the folds containing the current line
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1264 let s:foldstack = []
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1265
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1266 if !s:settings.no_progress
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1267 let s:pgb = s:ProgressBar("Processing lines:", s:end - s:lnum + 1, s:orgwin)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1268 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1269
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1270 if s:settings.number_lines
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1271 let s:margin = strlen(s:end) + 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1272 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1273 let s:margin = 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1274 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1275
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1276 if has('folding') && !s:settings.ignore_folding
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1277 let s:foldfillchar = &fillchars[matchend(&fillchars, 'fold:')]
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1278 if s:foldfillchar == ''
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1279 let s:foldfillchar = '-'
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1280 endif
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1281 endif
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1282 let s:difffillchar = &fillchars[matchend(&fillchars, 'diff:')]
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1283 if s:difffillchar == ''
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1284 let s:difffillchar = '-'
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1285 endif
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1286
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1287 let s:foldId = 0
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1288
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1289 if !s:settings.expand_tabs
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1290 " If keeping tabs, add them to printable characters so we keep them when
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1291 " formatting text (strtrans() doesn't replace printable chars)
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1292 let s:old_isprint = &isprint
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1293 setlocal isprint+=9
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1294 endif
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1295
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 while s:lnum <= s:end
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297
32
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1298 " If there are filler lines for diff mode, show these above the line.
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1299 let s:filler = diff_filler(s:lnum)
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1300 if s:filler > 0
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1301 let s:n = s:filler
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1302 while s:n > 0
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1303 let s:new = repeat(s:difffillchar, 3)
32
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1304
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1305 if s:n > 2 && s:n < s:filler && !s:settings.whole_filler
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1306 let s:new = s:new . " " . s:filler . " inserted lines "
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1307 let s:n = 2
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1308 endif
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1309
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1310 if !s:settings.no_pre
856
8cd729851562 updated for version 7.0g
vimboss
parents: 837
diff changeset
1311 " HTML line wrapping is off--go ahead and fill to the margin
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1312 " TODO: what about when CSS wrapping is turned on?
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1313 let s:new = s:new . repeat(s:difffillchar, &columns - strlen(s:new) - s:margin)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1314 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1315 let s:new = s:new . repeat(s:difffillchar, 3)
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1316 endif
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1317
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1318 let s:new = s:HtmlFormat_d(s:new, s:DIFF_D_ID, 0)
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1319 if s:settings.number_lines
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1320 " Indent if line numbering is on. Indent gets style of line number
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1321 " column.
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1322 let s:new = s:HtmlFormat_n(repeat(' ', s:margin), s:LINENR_ID, 0, 0) . s:new
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1323 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1324 if s:settings.dynamic_folds && !s:settings.no_foldcolumn && s:foldcolumn > 0
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1325 " Indent for foldcolumn if there is one. Assume it's empty, there should
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1326 " not be a fold for deleted lines in diff mode.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1327 let s:new = s:FoldColumn_fill() . s:new
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1328 endif
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1329 call add(s:lines, s:new.s:HtmlEndline)
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1330
32
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1331 let s:n = s:n - 1
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1332 endwhile
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1333 unlet s:n
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1334 endif
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1335 unlet s:filler
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1336
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1337 " Start the line with the line number.
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1338 if s:settings.number_lines
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1339 let s:numcol = repeat(' ', s:margin - 1 - strlen(s:lnum)) . s:lnum . ' '
32
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1340 endif
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1341
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1342 let s:new = ""
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1343
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1344 if has('folding') && !s:settings.ignore_folding && foldclosed(s:lnum) > -1 && !s:settings.dynamic_folds
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1345 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1346 " This is the beginning of a folded block (with no dynamic folding)
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1347 let s:new = foldtextresult(s:lnum)
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1348 if !s:settings.no_pre
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1349 " HTML line wrapping is off--go ahead and fill to the margin
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1350 let s:new = s:new . repeat(s:foldfillchar, &columns - strlen(s:new))
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1351 endif
856
8cd729851562 updated for version 7.0g
vimboss
parents: 837
diff changeset
1352
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1353 " put numcol in a separate group for sake of unselectable text
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1354 let s:new = (s:settings.number_lines ? s:HtmlFormat_n(s:numcol, s:FOLDED_ID, 0, s:lnum): "") . s:HtmlFormat_t(s:new, s:FOLDED_ID, 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355
856
8cd729851562 updated for version 7.0g
vimboss
parents: 837
diff changeset
1356 " Skip to the end of the fold
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1357 let s:new_lnum = foldclosedend(s:lnum)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1358
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1359 if !s:settings.no_progress
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1360 call s:pgb.incr(s:new_lnum - s:lnum)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1361 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1362
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1363 let s:lnum = s:new_lnum
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1364
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1365 else
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1366 "
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1367 " A line that is not folded, or doing dynamic folding.
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1368 "
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1369 let s:line = getline(s:lnum)
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1370 let s:len = strlen(s:line)
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1371
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1372 if s:settings.dynamic_folds
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1373 " First insert a closing for any open folds that end on this line
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1374 while !empty(s:foldstack) && get(s:foldstack,0).lastline == s:lnum-1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1375 let s:new = s:new."</span></span>"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1376 call remove(s:foldstack, 0)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1377 endwhile
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1378
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1379 " Now insert an opening for any new folds that start on this line
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1380 let s:firstfold = 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1381 while !empty(s:allfolds) && get(s:allfolds,0).firstline == s:lnum
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1382 let s:foldId = s:foldId + 1
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1383 let s:new .= "<span id='"
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1384 let s:new .= (exists('g:html_diff_win_num') ? "win".g:html_diff_win_num : "")
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
1385 let s:new .= "fold".s:foldId.s:settings.id_suffix."' class='".s:allfolds[0].type."'>"
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1386
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1387
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1388 " Unless disabled, add a fold column for the opening line of a fold.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1389 "
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1390 " Note that dynamic folds require using css so we just use css to take
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1391 " care of the leading spaces rather than using &nbsp; in the case of
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1392 " html_no_pre to make it easier
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1393 if !s:settings.no_foldcolumn
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1394 " add fold column that can open the new fold
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1395 if s:allfolds[0].level > 1 && s:firstfold
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1396 let s:new = s:new . s:FoldColumn_build('|', s:allfolds[0].level - 1, 0, "",
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
1397 \ 'toggle-open FoldColumn','javascript:toggleFold("fold'.s:foldstack[0].id.s:settings.id_suffix.'");')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1398 endif
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1399 " add the filler spaces separately from the '+' char so that it can be
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1400 " shown/hidden separately during a hover unfold
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1401 let s:new = s:new . s:FoldColumn_build("+", 1, 0, "",
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
1402 \ 'toggle-open FoldColumn', 'javascript:toggleFold("fold'.s:foldId.s:settings.id_suffix.'");')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1403 " If this is not the last fold we're opening on this line, we need
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1404 " to keep the filler spaces hidden if the fold is opened by mouse
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1405 " hover. If it is the last fold to open in the line, we shouldn't hide
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1406 " them, so don't apply the toggle-filler class.
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1407 let s:new = s:new . s:FoldColumn_build(" ", 1, s:foldcolumn - s:allfolds[0].level - 1, "",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1408 \ 'toggle-open FoldColumn'. (get(s:allfolds, 1, {'firstline': 0}).firstline == s:lnum ?" toggle-filler" :""),
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
1409 \ 'javascript:toggleFold("fold'.s:foldId.s:settings.id_suffix.'");')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1410
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1411 " add fold column that can close the new fold
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1412 " only add extra blank space if we aren't opening another fold on the
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1413 " same line
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1414 if get(s:allfolds, 1, {'firstline': 0}).firstline != s:lnum
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1415 let s:extra_space = s:foldcolumn - s:allfolds[0].level
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1416 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1417 let s:extra_space = 0
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1418 endif
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1419 if s:firstfold
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1420 " the first fold in a line has '|' characters from folds opened in
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1421 " previous lines, before the '-' for this fold
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1422 let s:new .= s:FoldColumn_build('|', s:allfolds[0].level - 1, s:extra_space, '-',
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
1423 \ 'toggle-closed FoldColumn', 'javascript:toggleFold("fold'.s:foldId.s:settings.id_suffix.'");')
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1424 else
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1425 " any subsequent folds in the line only add a single '-'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1426 let s:new = s:new . s:FoldColumn_build("-", 1, s:extra_space, "",
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
1427 \ 'toggle-closed FoldColumn', 'javascript:toggleFold("fold'.s:foldId.s:settings.id_suffix.'");')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1428 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1429 let s:firstfold = 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1430 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1431
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1432 " Add fold text, moving the span ending to the next line so collapsing
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1433 " of folds works correctly.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1434 " Put numcol in a separate group for sake of unselectable text.
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1435 let s:new = s:new . (s:settings.number_lines ? s:HtmlFormat_n(s:numcol, s:FOLDED_ID, 0, 0) : "") . substitute(s:HtmlFormat_t(foldtextresult(s:lnum), s:FOLDED_ID, 0), '</span>', s:HtmlEndline.'\n\0', '')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1436 let s:new = s:new . "<span class='fulltext'>"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1437
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1438 " open the fold now that we have the fold text to allow retrieval of
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1439 " fold text for subsequent folds
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1440 execute s:lnum."foldopen"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1441 call insert(s:foldstack, remove(s:allfolds,0))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1442 let s:foldstack[0].id = s:foldId
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1443 endwhile
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1444
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1445 " Unless disabled, add a fold column for other lines.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1446 "
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1447 " Note that dynamic folds require using css so we just use css to take
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1448 " care of the leading spaces rather than using &nbsp; in the case of
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1449 " html_no_pre to make it easier
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1450 if !s:settings.no_foldcolumn
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1451 if empty(s:foldstack)
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1452 " add the empty foldcolumn for unfolded lines if there is a fold
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1453 " column at all
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1454 if s:foldcolumn > 0
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1455 let s:new = s:new . s:FoldColumn_fill()
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1456 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1457 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1458 " add the fold column for folds not on the opening line
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1459 if get(s:foldstack, 0).firstline < s:lnum
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1460 let s:new = s:new . s:FoldColumn_build('|', s:foldstack[0].level, s:foldcolumn - s:foldstack[0].level, "",
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
1461 \ 'FoldColumn', 'javascript:toggleFold("fold'.s:foldstack[0].id.s:settings.id_suffix.'");')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1462 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1463 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1464 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1465 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1466
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1467 " Now continue with the unfolded line text
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1468 if s:settings.number_lines
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1469 let s:new = s:new . s:HtmlFormat_n(s:numcol, s:LINENR_ID, 0, s:lnum)
5003
ad6996a23e3e Updated runtime files. New version of TOhtml plugin.
Bram Moolenaar <bram@vim.org>
parents: 4681
diff changeset
1470 elseif s:settings.line_ids
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1471 let s:new = s:new . s:HtmlFormat_n("", s:LINENR_ID, 0, s:lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 endif
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1473
32
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1474 " Get the diff attribute, if any.
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1475 let s:diffattr = diff_hlID(s:lnum, 1)
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1476
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1477 " initialize conceal info to act like not concealed, just in case
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1478 let s:concealinfo = [0, '']
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1479
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1480 " Loop over each character in the line
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1481 let s:col = 1
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1482
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1483 " most of the time we won't use the diff_id, initialize to zero
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1484 let s:diff_id = 0
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1485
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1486 while s:col <= s:len || (s:col == 1 && s:diffattr)
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1487 let s:startcol = s:col " The start column for processing text
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1488 if !s:settings.ignore_conceal && has('conceal')
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1489 let s:concealinfo = synconcealed(s:lnum, s:col)
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1490 endif
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1491 if !s:settings.ignore_conceal && s:concealinfo[0]
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1492 let s:col = s:col + 1
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1493 " Speed loop (it's small - that's the trick)
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1494 " Go along till we find a change in the match sequence number (ending
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1495 " the specific concealed region) or until there are no more concealed
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1496 " characters.
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1497 while s:col <= s:len && s:concealinfo == synconcealed(s:lnum, s:col) | let s:col = s:col + 1 | endwhile
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1498 elseif s:diffattr
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1499 let s:diff_id = diff_hlID(s:lnum, s:col)
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1500 let s:id = synID(s:lnum, s:col, 1)
32
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1501 let s:col = s:col + 1
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1502 " Speed loop (it's small - that's the trick)
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1503 " Go along till we find a change in hlID
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1504 while s:col <= s:len && s:id == synID(s:lnum, s:col, 1)
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1505 \ && s:diff_id == diff_hlID(s:lnum, s:col) |
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1506 \ let s:col = s:col + 1 |
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1507 \ endwhile
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1508 if s:len < &columns && !s:settings.no_pre
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1509 " Add spaces at the end of the raw text line to extend the changed
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1510 " line to the full width.
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1511 let s:line = s:line . repeat(' ', &columns - virtcol([s:lnum, s:len]) - s:margin)
856
8cd729851562 updated for version 7.0g
vimboss
parents: 837
diff changeset
1512 let s:len = &columns
8cd729851562 updated for version 7.0g
vimboss
parents: 837
diff changeset
1513 endif
32
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1514 else
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1515 let s:id = synID(s:lnum, s:col, 1)
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1516 let s:col = s:col + 1
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1517 " Speed loop (it's small - that's the trick)
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1518 " Go along till we find a change in synID
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1519 while s:col <= s:len && s:id == synID(s:lnum, s:col, 1) | let s:col = s:col + 1 | endwhile
41f9fd58cf13 updated for version 7.0019
vimboss
parents: 29
diff changeset
1520 endif
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1521
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1522 if s:settings.ignore_conceal || !s:concealinfo[0]
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1523 " Expand tabs if needed
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1524 let s:expandedtab = strpart(s:line, s:startcol - 1, s:col - s:startcol)
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1525 if s:settings.expand_tabs
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1526 let s:offset = 0
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1527 let s:idx = stridx(s:expandedtab, "\t")
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1528 while s:idx >= 0
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1529 if has("multi_byte_encoding")
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1530 if s:startcol + s:idx == 1
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1531 let s:i = &ts
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1532 else
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1533 if s:idx == 0
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1534 let s:prevc = matchstr(s:line, '.\%' . (s:startcol + s:idx + s:offset) . 'c')
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1535 else
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1536 let s:prevc = matchstr(s:expandedtab, '.\%' . (s:idx + 1) . 'c')
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1537 endif
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1538 let s:vcol = virtcol([s:lnum, s:startcol + s:idx + s:offset - len(s:prevc)])
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1539 let s:i = &ts - (s:vcol % &ts)
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1540 endif
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1541 let s:offset -= s:i - 1
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1542 else
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1543 let s:i = &ts - ((s:idx + s:startcol - 1) % &ts)
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1544 endif
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1545 let s:expandedtab = substitute(s:expandedtab, '\t', repeat(' ', s:i), '')
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1546 let s:idx = stridx(s:expandedtab, "\t")
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1547 endwhile
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1548 end
34
7f788cd27415 updated for version 7.0020
vimboss
parents: 32
diff changeset
1549
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1550 " get the highlight group name to use
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1551 let s:id = synIDtrans(s:id)
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1552 else
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1553 " use Conceal highlighting for concealed text
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1554 let s:id = s:CONCEAL_ID
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1555 let s:expandedtab = s:concealinfo[1]
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1556 endif
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1557
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1558 " Output the text with the same synID, with class set to the highlight ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1559 " name, unless it has been concealed completely.
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1560 if strlen(s:expandedtab) > 0
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1561 let s:new = s:new . s:HtmlFormat(s:expandedtab, s:id, s:diff_id, "", 0)
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1562 endif
29
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1563 endwhile
ac33b7c03fac updated for version 7.0018
vimboss
parents: 7
diff changeset
1564 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565
2401
e7751177126b Add the synconcealed() function and use it for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2334
diff changeset
1566 call extend(s:lines, split(s:new.s:HtmlEndline, '\n', 1))
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1567 if !s:settings.no_progress && s:pgb.needs_redraw
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1568 redrawstatus
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1569 let s:pgb.needs_redraw = 0
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1570 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571 let s:lnum = s:lnum + 1
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1572
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1573 if !s:settings.no_progress
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1574 call s:pgb.incr()
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1575 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 endwhile
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
1577
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1578 if s:settings.dynamic_folds
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1579 " finish off any open folds
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1580 while !empty(s:foldstack)
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1581 let s:lines[-1].="</span></span>"
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1582 call remove(s:foldstack, 0)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1583 endwhile
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1584
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1585 " add fold column to the style list if not already there
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1586 let s:id = s:FOLD_C_ID
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1587 if !has_key(s:stylelist, s:id)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1588 let s:stylelist[s:id] = '.FoldColumn { ' . s:CSS1(s:id) . '}'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1589 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1590 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1591
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1592 if s:settings.no_pre
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1593 if !s:settings.use_css
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1594 " Close off the font tag that encapsulates the whole <body>
2508
7e008c174cc3 Updates for :TOhtml. (Ben Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2496
diff changeset
1595 call extend(s:lines, ["</font>", "</body>", "</html>"])
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1596 else
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1597 call extend(s:lines, ["</div>", "</body>", "</html>"])
2432
80229a724a11 Updated runtime files. :TOhtml improvements by Benjamin Fritz.
Bram Moolenaar <bram@vim.org>
parents: 2401
diff changeset
1598 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 else
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1600 call extend(s:lines, ["</pre>", "</body>", "</html>"])
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1603 exe s:newwin . "wincmd w"
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1604 call setline(1, s:lines)
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1605 unlet s:lines
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1607 " Mangle modelines so Vim doesn't try to use HTML text as a modeline if editing
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1608 " this file in the future; need to do this after generating all the text in case
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1609 " the modeline text has different highlight groups which all turn out to be
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1610 " stripped from the final output.
5161
f7add3891e95 Updated runtime files. Fix NL translations.
Bram Moolenaar <bram@vim.org>
parents: 5003
diff changeset
1611 %s!\v(%(^|\s+)%([Vv]i%(m%([<=>]?\d+)?)?|ex)):!\1\&#0058;!ge
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1612
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1613 " The generated HTML is admittedly ugly and takes a LONG time to fold.
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1614 " Make sure the user doesn't do syntax folding when loading a generated file,
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1615 " using a modeline.
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1616 call append(line('$'), "<!-- vim: set foldmethod=manual : -->")
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1617
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 " Now, when we finally know which, we define the colors and styles
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1619 if s:settings.use_css
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 1;/<style type="text/+1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 " Normal/global attributes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 " For Netscape 4, set <body> attributes too, though, strictly speaking, it's
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625 " incorrect.
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1626 if s:settings.use_css
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1627 if s:settings.no_pre
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1628 call append('.', "body { color: " . s:fgc . "; background-color: " . s:bgc . "; font-family: ". s:htmlfont ."; }")
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1629 +
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 else
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1631 call append('.', "pre { " . s:whitespace . "font-family: ". s:htmlfont ."; color: " . s:fgc . "; background-color: " . s:bgc . "; }")
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1632 +
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 yank
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634 put
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 execute "normal! ^cwbody\e"
2788
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
1636 " body should not have the wrap formatting, only the pre section
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
1637 if s:whitespace != ''
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
1638 exec 's#'.s:whitespace
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
1639 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 endif
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1641 " fix browser inconsistencies (sometimes within the same browser) of different
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1642 " default font size for different elements
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1643 call append('.', '* { font-size: 1em; }')
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1644 +
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1645 " if we use any input elements for unselectable content, make sure they look
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1646 " like normal text
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1647 if !empty(s:settings.prevent_copy)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1648 call append('.', 'input { border: none; margin: 0; padding: 0; font-family: '.s:htmlfont.'; }')
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1649 +
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1650 " ch units for browsers which support them, em units for a somewhat
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1651 " reasonable fallback. Also make sure the special elements for size
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1652 " calculations aren't seen.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1653 call append('.', [
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1654 \ "input[size='1'] { width: 1em; width: 1ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1655 \ "input[size='2'] { width: 2em; width: 2ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1656 \ "input[size='3'] { width: 3em; width: 3ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1657 \ "input[size='4'] { width: 4em; width: 4ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1658 \ "input[size='5'] { width: 5em; width: 5ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1659 \ "input[size='6'] { width: 6em; width: 6ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1660 \ "input[size='7'] { width: 7em; width: 7ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1661 \ "input[size='8'] { width: 8em; width: 8ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1662 \ "input[size='9'] { width: 9em; width: 9ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1663 \ "input[size='10'] { width: 10em; width: 10ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1664 \ "input[size='11'] { width: 11em; width: 11ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1665 \ "input[size='12'] { width: 12em; width: 12ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1666 \ "input[size='13'] { width: 13em; width: 13ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1667 \ "input[size='14'] { width: 14em; width: 14ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1668 \ "input[size='15'] { width: 15em; width: 15ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1669 \ "input[size='16'] { width: 16em; width: 16ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1670 \ "input[size='17'] { width: 17em; width: 17ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1671 \ "input[size='18'] { width: 18em; width: 18ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1672 \ "input[size='19'] { width: 19em; width: 19ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1673 \ "input[size='20'] { width: 20em; width: 20ch; }",
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1674 \ "#oneCharWidth, #oneEmWidth, #oneInputWidth { padding: 0; margin: 0; position: absolute; left: -999999px; visibility: hidden; }"
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1675 \ ])
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1676 +21
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1677 for w in range(5, 100, 5)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1678 let base = 0.01 * w
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1679 call append('.', join(map(range(1,20), "'.em'.w.' input[size='''.v:val.'''] { width: '.string(v:val*base).'em; }'")))
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1680 +
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1681 endfor
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1682 if s:settings.prevent_copy =~# 'f'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1683 " Make the cursor show active fold columns as active areas, and empty fold
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1684 " columns as not interactive.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1685 call append('.', ['input.FoldColumn { cursor: pointer; }',
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1686 \ 'input.FoldColumn[value=""] { cursor: default; }'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1687 \ ])
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1688 +2
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1689 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1690 " make line number column show as non-interactive if not selectable
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1691 if s:settings.prevent_copy =~# 'n'
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1692 call append('.', 'input.LineNr { cursor: default; }')
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1693 +
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1694 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1695 " make fold text and line number column within fold text show as
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1696 " non-interactive if not selectable
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1697 if (s:settings.prevent_copy =~# 'n' || s:settings.prevent_copy =~# 't') && !s:settings.ignore_folding
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1698 call append('.', 'input.Folded { cursor: default; }')
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1699 +
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1700 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1701 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 else
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1703 execute '%s:<body\([^>]*\):<body bgcolor="' . s:bgc . '" text="' . s:fgc . '"\1>\r<font face="'. s:htmlfont .'"'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1706 " Gather attributes for all other classes. Do diff first so that normal
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1707 " highlight groups are inserted before it.
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1708 if s:settings.use_css
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1709 if s:diff_mode
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1710 call append('.', filter(map(keys(s:diffstylelist), "s:diffstylelist[v:val]"), 'v:val != ""'))
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1711 endif
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1712 if !empty(s:stylelist)
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1713 call append('.', filter(map(keys(s:stylelist), "s:stylelist[v:val]"), 'v:val != ""'))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 " Add hyperlinks
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1718 " TODO: add option to not do this? Maybe just make the color the same as the
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1719 " text highlight group normally is?
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 34
diff changeset
1720 %s+\(https\=://\S\{-}\)\(\([.,;:}]\=\(\s\|$\)\)\|[\\"'<>]\|&gt;\|&lt;\|&quot;\)+<a href="\1">\1</a>\2+ge
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 " The DTD
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1723 if s:settings.use_xhtml
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1724 exe "normal! gg$a\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1725 elseif s:settings.use_css && !s:settings.no_pre
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1726 exe "normal! gg0i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n"
1122
2ad54fcf37e3 updated for version 7.1a
vimboss
parents: 856
diff changeset
1727 else
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1728 exe "normal! gg0i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 34
diff changeset
1729 endif
410fa1a31baf updated for version 7.0023
vimboss
parents: 34
diff changeset
1730
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1731 if s:settings.use_xhtml
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 34
diff changeset
1732 exe "normal! gg/<html/e\na xmlns=\"http://www.w3.org/1999/xhtml\"\e"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1734
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1735 " Cleanup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 %s:\s\+$::e
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1738 " Restore old settings (new window first)
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1739 "
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1740 " Don't bother restoring foldmethod in case it was syntax because the markup is
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1741 " so weirdly formatted it can take a LONG time.
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
1742 let &l:foldenable = s:old_fen
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 let &report = s:old_report
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 let &title = s:old_title
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 let &icon = s:old_icon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 let &paste = s:old_paste
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 let &magic = s:old_magic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 let @/ = s:old_search
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1749 let &more = s:old_more
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1750
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1751 " switch to original window to restore those settings
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 exe s:orgwin . "wincmd w"
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1753
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1754 if !s:settings.expand_tabs
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1755 let &l:isprint = s:old_isprint
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1756 endif
2642
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
1757 let &l:stl = s:origwin_stl
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 let &l:et = s:old_et
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
1759 let &l:scrollbind = s:old_bind
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1760
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1761 " and back to the new window again to end there
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 exe s:newwin . "wincmd w"
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1763
2642
840c3cadb842 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2546
diff changeset
1764 let &l:stl = s:newwin_stl
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1765 exec 'resize' s:old_winheight
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1766 let &l:winfixheight = s:old_winfixheight
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1768 let &ls=s:ls
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1769
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 " Save a little bit of memory (worth doing?)
2788
0877b8d6370e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2681
diff changeset
1771 unlet s:htmlfont s:whitespace
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
1772 unlet s:old_et s:old_paste s:old_icon s:old_report s:old_title s:old_search
4681
2eb30f341e8d Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents: 3713
diff changeset
1773 unlet s:old_magic s:old_more s:old_fen s:old_winheight
2681
85c5a72551e2 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2642
diff changeset
1774 unlet! s:old_isprint
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1775 unlet s:whatterm s:stylelist s:diffstylelist s:lnum s:end s:margin s:fgc s:bgc s:old_winfixheight
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1776 unlet! s:col s:id s:attr s:len s:line s:new s:expandedtab s:concealinfo s:diff_mode
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
1777 unlet! s:orgwin s:newwin s:orgbufnr s:idx s:i s:offset s:ls s:origwin_stl
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
1778 unlet! s:newwin_stl s:current_syntax
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 39
diff changeset
1779 if !v:profiling
8c60f65311fa updated for version 7.0052
vimboss
parents: 39
diff changeset
1780 delfunc s:HtmlColor
8c60f65311fa updated for version 7.0052
vimboss
parents: 39
diff changeset
1781 delfunc s:HtmlFormat
8c60f65311fa updated for version 7.0052
vimboss
parents: 39
diff changeset
1782 delfunc s:CSS1
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1783 delfunc s:BuildStyleWrapper
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1784 if !s:settings.use_css
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 39
diff changeset
1785 delfunc s:HtmlOpening
8c60f65311fa updated for version 7.0052
vimboss
parents: 39
diff changeset
1786 delfunc s:HtmlClosing
8c60f65311fa updated for version 7.0052
vimboss
parents: 39
diff changeset
1787 endif
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1788 if s:settings.dynamic_folds
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1789 delfunc s:FoldCompare
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1790 endif
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1791
2496
a29075150aee Improve handling of user settings in :TOhtml. Default to generating CSS.
Bram Moolenaar <bram@vim.org>
parents: 2432
diff changeset
1792 if !s:settings.no_progress
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1793 delfunc s:ProgressBar
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1794 delfunc s:progressbar.paint
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1795 delfunc s:progressbar.incr
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1796 unlet s:pgb s:progressbar
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1797 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 endif
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1799
2546
0d3f0e3d289b Updates for :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2508
diff changeset
1800 unlet! s:new_lnum s:diffattr s:difffillchar s:foldfillchar s:HtmlSpace
3713
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1801 unlet! s:LeadingSpace s:HtmlEndline s:firstfold s:numcol s:foldcolumn
9910cbff5f16 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
1802 unlet s:foldstack s:allfolds s:foldId s:settings
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1803
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1804 let &cpo = s:cpo_sav
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1805 unlet! s:cpo_sav
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1698
diff changeset
1806
2321
1902913f2049 Improved version of 2html.vim.
Bram Moolenaar <bram@vim.org>
parents: 2304
diff changeset
1807 " Make sure any patches will probably use consistent indent
2334
3c9324c0800e Improved :TOhtml. (Benjamin Fritz)
Bram Moolenaar <bram@vim.org>
parents: 2321
diff changeset
1808 " vim: ts=8 sw=2 sts=2 noet