Add 'pumopt' option for popup menu transparency#19739
Add 'pumopt' option for popup menu transparency#19739mattn wants to merge 16 commits intovim:masterfrom
Conversation
|
The options for pum (popup menu) have increased quite a bit ('pumborder', 'pumheight', 'pummaxwidth', 'pumwidth'). With 'pumopacity', that makes five. It might be time to consider introducing a new 'pumopt' option to consolidate these, similar to 'diffopt', 'completeopt', and 'statuslineopt', ... (Add:) |
|
Thanks, I tend to agree on a consolidated |
|
Should we treat 'pumborder', 'pumheight', 'pummaxwidth', and 'pumwidth' as deprecated? |
|
Yes, I think we should mark it as "deprecated" in the documentation and remove it in the next or the one after that major release. |
|
I perfer to add new error |
|
Anyway I should not include the error e_option_is_deprecated in this pull-request. Should be separated. |
|
|
|
I looked into how other comma-separated string options behave when only some values are specified:
All of these options reset unspecified values to their defaults. This is the standard behavior for comma-separated options in Vim. So |
|
As an aside, Vim currently has some precedent for deprecated options:
Neither of these produce an error when set. In a separate PR, I plan to introduce |
|
I'm sorry, I completely misunderstood.
Regarding the above, yes, that's how it's designed.
(Added:) |
|
To clarify: this PR adds |
|
Looking back at it, it doesn't make sense to add |
|
Removed pumopacity |
Add a new 'pumopacity' option (0-100) that controls the transparency of the popup completion menu (pum). When set, the underlying buffer content shows through the pum's padding areas with blended attributes. - pumopacity=0: fully opaque (default, normal pum behavior) - pumopacity=1-99: partially transparent, higher = more transparent - pumopacity=100: same as 0 (fully opaque) Implementation saves the background screen content on the first pum display and restores it for padding/space cells using hl_blend_attr() for color blending. Text cells are drawn normally with pum highlight. Works with both cterm and termguicolors/GUI.
Move pum opacity blending from post-processing (pum_opacity_fill) into screen_puts_len() and screen_fill() using the screen_pum_blend global. This avoids double-blending issues and ensures text and space cells use consistent blend calculations. - screen_puts_len: blend text background with underlying attr - screen_fill: restore underlying character and blend attrs - pum_bg_* variables moved to globals.h for access from screen.c - screen_pum_blend set during pum_redraw, cleared after
Add hl_pum_blend_attr() in highlight.c that blends fg and bg in the correct direction for pum opacity: - fg: pum_bg toward underlying_fg (opaque = text hidden, transparent = visible) - bg: pum_bg toward underlying_bg (opaque = pum color, transparent = underlying) This is different from hl_blend_attr(blend_fg=TRUE) which blends fg in the opposite direction (designed for popup-over-popup compositing). Use hl_pum_blend_attr() in screen_fill for pum space cells. Use UPD_CLEAR in did_set_pumopacity to reset stale blended ScreenAttrs.
- Remove unused pum_opacity_fill() function and forward declaration - Remove unused pum_opacity_active variable - Remove duplicate if (over_cell > 0) condition - Remove unnecessary comment
Add option value test (default, clamping, reset) and screendump tests for pumopacity=50 and pumopacity=100.
Move next_col label outside of #ifdef FEAT_PROP_POPUP since it is also used by the pum opacity code path.
The blend parameter is only used inside FEAT_GUI and FEAT_TERMGUICOLORS blocks, so it triggers -Wunused-parameter when both are disabled.
Match the function declaration order to the implementation order in popupmenu.c.
Invalidate cached background when screen size changes so the blended pum background is re-captured from the updated screen.
Move 'pumopacity' after 'pummaxwidth' to maintain alphabetical order. This fixes the Test_set_all_one_column test failure.
Add 'pumopt' as a single string option that controls popup menu properties: border, height, width, maxwidth, opacity, shadow, margin. This provides a consolidated alternative to the individual options 'pumborder', 'pumheight', 'pumwidth', 'pummaxwidth', and 'pumopacity'. The existing individual options continue to work. Deprecation will be handled in a separate change. Example usage: :set pumopt=border:single,height:10,width:20,opacity:80 - Extract parse_pumopt_border() as shared border parser - Add pum_opacity_changed() as public function - Add expand_set_pumopt() for cmdline completion - Update syntax/vim.vim, options.txt, gen_opt_test.vim
The standalone 'pumopacity' option is unnecessary since 'pumopt' already
supports opacity via the opacity:{n} key. Remove the option definition
and move the internal p_po variable to globals.h. Update tests to use
'pumopt=opacity:50' instead of 'set pumopacity=50'.
|
I found a behavior difference between
|
pum_set_border_chars() unconditionally sets pum_border = 1. Calling it with all zeros during pumopt reset re-enabled the border right after PUM_BORDER_CLEAR() disabled it, causing the pum to appear one row lower than expected.
- Draw border/shadow before setting screen_pum_blend so they render opaque instead of partially transparent. - Expand pum_under_menu() to cover border, margin, and shadow areas to prevent flicker during completion selection. - Remove text cell blending in screen_puts_len() that caused underlying syntax highlight colors to leak into pum foreground.

Add the 'pumopacity' option (0-100, default 100) to control popup completion menu transparency, similar to the existing 'opacity' property for popup windows.
When pumopacity < 100, the background content shows through the popup menu. The implementation saves the background screen content before drawing the pum, then blends pum colors with the saved background using hl_pum_blend_attr() for space cells and hl_blend_attr() for text cells.