On 18/05/13 20:27, meh. wrote:
I'm writing a fairly complex statusline and using %!Func() as
statusline, everything was good until I started using my new shiny
statusline and I realized the context it's run in is the current
window and not the context %{} would use, so the one the statusline
belongs to.
Is this intended? Because it makes doing what I want to do basically
impossible.
IIRC, %!Function() didn't exist until tab pages were added to Vim; then
it was invented so that you could call one function to generate the
whole tab line (the text-style one, where you generate all tabs at one
go). Since there is only one tab line, it didn't need to be called again
for each window. The status line (one for each window) has already a lot
of predefined %x items, and %{} expressions need only be added for the
few non-predefined things which you might want to put into it.
Example:
" custom status line, see :help 'statusline' for details
if has("statusline")
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc\ ==\
\"\"?&enc:&fenc).(&bomb?\",BOM\":\"\")}][U+%04B]\ %-12.(%l,%c%V%)\ %P
endif
if exists("+guioptions")
set go-=a go-=e go-=T go+=tc
" remove a no autoselect to * register
" remove e always use text-style tabs
" remove T omit the toolbar
" add t include tearoff menu items if possible
" add c avoid popup dialogs for small choices
endif
" define our text-style tabline
" this is adapted (with some enhancements) from the example at :help
setting-tabline
if exists("+showtabline")
function MyTabLine()
let s = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= '%' . i . 'T'
let s .= (i == t ? '%1*' : '%2*')
let s .= ' '
let s .= i . ':'
let s .= winnr . '/' . tabpagewinnr(i,'$')
let s .= ' %*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let bufnr = buflist[winnr - 1]
let file = bufname(bufnr)
let buftype = getbufvar(bufnr, 'buftype')
if buftype == 'nofile'
if file =~ '\/.'
let file = substitute(file, '.*\/\ze.',
'', '')
endif
else
let file = fnamemodify(file, ':p:t')
endif
if file == ''
let file = '[No Name]'
endif
let s .= file
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
return s
endfunction
set stal=2
set tabline=%!MyTabLine()
map <C-Tab> :tabnext<CR>
imap <C-Tab> <C-O>:tabnext<CR>
map <C-S-Tab> :tabprev<CR>
imap <C-S-Tab> <C-O>:tabprev<CR>
endif
Best regards,
Tony.
--
He looked at me as if I was a side dish he hadn't ordered.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.