]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4906: MS-Windows: cannot use transparent background v8.2.4906
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Sat, 7 May 2022 13:09:19 +0000 (14:09 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 7 May 2022 13:09:19 +0000 (14:09 +0100)
Problem:    MS-Windows: cannot use transparent background.
Solution:   Make transparent background work with 'termguicolors' and NONE
            background color. (Yasuhiro Matsumoto, closes #10310, closes #7162)

runtime/doc/options.txt
src/os_win32.c
src/term.c
src/version.c

index 689c9a28c1d0b179e4d4243b3165294d228e219d..124cfee5e08462dd4f9260f1bd02d1731e8998a1 100644 (file)
@@ -8079,6 +8079,13 @@ A jump table for the options with a short description can be found at |Q_op|.
 <      This requires Vim to be built with the |+vtp| feature.
 
        Note that the "cterm" attributes are still used, not the "gui" ones.
+
+       When using Vim with Windows Terminal, the background of Windows
+       Terminal is normally filled with the Vim background color.  Setting
+       'termguicolors' and the guibg of the Normal highlight group to NONE
+       will make the background transparent: >
+               :hi Normal guibg=NONE
+<
        NOTE: This option is reset when 'compatible' is set.
 
                                                *'termwinkey'* *'twk'*
index 7224fadef59a0271c61e8f058bc3f5d100f7ed67..efb0cfd612251c756e0aa928c420f1777fe08d44 100644 (file)
@@ -211,7 +211,6 @@ static int g_color_index_bg = 0;
 static int g_color_index_fg = 7;
 
 # ifdef FEAT_TERMGUICOLORS
-static int default_console_color_bg = 0x000000; // black
 static int default_console_color_fg = 0xc0c0c0; // white
 # endif
 
@@ -7846,7 +7845,7 @@ vtp_init(void)
     HMODULE hKerneldll;
     DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
 # ifdef FEAT_TERMGUICOLORS
-    COLORREF fg, bg;
+    COLORREF fg;
 # endif
 
     // Use functions supported from Vista
@@ -7873,11 +7872,8 @@ vtp_init(void)
     store_console_fg_rgb = save_console_fg_rgb;
 
 # ifdef FEAT_TERMGUICOLORS
-    bg = (COLORREF)csbi.ColorTable[g_color_index_bg];
     fg = (COLORREF)csbi.ColorTable[g_color_index_fg];
-    bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
     fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
-    default_console_color_bg = bg;
     default_console_color_fg = fg;
 # endif
 
@@ -8158,10 +8154,11 @@ get_default_console_color(
        ctermbg = -1;
        if (id > 0)
            syn_id2cterm_bg(id, &ctermfg, &ctermbg);
-       guibg = ctermbg != -1 ? ctermtoxterm(ctermbg)
-                                                   : default_console_color_bg;
-       cterm_normal_bg_gui_color = guibg;
-       ctermbg = ctermbg < 0 ? 0 : ctermbg;
+       cterm_normal_bg_gui_color = guibg =
+                           ctermbg != -1 ? ctermtoxterm(ctermbg) : INVALCOLOR;
+
+       if (ctermbg < 0)
+           ctermbg = 0;
     }
 
     *cterm_fg = ctermfg;
index 9cc480e6d02fbd3aaa49005ed77002af59db41d5..84d6bd5a1978b16ad724c4091212544b7189f95e 100644 (file)
@@ -3084,7 +3084,8 @@ term_fg_rgb_color(guicolor_T rgb)
     void
 term_bg_rgb_color(guicolor_T rgb)
 {
-    term_rgb_color(T_8B, rgb);
+    if (rgb != INVALCOLOR)
+       term_rgb_color(T_8B, rgb);
 }
 
     void
index af4c0b2546a4f39a99b3160418fadb5373f6178a..d5963d46d5c452497cce2f43ed4f21806923993c 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4906,
 /**/
     4905,
 /**/