]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0428: popup: no opacity support for completepopup/previewpopup v9.2.0428
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Fri, 1 May 2026 16:28:51 +0000 (16:28 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 1 May 2026 16:32:44 +0000 (16:32 +0000)
Problem:  popup: no opacity support for completepopup/previewpopup
Solution: Add support opacity: suboption for the 'completeopt'.

Accepts opacity:0-100 with the same semantics as popup_create()'s
opacity option, allowing the info / preview popup to blend with
the background.

closes: #20099

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/options.txt
runtime/doc/version9.txt
runtime/doc/windows.txt
src/optionstr.c
src/popupwin.c
src/testdir/test_options.vim
src/version.c

index b0f3f1c72b0dc9436db18fb1349bd89942feeba5..7e1d4cb67ed9ad3db271312fd49d5015d56c394f 100644 (file)
@@ -2393,6 +2393,9 @@ A jump table for the options with a short description can be found at |Q_op|.
                close           show close button: "on" (default) or "off"
                height          maximum height of the popup
                highlight       popup highlight group (default: PmenuSel)
+               opacity         opacity percentage 0-100 (default 100, fully
+                               opaque).  When less than 100, content beneath
+                               the popup shows through.
                resize          show resize handle: "on" (default) or "off"
                shadow          "off" (default) or "on" using |hl-PmenuShadow|
                width           maximum width of the popup
@@ -2400,6 +2403,7 @@ A jump table for the options with a short description can be found at |Q_op|.
        Example: >
                :set completepopup=height:10,border:single,highlight:InfoPopup
                :set completepopup=width:60,border:custom:─;│;─;│;┌;┐;┘;└
+               :set completepopup=border:round,opacity:80
 <
        When "align" is set to "item", the popup is positioned near the
        selected item and moves as the selection changes.
index ca69850e05febcb2cf1f6e6596a7196ca6e60615..c9ede397b868dde9c51e40f44235c16a2babb286 100644 (file)
@@ -52587,6 +52587,7 @@ Popups ~
 - Support for transparency, see |popup-opacity|.
 - 'previewpopup' supports the same values as 'completepopup' (except for
   "align").
+- Support "opacity" setting for 'completepopup' option.
 
 Diff mode ~
 ---------
index f27cc6b056e42231573dbc769b032b3706cb4288..f0d9afaf1ab3fb38c08f9dec63b180e34794ade8 100644 (file)
@@ -1,4 +1,4 @@
-*windows.txt*  For Vim version 9.2.  Last change: 2026 Mar 01
+*windows.txt*  For Vim version 9.2.  Last change: 2026 May 01
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -960,6 +960,9 @@ settings.  The option is a comma-separated list of values:
                        the value is "on", it must be set after border.
        height          maximum height of the popup
        highlight       highlight group of the popup (default is Pmenu)
+       opacity         opacity percentage 0-100 (default 100, fully opaque).
+                       When less than 100, content beneath the popup shows
+                       through.
        resize          show resize handle: "on" (default) or "off"
        shadow          "off" (default) or "on" using |hl-PmenuShadow|
        width           maximum width of the popup
@@ -968,6 +971,7 @@ Example: >
        :set previewpopup=height:10,width:60
        :set previewpopup=border:single,borderhilight:PmenuBorder
        :set previewpopup=border:custom:─;│;─;│;┌;┐;┘;└
+       :set previewpopup=border:round,opacity:80
 
 A few peculiarities:
 - If the file is in a buffer already, it will be re-used.  This will allow for
index 128e5a9469bdfae3e5635450694795510e047e0c..59d490913059512079feab1eeb7619603885628f 100644 (file)
@@ -73,11 +73,11 @@ static char *(p_kpc_protocol_values[]) = {"none", "mok2", "kitty", NULL};
 #ifdef FEAT_PROP_POPUP
 // Note: Keep this in sync with parse_popup_option()
 static char *(p_popup_cpp_option_values[]) = {"align:", "border:",
-    "borderhighlight:", "close:", "height:", "highlight:", "resize:",
-    "shadow:", "width:", NULL};
+    "borderhighlight:", "close:", "height:", "highlight:", "opacity:",
+    "resize:", "shadow:", "width:", NULL};
 static char *(p_popup_pvp_option_values[]) = {"border:",
-    "borderhighlight:", "close:", "height:", "highlight:", "resize:",
-    "shadow:", "width:", NULL};
+    "borderhighlight:", "close:", "height:", "highlight:", "opacity:",
+    "resize:", "shadow:", "width:", NULL};
 static char *(p_popup_option_on_off_values[]) = {"on", "off", NULL};
 static char *(p_popup_cpp_border_values[]) = {"single", "double", "round",
     "ascii", "on", "off", "custom:", NULL};
index 103daccd29647363279778b27712d5ae3bf649cb..fb6e17d058c45e95669e1dfcda439f94e75369c8 100644 (file)
@@ -2163,6 +2163,19 @@ parse_popup_option(win_T *wp, int is_preview)
            if (wp != NULL && menu)
                wp->w_popup_flags |= POPF_INFO_MENU;
        }
+       else if (STRNCMP(s, "opacity:", 8) == 0)
+       {
+           if (dig != p || x < 0 || x > 100)
+               return FAIL;
+           if (wp != NULL)
+           {
+               if (x < 100)
+                   wp->w_popup_flags |= POPF_OPACITY;
+               else
+                   wp->w_popup_flags &= ~POPF_OPACITY;
+               wp->w_popup_blend = 100 - x;
+           }
+       }
        else
            return FAIL;
     }
index 91610e12892367bf72090554b731132270fb0fc9..bbca7fe46f2fefdabcf8e59fcd0533a071d1bd22 100644 (file)
@@ -663,6 +663,22 @@ func Test_set_completion_string_values()
   call feedkeys(":set completepopup=height:10,align:\<Tab>\<C-B>\"\<CR>", 'xt')
   call assert_equal('"set completepopup=height:10,align:item', @:)
   call assert_equal([], getcompletion('set completepopup=bogusname:', 'cmdline'))
+
+  " opacity: numeric, 0..100 only
+  call assert_true(index(getcompletion('set completepopup=', 'cmdline'),
+        \ 'opacity:') >= 0)
+  call assert_true(index(getcompletion('set previewpopup=', 'cmdline'),
+        \ 'opacity:') >= 0)
+  set completepopup=border:on,opacity:0
+  set completepopup=border:on,opacity:50
+  set completepopup=border:on,opacity:100
+  call assert_fails('set completepopup=opacity:101', 'E474:')
+  call assert_fails('set completepopup=opacity:abc', 'E474:')
+  call assert_fails('set completepopup=opacity:-10', 'E474:')
+  set previewpopup=opacity:30
+  call assert_fails('set previewpopup=opacity:200', 'E474:')
+  call assert_fails('set previewpopup=opacity:-10', 'E474:')
+
   set previewpopup& completepopup&
 
   " diffopt: special handling of algorithm:<alg_list> and inline:<inline_type>
index d77ebcc1f49f159592213e5d34efabf70033b6e3..376f278c6443b132e951454023a767cfa84eca9e 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    428,
 /**/
     427,
 /**/