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

can I change the background for the faded window/buffer ? #53

Open
dnastase opened this issue Jan 8, 2021 · 2 comments
Open

can I change the background for the faded window/buffer ? #53

dnastase opened this issue Jan 8, 2021 · 2 comments

Comments

@dnastase
Copy link

dnastase commented Jan 8, 2021

Sorry, this is a question only, but I don't know where else to ask it.

First of all, nice plugin and very very useful to me ! thanks !

The question: when the focus moves, I can see the faded window changes the colors for the text, but the background remains the same. I would love to be able for the background to change too as that would be an even more visible difference.
But I don't know how/if I can do that. Using the g:vimade.basebg only seems to change the tint of the text, not the background.

@TaDaa
Copy link
Owner

TaDaa commented Jan 9, 2021

Hi @dnastase --

Neovim:

If you are using neovim, you can use the following to fade the background color on a per window basis:

hi NormalNC guibg=black

If you want to combine vimade with the background changes above, the following should follow the same behaviors as vimade for which buffers get faded:

let start_win=win_getid()
hi NormalNC guibg=black
augroup startup
au!
au WinEnter * setlocal winhighlight=NormalNC:Normal
augroup END
silent windo setlocal winhighlight=NormalNC:Normal
silent windo echo "" 
call win_gotoid(start_win)

Vim:
If you are using vim, I think the right approach now is using wincolor. Vimade doesn't currently support detecting the background through wincolor for text fading, but if you need this let me know and it would be pretty quick to add.

On the config for vim side it could look like this:

function! SetBackground(target)
    let l:wins=win_findbuf(bufnr())
    let l:start_win=win_getid()
    for l:win in l:wins
        let l:winnr = win_id2win(l:win)
        call setwinvar(l:winnr, "&wincolor", a:target)
    endfor
endfunction

let start_win=win_getid()
hi NormalNC guibg=black
augroup startup
au!
au BufEnter * call SetBackground('Normal')
au BufLeave * call SetBackground('NormalNC')
augroup END
silent windo set wincolor=NormalNC
silent windo echo "" 
call win_gotoid(start_win)
silent set wincolor=Normal

@dnastase
Copy link
Author

Yes, I think it would be useful to add to Vimade as it will allow text to be easy to read both on active and non-active buffers. My use case scenario is for coding where fading the text itself on the non-active buffers makes it hard to see source code that you need to reference in order to write the code in the active buffer. Having just the background change in the non-active buffers would keep the text as readable.

Thank you for the above, I will try it as soon as possible.

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