Problem: When using popup with a highlight group without background color set, and opacity set between 1 and 99 the blending fail and the popup is completely transparent.
I'm expecting a fadeout toward the underlying background color.
it occurs when popup highlight or highlights option are set to a group:
Moreover in the case ctermfg and guifg are not set, the underlying text color bleed on the popup text if this one does not have a color attribute (see the $${\color{cyan}OV\color{black}E\color{green}RANDABO\color{black}V\color{pink}E}$$ text in the screenshots)
Before this patch:
opacity-before-patch.png (view on web)
After this patch:
opacity-after-patch.png (view on web)
Since gui and cterm code are separate, I wanted to add similar screendump for gui but it works only for terminal, is there any way to do this kind of test for gvim ?
As the blocs guarded by if (popup_attr > HL_ALL) are not conditional any more, to ease the review on github, I've removed the bloc brackets and reindent in a separate commit.
To test it:
open a vim file containing
" DUMB CODE TO HAVE COLORED TEXT UNDER POPUP " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " 0123456789 abcdef TODO highlight grup cterm=underline ctermbg=1 guibg=#00ff00 let s:uvar = &filetype . 'under' + 1 " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " 0123456789 abcdef TODO highlight grup cterm=underline ctermbg=1 guibg=#00ff00 let s:uvar = &filetype . 'under' + 1 " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " 0123456789 abcdef TODO highlight grup cterm=underline ctermbg=1 guibg=#00ff00 let s:uvar = &filetype . 'under' + 1 " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " 0123456789 abcdef TODO highlight grup cterm=underline ctermbg=1 guibg=#00ff00 let s:uvar = &filetype . 'under' + 1 " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " 0123456789 abcdef TODO highlight grup cterm=underline ctermbg=1 guibg=#00ff00 let s:uvar = &filetype . 'under' + 1 " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " 0123456789 abcdef TODO highlight grup cterm=underline ctermbg=1 guibg=#00ff00 let s:uvar = &filetype . 'under' + 1 " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ █▓▒░ " 0123456789 abcdef TODO highlight grup cterm=underline ctermbg=1 guibg=#00ff00 let s:uvar = &filetype . 'under' + 1 " ===== END OF DUMB CODE ===== "hi! link Pmenu Normal function! Custompopup(hlgroup, position, opacity) abort let popup_content = [ \ '" popup content', \ '" A C E TODO █▓▒░ ', \ 'hi p cterm=nocombine ctermbg=1 guibg=#ccc', \ ' OVERANDABOVE', \ 'let s:pvar = &filetype . "popup" + 1', \ ''] if (has('nvim')) let bufnr = nvim_create_buf(v:false, v:true) let opts = { \ 'relative': 'win', \ 'row': a:position['line'] -1, \ 'border': [ '╔', '═' ,'╗', '║', '╝', '═', '╚', '║' ], \ 'width': 41, \ 'height': 7, \ 'fixed': 1, \ 'col': a:position['col'] -1, \ 'title': 'Opacity ' . a:opacity . '% - Highlight: ' . a:hlgroup, \ } call nvim_buf_set_lines(bufnr, 0, -1, v:true, popup_content) let winid = nvim_open_win(bufnr, 0, opts) call nvim_win_set_option(winid, 'winblend', 100 - a:opacity) call nvim_win_set_option(winid, 'filetype', 'vim') call nvim_set_option_value('winhl', 'Normal:' . a:hlgroup, {'win': winid}) else let opts = { \ 'border': [1, 1, 1, 1], \ 'line': a:position['line'], \ 'close': 'button', \ 'minheight': 7, \ 'minwidth': 40, \ 'opacity': a:opacity, \ 'fixed': 1, \ 'col': a:position['col'], \ 'highlights': 'Normal:' . a:hlgroup, \ 'title': 'Opacity ' . a:opacity . '% - Highlight: ' . a:hlgroup, \ } let winid = popup_create(popup_content, opts) call setbufvar(winbufnr(winid), '&filetype', 'vim') endif return winid endfunction highlight link LinkedToNormal Normal highlight clear ClearedGroup highlight OnlyFg ctermfg=blue guifg=blue highlight OnlyBg ctermbg=green guibg=green highlight BgNone ctermfg=red guifg=red ctermbg=NONE guibg=NONE let popupline = 2 for hlgroup in ['Pmenu', 'Normal', 'LinkedToNormal', 'ClearedGroup', 'OnlyFg', 'OnlyBg', 'BgNone'] let win1 = Custompopup(hlgroup, {'line': popupline, 'col': 10}, 80) let popupline = popupline + 9 endfor set wildoptions=pum,fuzzy " to compare popup and pum opacity if (has('nvim')) let pumblend=20 else set pumopt=opacity:80 endif
source it:
:sourcehttps://github.com/vim/vim/pull/20414
(18 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
Since gui and cterm code are separate, I wanted to add similar screendump for gui but it works only for terminal, is there any way to do this kind of test for gvim ?
You can add CheckGui at the start of the test function. It will skip the test if the Vim being tested is not gvim
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
You can add
CheckGuiat the start of the test function. It will skip the test if the Vim being tested is not gvim
I mean, I've started to add in src/testdir/test_gui.vim a test like
func Test_gui_popup_opacity_undefined_popup_highlight() CheckGui CheckScreendump "[…] call VerifyScreenDump(…
to get an error E117: Unknown function: VerifyScreenDump after that, I realised that VerifyScreenDump was explicitly for terminal use
" Verify that Vim running in terminal buffer "buf" matches the screen dump.but did not found a similar function for gui use.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
You can add
CheckGuiat the start of the test function. It will skip the test if the Vim being tested is not gvimI mean, I've started to add in src/testdir/test_gui.vim a test like
func Test_gui_popup_opacity_undefined_popup_highlight() CheckGui CheckScreendump "[…] call VerifyScreenDump(…to get an error
E117: Unknown function: VerifyScreenDumpafter that, I realised thatVerifyScreenDumpwas explicitly for terminal use" Verify that Vim running in terminal buffer "buf" matches the screen dump.but did not found a similar function for gui use.
VerifyScreenDump should work in the GUI, it uses the terminal feature, not the terminal Vim is running in. I think the error you are getting is because test_gui.vim doesn't source src/screendump.vim. However you shouldnt be putting the tests in test_gui, just put them in test_popup. The CI will run Vim in the GUI against all the tests anyways
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()