comparison src/os_win32.c @ 18786:1756fe125914 v8.1.2382

patch 8.1.2382: MS-Windows: When using VTP bold+inverse doesn't work Commit: https://github.com/vim/vim/commit/a050b9471c66b383ed674bfd57ac78016199d972 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 2 21:35:31 2019 +0100 patch 8.1.2382: MS-Windows: When using VTP bold+inverse doesn't work Problem: MS-Windows: When using VTP bold+inverse doesn't work. Solution: Compare with the default colors. (Nobuhiro Takasaki, closes https://github.com/vim/vim/issues/5303)
author Bram Moolenaar <Bram@vim.org>
date Mon, 02 Dec 2019 21:45:04 +0100
parents 38a3bef525e6
children 44b855153d8e
comparison
equal deleted inserted replaced
18785:b3ddaa7a8b5b 18786:1756fe125914
7412 static void 7412 static void
7413 set_console_color_rgb(void) 7413 set_console_color_rgb(void)
7414 { 7414 {
7415 # ifdef FEAT_TERMGUICOLORS 7415 # ifdef FEAT_TERMGUICOLORS
7416 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; 7416 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
7417 int id; 7417 guicolor_T fg, bg;
7418 guicolor_T fg = INVALCOLOR; 7418 int ctermfg, ctermbg;
7419 guicolor_T bg = INVALCOLOR;
7420 int ctermfg;
7421 int ctermbg;
7422 7419
7423 if (!USE_VTP) 7420 if (!USE_VTP)
7424 return; 7421 return;
7425 7422
7426 id = syn_name2id((char_u *)"Normal"); 7423 get_default_console_color(&ctermfg, &ctermbg, &fg, &bg);
7427 if (id > 0 && p_tgc) 7424
7428 syn_id2colors(id, &fg, &bg);
7429 if (fg == INVALCOLOR)
7430 {
7431 ctermfg = -1;
7432 if (id > 0)
7433 syn_id2cterm_bg(id, &ctermfg, &ctermbg);
7434 fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : default_console_color_fg;
7435 cterm_normal_fg_gui_color = fg;
7436 }
7437 if (bg == INVALCOLOR)
7438 {
7439 ctermbg = -1;
7440 if (id > 0)
7441 syn_id2cterm_bg(id, &ctermfg, &ctermbg);
7442 bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : default_console_color_bg;
7443 cterm_normal_bg_gui_color = bg;
7444 }
7445 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); 7425 fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
7446 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); 7426 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
7447 7427
7448 csbi.cbSize = sizeof(csbi); 7428 csbi.cbSize = sizeof(csbi);
7449 if (has_csbiex) 7429 if (has_csbiex)
7457 if (has_csbiex) 7437 if (has_csbiex)
7458 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); 7438 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
7459 # endif 7439 # endif
7460 } 7440 }
7461 7441
7442 # if defined(FEAT_TERMGUICOLORS) || defined(PROTO)
7443 void
7444 get_default_console_color(
7445 int *cterm_fg,
7446 int *cterm_bg,
7447 guicolor_T *gui_fg,
7448 guicolor_T *gui_bg)
7449 {
7450 int id;
7451 guicolor_T guifg = INVALCOLOR;
7452 guicolor_T guibg = INVALCOLOR;
7453 int ctermfg = 0;
7454 int ctermbg = 0;
7455
7456 id = syn_name2id((char_u *)"Normal");
7457 if (id > 0 && p_tgc)
7458 syn_id2colors(id, &guifg, &guibg);
7459 if (guifg == INVALCOLOR)
7460 {
7461 ctermfg = -1;
7462 if (id > 0)
7463 syn_id2cterm_bg(id, &ctermfg, &ctermbg);
7464 guifg = ctermfg != -1 ? ctermtoxterm(ctermfg)
7465 : default_console_color_fg;
7466 cterm_normal_fg_gui_color = guifg;
7467 ctermfg = ctermfg < 0 ? 0 : ctermfg;
7468 }
7469 if (guibg == INVALCOLOR)
7470 {
7471 ctermbg = -1;
7472 if (id > 0)
7473 syn_id2cterm_bg(id, &ctermfg, &ctermbg);
7474 guibg = ctermbg != -1 ? ctermtoxterm(ctermbg)
7475 : default_console_color_bg;
7476 cterm_normal_bg_gui_color = guibg;
7477 ctermbg = ctermbg < 0 ? 0 : ctermbg;
7478 }
7479
7480 *cterm_fg = ctermfg;
7481 *cterm_bg = ctermbg;
7482 *gui_fg = guifg;
7483 *gui_bg = guibg;
7484 }
7485 # endif
7486
7462 static void 7487 static void
7463 reset_console_color_rgb(void) 7488 reset_console_color_rgb(void)
7464 { 7489 {
7465 # ifdef FEAT_TERMGUICOLORS 7490 # ifdef FEAT_TERMGUICOLORS
7466 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; 7491 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;