├── README ├── autoload └── ZoomWin.vim ├── doc └── ZoomWin.txt └── plugin └── ZoomWinPlugin.vim /README: -------------------------------------------------------------------------------- 1 | This is a mirror of http://www.vim.org/scripts/script.php?script_id=508 2 | 3 | Note: version 23 or later of ZoomWin requires vim 7.2 or later 4 | 5 | Usage: 6 | 7 | Press o : the current window zooms into a full screen 8 | Press o again: the previous set of windows is restored 9 | 10 | Features: 11 | 12 | The idea is to make it easy to zoom into and out of a window. ZoomWin supports normal windows, and it now also supports scratch-windows, no-name windows, and modified-buffer windows. 13 | 14 | * ZoomWin is a 7.2 plugin (as of v23) 15 | 16 | * Files are made hidden during zoom-in and restored upon zoom-out 17 | 18 | * All windows' file contents will be restored during zoomouts. 19 | 20 | * ZoomWin will clean up any temporary files it generates upon exit. 21 | 22 | * Session files are guaranteed to be unique to each vim session, so multiple vims can use zoom-in/out without interfering with one another 23 | 24 | A later version may be available at http://www.drchip.org/astronaut/vim/index.html#ZOOMWIN . 25 | 26 | When zooming in, ZoomWin's window is full sized, with no loss of screen space to status lines for other windows, unlike vimscript#1280 (ToggleOnly), for those vims compiled with the +mksession feature. For those vims without that feature, v21 ZoomWin now supports partial-zoom-in (leaves a status line behind for each window). 27 | 28 | History: 29 | 30 | Ron Aaron came up with the original ZoomWin and gave permission to have it posted. 31 | 32 | -------------------------------------------------------------------------------- /autoload/ZoomWin.vim: -------------------------------------------------------------------------------- 1 | " ZoomWin: Brief-like ability to zoom into/out-of a window 2 | " Author: Charles Campbell 3 | " original version by Ron Aaron 4 | " Date: Jun 18, 2012 5 | " Version: 24 6 | " History: see :help zoomwin-history {{{1 7 | " GetLatestVimScripts: 508 1 :AutoInstall: ZoomWin.vim 8 | 9 | " --------------------------------------------------------------------- 10 | " Load Once: {{{1 11 | if &cp || exists("g:loaded_ZoomWin") 12 | finish 13 | endif 14 | if v:version < 702 15 | echohl WarningMsg 16 | echo "***warning*** this version of ZoomWin needs vim 7.2" 17 | echohl Normal 18 | finish 19 | endif 20 | let s:keepcpo = &cpo 21 | let g:loaded_ZoomWin = "v24" 22 | let s:localoptlist = ["ai","ar","bh","bin","bl","bomb","bt","cfu","ci","cin","cink","cino","cinw","cms","com","cpt","efm","eol","ep","et","fenc","fex","ff","flp","fo","ft","gp","imi","ims","inde","inex","indk","inf","isk","key","kmp","lisp","mps","ml","ma","mod","nf","ofu","oft","pi","qe","ro","sw","sn","si","sts","spc","spf","spl","sua","swf","smc","syn","ts","tx","tw","udf","wm"] 23 | set cpo&vim 24 | "DechoTabOn 25 | 26 | " ===================================================================== 27 | " Functions: {{{1 28 | 29 | " --------------------------------------------------------------------- 30 | " ZoomWin#ZoomWin: toggles between a single-window and a multi-window layout {{{2 31 | " The original version was by Ron Aaron. 32 | fun! ZoomWin#ZoomWin() 33 | " let g:decho_hide= 1 "Decho 34 | let lzkeep = &lz 35 | set lz 36 | " call Dfunc("ZoomWin#ZoomWin() winbufnr(2)=".winbufnr(2)) 37 | 38 | " if the vim doesn't have +mksession, only a partial zoom is available {{{3 39 | if !has("mksession") 40 | if !exists("s:partialzoom") 41 | echomsg "missing the +mksession feature; only a partial zoom is available" 42 | let s:partialzoom= 0 43 | endif 44 | if v:version < 630 45 | echoerr "***sorry*** you need an updated vim, preferably with +mksession" 46 | elseif s:partialzoom 47 | " partial zoom out 48 | let s:partialzoom= 0 49 | exe s:winrestore 50 | else 51 | " partial zoom in 52 | let s:partialzoom= 1 53 | let s:winrestore = winrestcmd() 54 | res 55 | endif 56 | let &lz = lzkeep 57 | " call Dret("ZoomWin#ZoomWin : partialzoom=".s:partialzoom) 58 | return 59 | endif 60 | 61 | " Close certain windows and save user settings {{{3 62 | call s:ZoomWinPreserve(0) 63 | call s:SaveUserSettings() 64 | 65 | if winbufnr(2) == -1 66 | " there's only one window - restore to multiple-windows mode {{{3 67 | " call Decho("there's only one window - restore to multiple windows") 68 | 69 | if exists("s:sessionfile") && filereadable(s:sessionfile) 70 | " save position in current one-window-only 71 | " call Decho("save position in current one-window-only in sponly (s:sessionfile<".s:sessionfile.">)") 72 | let sponly = s:SavePosn(0) 73 | let s:origline = line(".") 74 | let s:origcol = virtcol(".") 75 | let s:swv = deepcopy(getwinvar(winnr(),""),1) 76 | sil! unlet key value 77 | for [key,value] in items(s:swv) 78 | exe "sil! unlet w:".key 79 | sil! unlet key value 80 | endfor 81 | 82 | " source session file to restore window layout 83 | let ei_keep = &ei 84 | set ei=all noswf 85 | exe 'sil! so '.fnameescape(s:sessionfile) 86 | let v:this_session= s:sesskeep 87 | " restore any and all window variables 88 | call s:RestoreWinVars() 89 | 90 | if exists("s:savedposn1") 91 | " restore windows' positioning and buffers 92 | " call Decho("restore windows, positions, buffers") 93 | windo call s:RestorePosn(s:savedposn{winnr()})|unlet s:savedposn{winnr()} 94 | call s:GotoWinNum(s:winkeep) 95 | unlet s:winkeep 96 | endif 97 | 98 | if exists("s:swv") 99 | " restore possibly modified while in one-window mode, window variables 100 | for [key,value] in items(s:swv) 101 | sil! call setwinvar(winnr(),key,value) 102 | sil! unlet key value 103 | endfor 104 | endif 105 | 106 | if line(".") != s:origline || virtcol(".") != s:origcol 107 | " If the cursor hasn't moved from the original position, 108 | " then let the position remain what it was in the original 109 | " multi-window layout. 110 | " call Decho("restore position using sponly") 111 | call s:RestorePosn(sponly) 112 | endif 113 | 114 | " delete session file and variable holding its name 115 | " call Decho("delete session file") 116 | call delete(s:sessionfile) 117 | unlet s:sessionfile 118 | let &ei = ei_keep 119 | endif 120 | 121 | " I don't know why -- but netrw-generated windows end up as [Scratch] even though the bufname is correct. 122 | " Following code fixes this. 123 | let curwin= winnr() 124 | windo exe "sil! file ".fnameescape(bufname(winbufnr(winnr()))) 125 | exe curwin."wincmd w" 126 | 127 | " Restore local window settings 128 | call s:RestoreWinSettings() 129 | 130 | " zoomwinstate used by g:ZoomWin_funcref() 131 | let zoomwinstate= 0 132 | 133 | else " there's more than one window - go to only-one-window mode {{{3 134 | " call Decho("there's multiple windows - goto one-window-only") 135 | 136 | let s:winkeep = winnr() 137 | let s:sesskeep = v:this_session 138 | 139 | " doesn't work with the command line window (normal mode q:) 140 | if &bt == "nofile" && expand("%") == (v:version < 702 ? 'command-line' : '[Command Line]') 141 | echoerr "***error*** ZoomWin#ZoomWin doesn't work with the ".expand("%")." window" 142 | let &lz= lzkeep 143 | " call Dret("ZoomWin#ZoomWin : ".expand('%')." window error") 144 | return 145 | endif 146 | 147 | " disable all events (autocmds) 148 | " call Decho("disable events") 149 | let ei_keep= &ei 150 | set ei=all 151 | 152 | " Save local window settings 153 | call s:SaveWinSettings() 154 | 155 | " save all window variables 156 | call s:SaveWinVars() 157 | 158 | " save window positioning commands 159 | " call Decho("save window positioning commands") 160 | windo let s:savedposn{winnr()}= s:SavePosn(1) 161 | call s:GotoWinNum(s:winkeep) 162 | 163 | " set up name of session file 164 | let s:sessionfile= tempname() 165 | 166 | " save session 167 | " call Decho("save session") 168 | let ssop_keep = &ssop 169 | let &ssop = 'blank,help,winsize,folds,globals,localoptions,options' 170 | exe 'mksession! '.fnameescape(s:sessionfile) 171 | let keepyy= @@ 172 | let keepy0= @0 173 | let keepy1= @1 174 | let keepy2= @2 175 | let keepy3= @3 176 | let keepy4= @4 177 | let keepy5= @5 178 | let keepy6= @6 179 | let keepy7= @7 180 | let keepy8= @8 181 | let keepy9= @9 182 | set lz ei=all bh= 183 | if v:version >= 700 184 | try 185 | exe "keepalt keepmarks new! ".fnameescape(s:sessionfile) 186 | catch /^Vim\%((\a\+)\)\=:E/ 187 | echoerr "Too many windows" 188 | sil! call delete(s:sessionfile) 189 | unlet s:sessionfile 190 | let &lz= lzkeep 191 | " call Dret("ZoomWin#ZoomWin : too many windows") 192 | return 193 | endtry 194 | sil! keepjumps keepmarks v/wincmd\|split\|resize/d 195 | keepalt w! 196 | keepalt bw! 197 | else 198 | exe "new! ".fnameescape(s:sessionfile) 199 | v/wincmd\|split\|resize/d 200 | w! 201 | bw! 202 | endif 203 | let @@= keepyy 204 | let @0= keepy0 205 | let @1= keepy1 206 | let @2= keepy2 207 | let @3= keepy3 208 | let @4= keepy4 209 | let @5= keepy5 210 | let @6= keepy6 211 | let @7= keepy7 212 | let @8= keepy8 213 | let @9= keepy9 214 | call histdel('search', -1) 215 | let @/ = histget('search', -1) 216 | 217 | " restore user's session options and restore event handling 218 | " call Decho("restore user session options and event handling") 219 | set nolz 220 | let &ssop = ssop_keep 221 | let curwin= winnr() 222 | sil! only! 223 | let &ei = ei_keep 224 | echomsg expand("%") 225 | call s:RestoreOneWinSettings(curwin) 226 | 227 | " zoomwinstate used by g:ZoomWin_funcref() 228 | let zoomwinstate= 1 229 | endif 230 | 231 | " restore user option settings {{{3 232 | call s:RestoreUserSettings() 233 | 234 | " Re-open certain windows {{{3 235 | call s:ZoomWinPreserve(1) 236 | 237 | " call user's optional funcref (callback) functions 238 | if exists("g:ZoomWin_funcref") 239 | if type(g:ZoomWin_funcref) == 2 240 | call g:ZoomWin_funcref(zoomwinstate) 241 | elseif type(g:ZoomWin_funcref) == 3 242 | for Fncref in g:ZoomWin_funcref 243 | if type(FncRef) == 2 244 | call FncRef(zoomwinstate) 245 | endif 246 | endfor 247 | endif 248 | endif 249 | 250 | let &lz= lzkeep 251 | " call Dret("ZoomWin#ZoomWin") 252 | endfun 253 | 254 | " --------------------------------------------------------------------- 255 | " SavePosn: this function sets up a savedposn variable that {{{2 256 | " has the commands necessary to restore the view 257 | " of the current window. 258 | fun! s:SavePosn(savewinhoriz) 259 | " call Dfunc("SavePosn(savewinhoriz=".a:savewinhoriz.") file<".expand("%").">") 260 | let swline = line(".") 261 | if swline == 1 && getline(1) == "" 262 | " empty buffer 263 | let savedposn= "silent b ".winbufnr(0) 264 | " call Dret("SavePosn savedposn<".savedposn.">") 265 | return savedposn 266 | endif 267 | let swcol = col(".") 268 | if swcol >= col("$") 269 | let swcol= swcol + virtcol(".") - virtcol("$") " adjust for virtual edit (cursor past end-of-line) 270 | endif 271 | let swwline = winline()-1 272 | let swwcol = virtcol(".") - wincol() 273 | " call Decho("swline #".swline) 274 | " call Decho("swcol #".swcol) 275 | " call Decho("swwline#".swwline) 276 | " call Decho("swwcol #".swwcol) 277 | 278 | let savedposn = "silent b ".winbufnr(0) 279 | let savedposn = savedposn."|".swline 280 | let savedposn = savedposn."|sil! norm! 0z\" 281 | if swwline > 0 282 | let savedposn= savedposn.":sil! norm! ".swwline."\\" 283 | endif 284 | 285 | if a:savewinhoriz 286 | if swwcol > 0 287 | let savedposn= savedposn.":sil! norm! 0".swwcol."zl\" 288 | endif 289 | let savedposn= savedposn.":sil! call cursor(".swline.",".swcol.")\" 290 | 291 | " handle certain special settings for the multi-window savedposn call 292 | " bufhidden buftype buflisted 293 | let settings= "" 294 | if &bh != "" 295 | let settings="bh=".&bh 296 | setlocal bh=hide 297 | endif 298 | if !&bl 299 | let settings= settings." nobl" 300 | setlocal bl 301 | endif 302 | if &bt != "" 303 | let settings= settings." bt=".&bt 304 | setlocal bt= 305 | endif 306 | if settings != "" 307 | let savedposn= savedposn.":setlocal ".settings."\" 308 | endif 309 | 310 | else 311 | let savedposn= savedposn.":sil! call cursor(".swline.",".swcol.")\" 312 | endif 313 | " call Dret("SavePosn savedposn<".savedposn.">") 314 | return savedposn 315 | endfun 316 | 317 | " --------------------------------------------------------------------- 318 | " s:RestorePosn: this function restores noname and scratch windows {{{2 319 | fun! s:RestorePosn(savedposn) 320 | " call Dfunc("RestorePosn(savedposn<".a:savedposn.">)") 321 | if &scb 322 | setlocal noscb 323 | exe a:savedposn 324 | setlocal scb 325 | else 326 | exe a:savedposn 327 | endif 328 | " call Dret("RestorePosn") 329 | endfun 330 | 331 | " --------------------------------------------------------------------- 332 | " CleanupSessionFile: if you exit Vim before cleaning up the {{{2 333 | " supposed-to-be temporary session file 334 | fun! ZoomWin#CleanupSessionFile() 335 | " call Dfunc("ZoomWin#CleanupSessionFile()") 336 | if exists("s:sessionfile") && filereadable(s:sessionfile) 337 | " call Decho("sessionfile exists and is readable; deleting it") 338 | sil! call delete(s:sessionfile) 339 | unlet s:sessionfile 340 | endif 341 | " call Dret("ZoomWin#CleanupSessionFile") 342 | endfun 343 | 344 | " --------------------------------------------------------------------- 345 | " GotoWinNum: this function puts cursor into specified window {{{2 346 | fun! s:GotoWinNum(winnum) 347 | " call Dfunc("GotoWinNum(winnum=".a:winnum.") winnr=".winnr()) 348 | if a:winnum != winnr() 349 | exe a:winnum."wincmd w" 350 | endif 351 | " call Dret("GotoWinNum") 352 | endfun 353 | 354 | 355 | " --------------------------------------------------------------------- 356 | " ZoomWinPreserve: This function, largely written by David Fishburn, {{{2 357 | " allows ZoomWin to "preserve" certain windows: 358 | " 359 | " TagList, by Yegappan Lakshmanan 360 | " http://vim.sourceforge.net/scripts/script.php?script_id=273 361 | " 362 | " WinManager, by Srinath Avadhanula 363 | " http://vim.sourceforge.net/scripts/script.php?script_id=95 364 | " 365 | " It does so by closing the associated window upon entry to ZoomWin 366 | " and re-opening it upon exit by using commands provided by the 367 | " utilities themselves. 368 | fun! s:ZoomWinPreserve(open) 369 | " call Dfunc("ZoomWinPreserve(open=".a:open.")") 370 | 371 | if a:open == 0 372 | 373 | " Close Taglist 374 | if exists('g:zoomwin_preserve_taglist') && exists('g:loaded_taglist') 375 | " If taglist window is open then close it. 376 | let s:taglist_winnum = bufwinnr(g:TagList_title) 377 | if s:taglist_winnum != -1 378 | " Close the window 379 | exec "sil! Tlist" 380 | endif 381 | endif 382 | 383 | " Close Winmanager 384 | if exists('g:zoomwin_preserve_winmanager') && exists('g:loaded_winmanager') 385 | " If the winmanager window is open then close it. 386 | let s:is_winmgr_vis = IsWinManagerVisible() 387 | if s:is_winmgr_vis == 1 388 | exec "WMClose" 389 | endif 390 | endif 391 | 392 | else 393 | 394 | " Re-open Taglist 395 | if exists('g:zoomwin_preserve_taglist') && exists('g:loaded_taglist') 396 | " If taglist window was open, open it again 397 | if s:taglist_winnum != -1 398 | exec "sil! Tlist" 399 | endif 400 | endif 401 | 402 | " Re-Open Winmanager 403 | if exists('g:zoomwin_preserve_winmanager') && exists('g:loaded_winmanager') 404 | " If the winmanager window is open then close it. 405 | if s:is_winmgr_vis == 1 406 | exec "WManager" 407 | endif 408 | endif 409 | endif 410 | 411 | " call Dret("ZoomWinPreserve") 412 | endfun 413 | 414 | " --------------------------------------------------------------------- 415 | " s:SaveWinVars: saves a copy of all window-variables into the script variable s:swv_#, {{{2 416 | " where # is the current window number, for all windows. 417 | fun! s:SaveWinVars() 418 | " call Dfunc("s:SaveWinVars()") 419 | let eikeep= &ei 420 | set ei=WinEnter,WinLeave 421 | windo let s:swv_{winnr()} = deepcopy(getwinvar(winnr(),""),1) 422 | 423 | let &ei= eikeep 424 | " call Dret("s:SaveWinVars") 425 | endfun 426 | 427 | " --------------------------------------------------------------------- 428 | " s:RestoreWinVars: restores window variables for all windows {{{2 429 | fun! s:RestoreWinVars() 430 | " call Dfunc("s:RestoreWinVars()") 431 | " windo call Decho(string(s:swv_{winnr()})) 432 | let eikeep= &ei 433 | set ei=WinEnter,WinLeave 434 | windo if exists("s:swv_{winnr()}") |sil! unlet s:key s:value |for [s:key,s:value] in items(s:swv_{winnr()})|call setwinvar(winnr(),s:key,s:value)|exe "sil! unlet s:key s:value"|endfor|endif 435 | windo if exists("s:swv_{winnr()}") |unlet s:swv_{winnr()} |endif 436 | let &ei= eikeep 437 | " call Dret("s:RestoreWinVars") 438 | endfun 439 | 440 | " --------------------------------------------------------------------- 441 | " s:SaveUserSettings: save user options, set to zoomwin-safe options. {{{2 442 | " Force window minimum height/width to be >= 1 443 | fun! s:SaveUserSettings() 444 | " call Dfunc("s:SaveUserSettings()") 445 | 446 | let s:keep_wfh = &wfh 447 | let s:keep_hidden = &hidden 448 | let s:keep_write = &write 449 | let s:keep_so = &so 450 | let s:keep_siso = &siso 451 | let s:keep_ss = &ss 452 | 453 | if v:version < 603 454 | if &wmh == 0 || &wmw == 0 455 | let s:keep_wmh = &wmh 456 | let s:keep_wmw = &wmw 457 | sil! set wmh=1 wmw=1 458 | endif 459 | endif 460 | set hidden write nowfh so=0 siso=0 ss=0 461 | " call Dret("s:SaveUserSettings") 462 | endfun 463 | 464 | " --------------------------------------------------------------------- 465 | " s:RestoreUserSettings: restore user option settings {{{2 466 | fun! s:RestoreUserSettings() 467 | " call Dfunc("s:RestoreUserSettings()") 468 | " call Decho("restore user option settings") 469 | let &hidden= s:keep_hidden 470 | let &write = s:keep_write 471 | let &wfh = s:keep_wfh 472 | let &so = s:keep_so 473 | let &siso = s:keep_siso 474 | let &ss = s:keep_ss 475 | if v:version < 603 476 | if exists("s:keep_wmw") 477 | let &wmh= s:keep_wmh 478 | let &wmw= s:keep_wmw 479 | endif 480 | endif 481 | " call Dret("s:RestoreUserSettings") 482 | endfun 483 | 484 | " --------------------------------------------------------------------- 485 | " s:SaveWinSettings: saves all windows' local settings {{{2 486 | fun! s:SaveWinSettings() 487 | " call Dfunc("s:SaveWinSettings() curwin#".winnr()) 488 | let curwin= winnr() 489 | for localopt in s:localoptlist 490 | windo exe "let s:swv_".localopt."_{winnr()}= &".localopt 491 | endfor 492 | exe curwin."wincmd w" 493 | " call Dret("s:SaveWinSettings : &bt=".&bt." s:swv_bt_".curwin."=".s:swv_bt_{curwin}) 494 | endfun 495 | 496 | " --------------------------------------------------------------------- 497 | " s:RestoreWinSettings: restores all windows' local settings {{{2 498 | fun! s:RestoreWinSettings() 499 | " call Dfunc("s:RestoreWinSettings()") 500 | let curwin= winnr() 501 | for localopt in s:localoptlist 502 | exe 'windo if exists("s:swv_'.localopt.'_{winnr()}")|let &'.localopt.'= s:swv_'.localopt.'_{winnr()}|unlet s:swv_'.localopt.'_{winnr()}|endif' 503 | endfor 504 | exe curwin."wincmd w" 505 | " call Dret("s:RestoreWinSettings : &bt=".&bt) 506 | endfun 507 | 508 | " --------------------------------------------------------------------- 509 | " s:RestoreOneWinSettings: assumes that s:SaveWinSettings() was called previously; this function restores the specified window's local settings {{{2 510 | fun! s:RestoreOneWinSettings(wnum) 511 | " call Dfunc("s:RestoreOneWinSettings(wnum=".a:wnum.") s:swv_bt_".a:wnum."=".s:swv_bt_{a:wnum}) 512 | for localopt in s:localoptlist 513 | " call Decho('windo if exists("s:swv_'.localopt.'_{a:wnum}")|let &'.localopt.'= s:swv_'.localopt.'_{a:wnum}|unlet s:swv_'.localopt.'_{a:wnum}|endif') 514 | exe 'windo if exists("s:swv_'.localopt.'_{a:wnum}")|let &'.localopt.'= s:swv_'.localopt.'_{a:wnum}|unlet s:swv_'.localopt.'_{a:wnum}|endif' 515 | endfor 516 | " call Dret("s:RestoreOneWinSettings : &bt=".&bt) 517 | endfun 518 | 519 | " ===================================================================== 520 | " Restore: {{{1 521 | let &cpo= s:keepcpo 522 | unlet s:keepcpo 523 | 524 | " --------------------------------------------------------------------- 525 | " Modelines: {{{1 526 | " vim: ts=4 fdm=marker 527 | -------------------------------------------------------------------------------- /doc/ZoomWin.txt: -------------------------------------------------------------------------------- 1 | *ZoomWin.txt* Zoom into/out-of a window Jun 18, 2012 2 | Authors: Charles E. Campbell, Jr. *zoomwin* 3 | Ron Aaron 4 | Copyright: (c) 2004-2012 by Charles E. Campbell, Jr. *zoomwin-copyright* 5 | The VIM LICENSE applies to ZoomWin.vim and ZoomWin.txt 6 | (see |copyright|) except use "ZoomWin" instead of "Vim" 7 | No warranty, express or implied. Use At-Your-Own-Risk. 8 | 9 | ============================================================================== 10 | 1. Usage *zoomwin-usage* 11 | 12 | :call ZoomWin() 13 | :ZoomWin 14 | o 15 | 16 | Either of the two commands or the normal mode o will toggle between 17 | * selecting the current window for display as the only window or 18 | * restoring the original multiple-window view. 19 | 20 | 21 | ============================================================================== 22 | 2. Setup *zoomwin-setup* 23 | 24 | ZoomWin comes as a vimball; to install it, simply > 25 | 26 | vim ZoomWin.vba.gz 27 | :so % 28 | :q 29 | < 30 | Your .vimrc needs to have, at least: > 31 | 32 | set nocp 33 | filetype plugin on 34 | < 35 | (see |'nocp'|, |:filetype|, and |filetype-plugin-on| for an explanation of 36 | these commands) 37 | 38 | ============================================================================== 39 | 3. Options *zoomwin-options* 40 | 41 | *g:ZoomWin_funcref* : this variable is used as a function reference 42 | (|Funcref|) or as a |List| of function references. 43 | It is called with a single argument: > 44 | 0 : multi-window display; not zoomed in 45 | 1 : single-window display; zoomed in 46 | < What this does is permits ZoomWin users to have a 47 | function called whenever ZoomWin changes state. 48 | As an example, consider having the status line 49 | indicate whether one is ZoomWin'd in or not: > 50 | set stl=Normal 51 | fun! ZWStatline(state) 52 | if a:state 53 | set stl=ZoomWin 54 | else 55 | set stl=Normal 56 | endif 57 | endfun 58 | if !exists("g:ZoomWin_funcref") 59 | let g:ZoomWin_funcref= function("ZWStatline") 60 | endif 61 | < The function, ZWStatline(), is called by ZoomWin() 62 | every time it changes state. 63 | 64 | *g:zoomwin_preserve_taglist* open and close a taglist window on 65 | zooms 66 | 67 | *g:zoomwin_preserve_winmanager* open and close winmanager a window on 68 | zooms 69 | 70 | 71 | ============================================================================== 72 | 4. History *zoomwin-history* 73 | 74 | v24 Jan 29, 2009 : * |g:ZoomWin_funcref| supported 75 | May 22, 2009 * supports the saving and restoring of window 76 | variables across zooms 77 | Oct 11, 2009 * The state wasn't being passed along to 78 | g:ZoomWin_funcref as intended. Fixed. 79 | Jul 09, 2010 * Put an exists() test into s:RestoreWinVars() 80 | Jan 18, 2011 * (reported by talek) bypass winfixheight option 81 | Apr 06, 2011 * Saves and restores local options for every window 82 | v23 Apr 24, 2008 : * when |'scrollbind'| was activated: when ZoomWin 83 | attempted to restore multiple-windows, the cursor 84 | position was incorrect. Fixed. 85 | Jan 02, 2009 * included some more things in the session file 86 | * broke ZoomWin into an plugin + autoload pair 87 | * (Ingo Karkat) contributed a patch to retain the 88 | the search pattern before zooming 89 | * (Ingo Karkat) contributed a patch to detect the 90 | vim 7.2 name for the command line window 91 | * too many files (more than the screen rows) 92 | caused restoration problems. 93 | v22 Apr 10, 2006 : * "only" was occasionally issuing an "Already one 94 | window" message, which is now prevented 95 | * SavePosn() issued error message when handling an 96 | empty buffer 97 | * saves yank registers and restores them on each 98 | zoom/unzoom 99 | v21 Oct 12, 2004 : * v14 fixed a bug when wmw and/or wmv equal to 0; 100 | v21 will invoke the patch only if the version <= 603. 101 | For vim version 6.3 users, this fix allows more files 102 | to be handled by ZoomWin. 103 | May 10, 2005 * When :version shows -mksession, and the vim version 104 | is at least 6.3, ZoomWin will now do a partial zoom 105 | v20 Jul 26, 2004 : * bugfix - ZoomWin didn't always retain the 106 | position in the former zoomed-in window after 107 | the window layout was restored. It was restoring 108 | the position when the zoom-in occurred. 109 | v19 May 26, 2004 : * bugfix - winmanager has events firing that, 110 | amongst other things, reset the bufhidden 111 | option to delete for some windows while 112 | ZoomWin worked. ZoomWin now works 113 | successfully with winmanager. 114 | v18 May 20, 2004 : * bugfix - didn't adversely affect anything, but 115 | ZoomWin was deleting its session file twice. 116 | * bugfix -- a multi-source file + minibufexplorer 117 | + Taglist interaction bug -- minibufexplorer's 118 | autocmd events were firing, generating a new 119 | window while ZoomWin was attempting to restore 120 | the display. ZoomWin didn't have restoration 121 | information for the new window and so reported 122 | an error. Events are now temporarily disabled 123 | while ZoomWin is restoring the layout. 124 | v17 Mar 26, 2004 : * ZoomWin command installed. Works nicely with 125 | taglist: vim +Tlist +ZoomWin filename 126 | v16 Dec 22, 2003 : * handles bufhidden and nobl windows (TagList support). 127 | * Now also works with quickfix window (:copen) but 128 | still not with |cmdline-window| (q:) 129 | v15 Dec 19, 2003 : * SavePosn()/RestorePosn() needed to be preceded 130 | by s: to prevent clashes 131 | v14 Dec 18, 2003 : * works around a restoration-bug with mksession 132 | when either wmw or wmh settings are zero 133 | * Bwipes internal temporary buffers 134 | * Known bugs: will not work with command-line 135 | * Editing window (|cmdline-window|) nor the 136 | quickfix window (|copen|). 137 | v13 Dec 18, 2003 : Uses eventignore to prevent events/autocmds from 138 | firing while changing the mksession results. 139 | v12 Dec 12, 2003 : uses hidden and a minimalist mksession save 140 | v11 Oct 14, 2003 : bug fix: apparently RestorePosn()'s variables, 141 | which were b:, weren't always defined, so s: 142 | ones are now used. 143 | v10 Sep 22, 2003 : Bug fix: when a single window is showing, the user 144 | moves the cursor, then o used to restore 145 | screen, the current cursor position wasn't retained 146 | Restores v:this_session. 147 | Bug fix: change a window, use o, then write. 148 | Was saving file only to temporary file instead of 149 | actual file, but when the actual file was brought back, 150 | the changes were lost. 151 | v9 Aug 15, 2003 : v8 managed to trash syntax highlighting on 152 | reload, this one removes the eventignore 153 | handling. Will need more pondering... 154 | v8 Aug 14, 2003 : now handles not-modified but not filereadable 155 | buffers, nowrite buffers uses eventignore to 156 | bypass autocmd firing 157 | v7 May 23, 2003 : bugfix - GotoWinNum() didn't always get the 158 | cursor into the correct window 159 | v6 Mar 25, 2003 : more cleanup included 160 | v5 Mar 14, 2003 : includes support for handling scratch buffers, 161 | no-name buffer windows, and modified-buffer 162 | windows. All windows' contents will be saved to 163 | temporary buffers 164 | v4 Dec 12, 2002 : Zak Beck contributed code to clean up temporary 165 | session files if one leaves vim while zoomed-in 166 | v3 Dec 11, 2002 : plugin-ized 167 | v2 Nov 08, 2002 : A guaranteed-to-be-unique to this 168 | session file is used for session information. 169 | Modified but not yet saved files are made hidden 170 | during zoom in. 171 | v1 the epoch : Ron Aaron's original 172 | 173 | vim:tw=78:ts=8:ft=help 174 | -------------------------------------------------------------------------------- /plugin/ZoomWinPlugin.vim: -------------------------------------------------------------------------------- 1 | " ZoomWin: Brief-like ability to zoom into/out-of a window 2 | " Author: Charles Campbell 3 | " original version by Ron Aaron 4 | " Date: Apr 07, 2011 5 | " Version: 24iNR NOT RELEASED 6 | " History: see :help zoomwin-history {{{1 7 | " GetLatestVimScripts: 508 1 :AutoInstall: ZoomWin.vim 8 | 9 | " --------------------------------------------------------------------- 10 | " Load Once: {{{1 11 | if &cp || exists("g:loaded_ZoomWinPlugin") 12 | finish 13 | endif 14 | if v:version < 702 15 | echohl WarningMsg 16 | echo "***warning*** this version of ZoomWin needs vim 7.2" 17 | echohl Normal 18 | finish 19 | endif 20 | let s:keepcpo = &cpo 21 | let g:loaded_ZoomWinPlugin = "v24" 22 | set cpo&vim 23 | "DechoTabOn 24 | 25 | " --------------------------------------------------------------------- 26 | " Public Interface: {{{1 27 | if !hasmapto("ZoomWin") 28 | nmap o ZoomWin 29 | endif 30 | nnoremap