diff options
Diffstat (limited to 'src/os_win32.c')
-rw-r--r-- | src/os_win32.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/os_win32.c b/src/os_win32.c index 0cb311337..8278ddd02 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -214,7 +214,7 @@ static guicolor_T save_console_bg_rgb; static guicolor_T save_console_fg_rgb; # ifdef FEAT_TERMGUICOLORS -# define USE_VTP (vtp_working && p_tgc) +# define USE_VTP (vtp_working && is_term_win32() && (p_tgc || (!p_tgc && t_colors >= 256))) # else # define USE_VTP 0 # endif @@ -2630,7 +2630,6 @@ mch_init(void) /* set termcap codes to current text attributes */ update_tcap(g_attrCurrent); - swap_tcap(); GetConsoleCursorInfo(g_hConOut, &g_cci); GetConsoleMode(g_hConIn, &g_cmodein); @@ -5763,7 +5762,11 @@ clear_chars( if (!USE_VTP) FillConsoleOutputAttribute(g_hConOut, g_attrCurrent, n, coord, &dwDummy); else - FillConsoleOutputAttribute(g_hConOut, 0, n, coord, &dwDummy); + { + set_console_color_rgb(); + gotoxy(coord.X + 1, coord.Y + 1); + vtp_printf("\033[%dX", n); + } } @@ -7653,6 +7656,16 @@ vtp_sgr_bulks( vtp_printf((char *)buf); } + static int +ctermtoxterm( + int cterm) +{ + uint8_t r, g, b, idx; + + cterm_color2rgb(cterm, &r, &g, &b, &idx); + return (((int)r << 16) | ((int)g << 8) | (int)b); +} + static void set_console_color_rgb(void) { @@ -7661,6 +7674,8 @@ set_console_color_rgb(void) int id; guicolor_T fg = INVALCOLOR; guicolor_T bg = INVALCOLOR; + int ctermfg; + int ctermbg; if (!USE_VTP) return; @@ -7669,9 +7684,19 @@ set_console_color_rgb(void) if (id > 0) syn_id2colors(id, &fg, &bg); if (fg == INVALCOLOR) - fg = 0xc0c0c0; /* white text */ + { + ctermfg = -1; + if (id > 0) + syn_id2cterm_bg(id, &ctermfg, &ctermbg); + fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : 0xc0c0c0; /* white */ + } if (bg == INVALCOLOR) - bg = 0x000000; /* black background */ + { + ctermbg = -1; + if (id > 0) + syn_id2cterm_bg(id, &ctermfg, &ctermbg); + bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : 0x000000; /* black */ + } fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg); bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); @@ -7730,4 +7755,10 @@ use_vtp(void) return USE_VTP; } + int +is_term_win32(void) +{ + return T_NAME != NULL && STRCMP(T_NAME, "win32") == 0; +} + #endif |