comparison src/os_win32.c @ 30013:11cfe4c6d677 v9.0.0344

patch 9.0.0344: MS-Windows: background color wrong in Console Commit: https://github.com/vim/vim/commit/e42c8dae32f3575557b83a371c4be66c09afbf7f Author: Yasuhiro Matsumoto <mattn.jp@gmail.com> Date: Thu Sep 1 11:31:45 2022 +0100 patch 9.0.0344: MS-Windows: background color wrong in Console Problem: MS-Windows: background color wrong in Console. Solution: Figure out the default console background color. (Yasuhiro Matsumoto, issue #10310)
author Bram Moolenaar <Bram@vim.org>
date Thu, 01 Sep 2022 12:45:05 +0200
parents 89e1d67814a9
children 347cf03fee2b
comparison
equal deleted inserted replaced
30012:94b5149875fa 30013:11cfe4c6d677
211 211
212 static int g_color_index_bg = 0; 212 static int g_color_index_bg = 0;
213 static int g_color_index_fg = 7; 213 static int g_color_index_fg = 7;
214 214
215 # ifdef FEAT_TERMGUICOLORS 215 # ifdef FEAT_TERMGUICOLORS
216 static int default_console_color_bg = 0x000000; // black
216 static int default_console_color_fg = 0xc0c0c0; // white 217 static int default_console_color_fg = 0xc0c0c0; // white
217 # endif 218 # endif
218 219
219 # ifdef FEAT_TERMGUICOLORS 220 # ifdef FEAT_TERMGUICOLORS
220 # define USE_VTP (vtp_working && is_term_win32() && (p_tgc || (!p_tgc && t_colors >= 256))) 221 # define USE_VTP (vtp_working && is_term_win32() && (p_tgc || (!p_tgc && t_colors >= 256)))
7876 save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg]; 7877 save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg];
7877 store_console_bg_rgb = save_console_bg_rgb; 7878 store_console_bg_rgb = save_console_bg_rgb;
7878 store_console_fg_rgb = save_console_fg_rgb; 7879 store_console_fg_rgb = save_console_fg_rgb;
7879 7880
7880 # ifdef FEAT_TERMGUICOLORS 7881 # ifdef FEAT_TERMGUICOLORS
7882 if (!USE_WT)
7883 {
7884 COLORREF bg;
7885 bg = (COLORREF)csbi.ColorTable[g_color_index_bg];
7886 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
7887 default_console_color_bg = bg;
7888 }
7881 fg = (COLORREF)csbi.ColorTable[g_color_index_fg]; 7889 fg = (COLORREF)csbi.ColorTable[g_color_index_fg];
7882 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); 7890 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
7883 default_console_color_fg = fg; 7891 default_console_color_fg = fg;
7884 # endif 7892 # endif
7885 7893
8158 if (guibg == INVALCOLOR) 8166 if (guibg == INVALCOLOR)
8159 { 8167 {
8160 ctermbg = -1; 8168 ctermbg = -1;
8161 if (id > 0) 8169 if (id > 0)
8162 syn_id2cterm_bg(id, &ctermfg, &ctermbg); 8170 syn_id2cterm_bg(id, &ctermfg, &ctermbg);
8163 cterm_normal_bg_gui_color = guibg = 8171 if (!USE_WT)
8172 {
8173 guibg = ctermbg != -1 ? ctermtoxterm(ctermbg)
8174 : default_console_color_bg;
8175 cterm_normal_bg_gui_color = guibg;
8176 ctermbg = ctermbg < 0 ? 0 : ctermbg;
8177 }
8178 else
8179 {
8180 cterm_normal_bg_gui_color = guibg =
8164 ctermbg != -1 ? ctermtoxterm(ctermbg) : INVALCOLOR; 8181 ctermbg != -1 ? ctermtoxterm(ctermbg) : INVALCOLOR;
8165 8182 if (ctermbg < 0)
8166 if (ctermbg < 0) 8183 ctermbg = 0;
8167 ctermbg = 0; 8184 }
8168 } 8185 }
8169 8186
8170 *cterm_fg = ctermfg; 8187 *cterm_fg = ctermfg;
8171 *cterm_bg = ctermbg; 8188 *cterm_bg = ctermbg;
8172 *gui_fg = guifg; 8189 *gui_fg = guifg;