Updating status line of inactive windows

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Updating status line of inactive windows

François Ingelrest

Hi all,

In my status line, I display the number of lines in the corresponding
buffer. If I split the window, so that I have the same buffer into two
visible windows, only the status line of the active window is updated.
For instance, if I add some new lines to the buffer, the number of
lines in the inactive windows remains the same.

Even more confusing: If I change the file type, the syntax
highlighting is updated in both windows, but only the file type in the
status line of the active window is updated, not the other one.

Is it the expected behavior? I would have expected the other status
line to be updated, even if the corresponding window is inactive,
since it's the same buffer I'm modifying.

BTW, I'm using Vim 7.2.148 on Ubuntu Linux.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Updating status line of inactive windows

Tony Mechelynck

On 31/03/09 13:34, François Ingelrest wrote:

>
> Hi all,
>
> In my status line, I display the number of lines in the corresponding
> buffer. If I split the window, so that I have the same buffer into two
> visible windows, only the status line of the active window is updated.
> For instance, if I add some new lines to the buffer, the number of
> lines in the inactive windows remains the same.
>
> Even more confusing: If I change the file type, the syntax
> highlighting is updated in both windows, but only the file type in the
> status line of the active window is updated, not the other one.
>
> Is it the expected behavior? I would have expected the other status
> line to be updated, even if the corresponding window is inactive,
> since it's the same buffer I'm modifying.
>
> BTW, I'm using Vim 7.2.148 on Ubuntu Linux.

I'm confirming this in gvim 7.2.148 on openSUSE Linux 11.1. I suspect it
is related to the bug investigated in the thread "How to redraw the
whole Vim screen after splitting new windows?".

After splitting windows, adding lines (by o followed by several times
Enter) does not cause the current line number in the non-current window
to be updated immediately. However, I have a CursorHold,CursorHoldI
autocommand which changes the color of the StatusLine and Wildmenu
groups, and when that autocommand triggers, the non-current statusine is
also updated, even though the autocommand changes neither the
'statusline' option nor StatusLineNC highlight.

Here are the relevant lines from my "almost-default" colorscheme:


----------------8<--------------------8<--------------------
" display the status line of the active window in a distinctive color:
" bold black on bright red in the GUI, white on green in the console
" (where the bg is never bright, and dark red is sometimes an ugly sort
" of reddish brown).
hi StatusLine   gui=NONE,bold   guibg=red           guifg=black
         \       cterm=NONE,bold ctermbg=darkgreen   ctermfg=white
hi WildMenu     gui=NONE,bold   guibg=green         guifg=black
         \       cterm=NONE,bold ctermbg=black       ctermfg=white
" make the status line bold-reverse (but B&W) for inactive windows
hi StatusLineNC gui=reverse,bold
         \       cterm=NONE      ctermbg=black       ctermfg=lightgrey
" make the active status line colours alternate between two settings
" to give a visual notice of the CursorHold/CursorHoldI events
if ! exists("s:statuslineflag")
   let s:statuslineflag = 0
endif
function! ToggleStatusLine()
     if s:statuslineflag
         hi StatusLine
           \     cterm=NONE,bold ctermbg=darkgreen   ctermfg=white
           \     gui=NONE,bold   guibg=red           guifg=black
         hi WildMenu
           \     cterm=NONE,bold ctermbg=black       ctermfg=white
           \     gui=NONE,bold   guibg=green         guifg=black
     else
         hi StatusLine
           \     cterm=NONE,bold ctermbg=black       ctermfg=white
           \     gui=NONE,bold   guibg=green         guifg=black
         hi WildMenu
           \     cterm=NONE,bold ctermbg=darkgreen   ctermfg=white
           \     gui=NONE,bold   guibg=red           guifg=black
     endif
     let s:statuslineflag = ! s:statuslineflag
endfunction
exe "augroup" s:colors_name
     au! CursorHold,CursorHoldI * call ToggleStatusLine()
     au! ColorScheme *
         \ if g:colors_name != s:colors_name | exe "au!" s:colors_name |
endif
augroup END
----------------8<--------------------8<--------------------


Both s:colors_name and g:colors-name are set to the colorscheme name
(outside the part quoted above) when it is sourced.

Continuation lines need 'nocompatible' to be set.


Best regards,
Tony.
--
Tussman's Law:
        Nothing is as inevitable as a mistake whose time has come.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Updating status line of inactive windows

François Ingelrest

On Wed, Apr 1, 2009 at 12:23, Tony Mechelynck
<[hidden email]> wrote:
> I'm confirming this in gvim 7.2.148 on openSUSE Linux 11.1. I suspect it
> is related to the bug investigated in the thread "How to redraw the
> whole Vim screen after splitting new windows?".

So should we forward this to the bugs mailing-list?

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Updating status line of inactive windows

Tony Mechelynck

On 04/04/09 06:51, François Ingelrest wrote:
>
> On Wed, Apr 1, 2009 at 12:23, Tony Mechelynck
> <[hidden email]>  wrote:
>> I'm confirming this in gvim 7.2.148 on openSUSE Linux 11.1. I suspect it
>> is related to the bug investigated in the thread "How to redraw the
>> whole Vim screen after splitting new windows?".
>
> So should we forward this to the bugs mailing-list?

Let's wait until the end of the Easter holiday, leave Bram some time to
settle back even after that, and we can still wake it up again on
vim_dev if nothing happens. What do you think?


Best regards,
Tony.
--
Only presidents, editors, and people with tapeworms have the right to
use the editorial "we."

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Updating status line of inactive windows

François Ingelrest

On Sat, Apr 4, 2009 at 11:28, Tony Mechelynck
<[hidden email]> wrote:
> Let's wait until the end of the Easter holiday, leave Bram some time to
> settle back even after that, and we can still wake it up again on
> vim_dev if nothing happens. What do you think?

Ça marche.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Updating status line of inactive windows

Bram Moolenaar
In reply to this post by François Ingelrest


Francois Ingelrest wrote:

> In my status line, I display the number of lines in the corresponding
> buffer. If I split the window, so that I have the same buffer into two
> visible windows, only the status line of the active window is updated.
> For instance, if I add some new lines to the buffer, the number of
> lines in the inactive windows remains the same.
>
> Even more confusing: If I change the file type, the syntax
> highlighting is updated in both windows, but only the file type in the
> status line of the active window is updated, not the other one.
>
> Is it the expected behavior? I would have expected the other status
> line to be updated, even if the corresponding window is inactive,
> since it's the same buffer I'm modifying.
>
> BTW, I'm using Vim 7.2.148 on Ubuntu Linux.

It appears you have a custom statusline.  This is not guaranteed to be
updated on every little change in Vim's status.  It's a trade off
between updating the status line too often, which consumes time and
performance, and the status line being slightly outdated.

The ideal solution would be to inspect the statusline, find out what it
depends on exactly and have the redraw trigger when one of the
dependencies changes.  But that's very complicated, since the status
line can depend on very many values.

--
"My particular problem is with registry entries, which seem to just
accumulate like plastic coffee cups..."           -- Paul Moore

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Updating status line of inactive windows

iler.ml
In reply to this post by François Ingelrest

On Mar 31, 2:34 pm, François Ingelrest <[hidden email]>
wrote:
...

Even though inactive statuslines are not updated automatically,
I beleive that by means of au CursorHold you can
make it get updated automatically. Did you try this.
Don't forget to your 'updatetime'.

Yakov
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Updating status line of inactive windows

François Ingelrest
In reply to this post by Bram Moolenaar

2009/4/5 Bram Moolenaar <[hidden email]>:

>> In my status line, I display the number of lines in the corresponding
>> buffer. If I split the window, so that I have the same buffer into two
>> visible windows, only the status line of the active window is updated.
>> For instance, if I add some new lines to the buffer, the number of
>> lines in the inactive windows remains the same.
>>
>> Even more confusing: If I change the file type, the syntax
>> highlighting is updated in both windows, but only the file type in the
>> status line of the active window is updated, not the other one.
>>
>> Is it the expected behavior? I would have expected the other status
>> line to be updated, even if the corresponding window is inactive,
>> since it's the same buffer I'm modifying.
>>
>> BTW, I'm using Vim 7.2.148 on Ubuntu Linux.
>
> It appears you have a custom statusline.  This is not guaranteed to be
> updated on every little change in Vim's status.  It's a trade off
> between updating the status line too often, which consumes time and
> performance, and the status line being slightly outdated.
>
> The ideal solution would be to inspect the statusline, find out what it
> depends on exactly and have the redraw trigger when one of the
> dependencies changes.  But that's very complicated, since the status
> line can depend on very many values.

Isn't it possible to compute the status line for the active window,
cache it, and then just 'copy it' over the status lines of visible
windows showing the same buffer? I guess most of the time there will
be at most only 1 or maybe 2 other visible windows with the same
buffer.

Maybe it's not possible, I don't know much about Vim's internals.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Updating status line of inactive windows

Tony Mechelynck

On 06/04/09 07:58, François Ingelrest wrote:

>
> 2009/4/5 Bram Moolenaar<[hidden email]>:
>>> In my status line, I display the number of lines in the corresponding
>>> buffer. If I split the window, so that I have the same buffer into two
>>> visible windows, only the status line of the active window is updated.
>>> For instance, if I add some new lines to the buffer, the number of
>>> lines in the inactive windows remains the same.
>>>
>>> Even more confusing: If I change the file type, the syntax
>>> highlighting is updated in both windows, but only the file type in the
>>> status line of the active window is updated, not the other one.
>>>
>>> Is it the expected behavior? I would have expected the other status
>>> line to be updated, even if the corresponding window is inactive,
>>> since it's the same buffer I'm modifying.
>>>
>>> BTW, I'm using Vim 7.2.148 on Ubuntu Linux.
>>
>> It appears you have a custom statusline.  This is not guaranteed to be
>> updated on every little change in Vim's status.  It's a trade off
>> between updating the status line too often, which consumes time and
>> performance, and the status line being slightly outdated.
>>
>> The ideal solution would be to inspect the statusline, find out what it
>> depends on exactly and have the redraw trigger when one of the
>> dependencies changes.  But that's very complicated, since the status
>> line can depend on very many values.
>
> Isn't it possible to compute the status line for the active window,
> cache it, and then just 'copy it' over the status lines of visible
> windows showing the same buffer? I guess most of the time there will
> be at most only 1 or maybe 2 other visible windows with the same
> buffer.
>
> Maybe it's not possible, I don't know much about Vim's internals.

It would be invalid in the case of custom 'statusline's including, for
instance, the window number, or maybe the number of visible lines and
columns in the window, as part of what is displayed. Also, the cursor's
line, column and virtual column (which are even displayed by the
_default_ statusline when 'ruler' is set) can also differ among windows
on a common buffer.

I prefer the present status (where :redraw or Ctrl-L can make the error
disappear) than a copy-over among windows of a common buffer, where
:redraw or Ctrl-L would _not_ make the error disappear.


Best regards,
Tony.
--
To the systems programmer, users and applications serve only to provide
a test load.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Updating status line of inactive windows

François Ingelrest

On Mon, Apr 6, 2009 at 18:00, Tony Mechelynck
<[hidden email]> wrote:
> It would be invalid in the case of custom 'statusline's including, for
> instance, the window number, or maybe the number of visible lines and
> columns in the window, as part of what is displayed. Also, the cursor's
> line, column and virtual column (which are even displayed by the
> _default_ statusline when 'ruler' is set) can also differ among windows
> on a common buffer.

Right, I did not thought of options such as the window number.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---