function! s:Tlist_Window_Create()
call s:Tlist_Log_Msg('Tlist_Window_Create()')
" If the window is open, jump to it
let winnum = bufwinnr(g:TagList_title)
if winnum != -1
" Jump to the existing window
if winnr() != winnum
exe winnum . 'wincmd w'
endif
return
endif
" If used with winmanager don't open windows. Winmanager will handle
" the window/buffer management
if s:tlist_app_name == "winmanager"
return
endif
" Create a new window. If user prefers a horizontal window, then open
" a horizontally split window. Otherwise open a vertically split
" window
if g:Tlist_Use_Horiz_Window
" Open a horizontally split window
let win_dir = 'botright'
" Horizontal window height
let win_size = g:Tlist_WinHeight
else
if s:tlist_winsize_chgd == -1
" Open a vertically split window. Increase the window size, if
" needed, to accomodate the new window
if g:Tlist_Inc_Winwidth &&
\ &columns < (80 + g:Tlist_WinWidth)
" Save the original window position
let s:tlist_pre_winx = getwinposx()
let s:tlist_pre_winy = getwinposy()
" one extra column is needed to include the vertical split
let &columns= &columns + g:Tlist_WinWidth + 1
let s:tlist_winsize_chgd = 1
else
let s:tlist_winsize_chgd = 0
endif
endif
if g:Tlist_Use_Right_Window
" Open the window at the rightmost place
let win_dir = 'botright vertical'
else
" Open the window at the leftmost place
let win_dir = 'topleft vertical'
endif
let win_size = g:Tlist_WinWidth
endif
" If the tag listing temporary buffer already exists, then reuse it.
" Otherwise create a new buffer
let bufnum = bufnr(g:TagList_title)
if bufnum == -1
" Create a new buffer
let wcmd = g:TagList_title
else
" Edit the existing buffer
let wcmd = '+buffer' . bufnum
endif
" Create the taglist window
" Preserve the alternate file
let cmd_mod = (v:version >= 700) ? 'keepalt ' : ''
exe 'silent! ' . cmd_mod . win_dir . ' ' . win_size . 'split ' . wcmd
" Save the new window position
let s:tlist_winx = getwinposx()
let s:tlist_winy = getwinposy()
" Initialize the taglist window
call s:Tlist_Window_Init()
endfunction
Vim插件中构建新窗口
最新推荐文章于 2024-04-10 09:48:23 发布