comparison runtime/optwin.vim @ 2908:fd09a9c8468e

Updated runtime files.
author Bram Moolenaar <bram@vim.org>
date Sun, 19 Jun 2011 05:09:16 +0200
parents 916c90b37ea9
children 8dcf3ea92b63
comparison
equal deleted inserted replaced
2907:ea75da0af64d 2908:fd09a9c8468e
1 " These commands create the option window. 1 " These commands create the option window.
2 " 2 "
3 " Maintainer: Bram Moolenaar <Bram@vim.org> 3 " Maintainer: Bram Moolenaar <Bram@vim.org>
4 " Last Change: 2010 Dec 02 4 " Last Change: 2011 Jun 13
5 5
6 " If there already is an option window, jump to that one. 6 " If there already is an option window, jump to that one.
7 if bufwinnr("option-window") > 0 7 if bufwinnr("option-window") > 0
8 let s:thiswin = winnr() 8 let s:thiswin = winnr()
9 while 1 9 while 1
10 if @% == "option-window" 10 if @% == "option-window"
11 finish 11 finish
12 endif 12 endif
13 exe "norm! \<C-W>w" 13 wincmd w
14 if s:thiswin == winnr() 14 if s:thiswin == winnr()
15 break 15 break
16 endif 16 endif
17 endwhile 17 endwhile
18 endif 18 endif
24 24
25 " function to be called when <CR> is hit in the option-window 25 " function to be called when <CR> is hit in the option-window
26 fun! <SID>CR() 26 fun! <SID>CR()
27 27
28 " If on a continued comment line, go back to the first comment line 28 " If on a continued comment line, go back to the first comment line
29 let lnum = line(".") 29 let lnum = search("^[^\t]", 'bWcn')
30 let line = getline(lnum) 30 let line = getline(lnum)
31 while line[0] == "\t"
32 let lnum = lnum - 1
33 let line = getline(lnum)
34 endwhile
35 31
36 " <CR> on a "set" line executes the option line 32 " <CR> on a "set" line executes the option line
37 if match(line, "^ \tset ") >= 0 33 if match(line, "^ \tset ") >= 0
38 34
39 " For a local option: go to the previous window 35 " For a local option: go to the previous window
80 " returns 0 for global option, 1 for local option, -1 for error 76 " returns 0 for global option, 1 for local option, -1 for error
81 fun! <SID>Find(lnum) 77 fun! <SID>Find(lnum)
82 if getline(a:lnum - 1) =~ "(local to" 78 if getline(a:lnum - 1) =~ "(local to"
83 let local = 1 79 let local = 1
84 let thiswin = winnr() 80 let thiswin = winnr()
85 exe "norm! \<C-W>p" 81 wincmd p
86 if exists("b:current_syntax") && b:current_syntax == "help" 82 if exists("b:current_syntax") && b:current_syntax == "help"
87 exe "norm! \<C-W>j" 83 wincmd j
88 if winnr() == thiswin 84 if winnr() == thiswin
89 exe "norm! \<C-W>j" 85 wincmd j
90 endif 86 endif
91 endif 87 endif
92 else 88 else
93 let local = 0 89 let local = 0
94 endif 90 endif
109 let name = substitute(a:line, '^ \tset \(no\)\=\([a-z]*\).*', '\2', "") 105 let name = substitute(a:line, '^ \tset \(no\)\=\([a-z]*\).*', '\2', "")
110 endif 106 endif
111 if name == "pt" && &pt =~ "\x80" 107 if name == "pt" && &pt =~ "\x80"
112 let val = <SID>PTvalue() 108 let val = <SID>PTvalue()
113 else 109 else
114 exe "let val = substitute(&" . name . ', "[ \\t\\\\\"|]", "\\\\\\0", "g")' 110 let val = escape(eval('&' . name), " \t\\\"|")
115 endif 111 endif
116 if a:local 112 if a:local
117 exe "norm! " . a:thiswin . "\<C-W>w" 113 exe a:thiswin . "wincmd w"
118 endif 114 endif
119 if match(a:line, "=") >= 0 || (val != "0" && val != "1") 115 if match(a:line, "=") >= 0 || (val != "0" && val != "1")
120 call setline(a:lnum, " \tset " . name . "=" . val) 116 call setline(a:lnum, " \tset " . name . "=" . val)
121 else 117 else
122 if val 118 if val
137 133
138 " If the current window is a help window, try finding a non-help window. 134 " If the current window is a help window, try finding a non-help window.
139 " Relies on syntax highlighting to be switched on. 135 " Relies on syntax highlighting to be switched on.
140 let s:thiswin = winnr() 136 let s:thiswin = winnr()
141 while exists("b:current_syntax") && b:current_syntax == "help" 137 while exists("b:current_syntax") && b:current_syntax == "help"
142 exe "norm! \<C-W>w" 138 wincmd w
143 if s:thiswin == winnr() 139 if s:thiswin == winnr()
144 break 140 break
145 endif 141 endif
146 endwhile 142 endwhile
147 143
148 " Open the window 144 " Open the window
149 new option-window 145 new option-window
150 setlocal ts=15 tw=0 noro 146 setlocal ts=15 tw=0 noro buftype=nofile
151 147
152 " Insert help and a "set" command for each option. 148 " Insert help and a "set" command for each option.
153 call append(0, '" Each "set" line shows the current value of an option (on the left).') 149 call append(0, '" Each "set" line shows the current value of an option (on the left).')
154 call append(1, '" Hit <CR> on a "set" line to execute it.') 150 call append(1, '" Hit <CR> on a "set" line to execute it.')
155 call append(2, '" A boolean option will be toggled.') 151 call append(2, '" A boolean option will be toggled.')
160 156
161 " These functions are called often below. Keep them fast! 157 " These functions are called often below. Keep them fast!
162 158
163 " Init a local binary option 159 " Init a local binary option
164 fun! <SID>BinOptionL(name) 160 fun! <SID>BinOptionL(name)
165 exe "norm! \<C-W>p" 161 let val = getwinvar(winnr('#'), '&' . a:name)
166 exe "let val = &" . a:name
167 exe "norm! \<C-W>p"
168 call append("$", substitute(substitute(" \tset " . val . a:name . "\t" . 162 call append("$", substitute(substitute(" \tset " . val . a:name . "\t" .
169 \!val . a:name, "0", "no", ""), "1", "", "")) 163 \!val . a:name, "0", "no", ""), "1", "", ""))
170 endfun 164 endfun
171 165
172 " Init a global binary option 166 " Init a global binary option
175 \!a:val . a:name, "0", "no", ""), "1", "", "")) 169 \!a:val . a:name, "0", "no", ""), "1", "", ""))
176 endfun 170 endfun
177 171
178 " Init a local string option 172 " Init a local string option
179 fun! <SID>OptionL(name) 173 fun! <SID>OptionL(name)
180 exe "norm! \<C-W>p" 174 let val = escape(getwinvar(winnr('#'), '&' . a:name), " \t\\\"|")
181 exe "let val = substitute(&" . a:name . ', "[ \\t\\\\\"|]", "\\\\\\0", "g")'
182 exe "norm! \<C-W>p"
183 call append("$", " \tset " . a:name . "=" . val) 175 call append("$", " \tset " . a:name . "=" . val)
184 endfun 176 endfun
185 177
186 " Init a global string option 178 " Init a global string option
187 fun! <SID>OptionG(name, val) 179 fun! <SID>OptionG(name, val)
188 call append("$", " \tset " . a:name . "=" . substitute(a:val, '[ \t\\"|]', 180 call append("$", " \tset " . a:name . "=" . escape(a:val, " \t\\\"|"))
189 \ '\\\0', "g"))
190 endfun 181 endfun
191 182
192 let s:idx = 1 183 let s:idx = 1
193 let s:lnum = line("$") 184 let s:lnum = line("$")
194 call append("$", "") 185 call append("$", "")
313 call <SID>BinOptionG("csverb", &csverb) 304 call <SID>BinOptionG("csverb", &csverb)
314 call append("$", "cscopepathcomp\thow many components of the path to show") 305 call append("$", "cscopepathcomp\thow many components of the path to show")
315 call append("$", " \tset cspc=" . &cspc) 306 call append("$", " \tset cspc=" . &cspc)
316 call append("$", "cscopequickfix\twhen to open a quickfix window for cscope") 307 call append("$", "cscopequickfix\twhen to open a quickfix window for cscope")
317 call <SID>OptionG("csqf", &csqf) 308 call <SID>OptionG("csqf", &csqf)
309 call append("$", "cscoperelative\tfile names in a cscope file are relative to that file")
310 call <SID>BinOptionG("csre", &csre)
318 endif 311 endif
319 312
320 313
321 call <SID>Header("displaying text") 314 call <SID>Header("displaying text")
322 call append("$", "scroll\tnumber of lines to scroll for CTRL-U and CTRL-D") 315 call append("$", "scroll\tnumber of lines to scroll for CTRL-U and CTRL-D")
1340 let &icon = s:old_icon 1333 let &icon = s:old_icon
1341 let &ru = s:old_ru 1334 let &ru = s:old_ru
1342 let &sc = s:old_sc 1335 let &sc = s:old_sc
1343 let &cpo = s:cpo_save 1336 let &cpo = s:cpo_save
1344 unlet s:old_title s:old_icon s:old_ru s:old_sc s:cpo_save s:idx s:lnum 1337 unlet s:old_title s:old_icon s:old_ru s:old_sc s:cpo_save s:idx s:lnum
1338
1339 " vim: ts=8 sw=2 sts=2