Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I conditionally change the status line colour? #640

Open
anko opened this issue Dec 8, 2017 · 1 comment
Open

How do I conditionally change the status line colour? #640

anko opened this issue Dec 8, 2017 · 1 comment

Comments

@anko
Copy link

anko commented Dec 8, 2017

I've figured that I can subscribe to vis.events.WIN_STATUS to get my statusline to contain exactly what I want it to, but I wish I could additionally change the background colour of the statusline according to the editor mode I'm in.

For example, the statusbar could be purple when I'm in insert mode.

Here's my best attempt at what I figure it should look like:

vis.events.subscribe(vis.events.WIN_STATUS, function(win)
    if vis.mode == vis.modes.INSERT then
        win:style_define(win.STYLE_STATUS, 'fore:red')
    end
    if vis.mode == vis.modes.NORMAL then
        win:style_define(win.STYLE_STATUS, '')
    end
end)

But that does nothing… no errors, just nothing. I guess I'd need to tell it to reload the style somehow, so it actually gets changed?

Is overwriting style definitions like this even supported?

Maybe I should be requesting a "mode changed" event type instead, and putting this in there?

@martanne
Copy link
Owner

martanne commented Dec 8, 2017

Try win.STYLE_STATUS_FOCUSED and back:red. However, you will likely encounter some glitches where the changes do not take immediate effect.

And yes the mode change events should eventually be added, they have been requested before (e.g. #564, #525).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants