forked from aniani/vim
patch 8.1.0338: MS-Windows: VTP doesn't work properly with Powershell
Problem: MS-Windows: VTP doesn't work properly with Powershell. Solution: Adjust the color index. (Nobuhiro Takasaki, closes #3347)
This commit is contained in:
@@ -213,6 +213,14 @@ static void vtp_sgr_bulks(int argc, int *argv);
|
||||
static guicolor_T save_console_bg_rgb;
|
||||
static guicolor_T save_console_fg_rgb;
|
||||
|
||||
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
|
||||
|
||||
# ifdef FEAT_TERMGUICOLORS
|
||||
# define USE_VTP (vtp_working && is_term_win32() && (p_tgc || (!p_tgc && t_colors >= 256)))
|
||||
# else
|
||||
@@ -2628,6 +2636,10 @@ mch_init(void)
|
||||
if (cterm_normal_bg_color == 0)
|
||||
cterm_normal_bg_color = ((g_attrCurrent >> 4) & 0xf) + 1;
|
||||
|
||||
// Fg and Bg color index nunmber at startup
|
||||
g_color_index_fg = g_attrDefault & 0xf;
|
||||
g_color_index_bg = (g_attrDefault >> 4) & 0xf;
|
||||
|
||||
/* set termcap codes to current text attributes */
|
||||
update_tcap(g_attrCurrent);
|
||||
|
||||
@@ -7664,6 +7676,9 @@ vtp_init(void)
|
||||
DWORD ver, mode;
|
||||
HMODULE hKerneldll;
|
||||
DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
|
||||
# ifdef FEAT_TERMGUICOLORS
|
||||
COLORREF fg, bg;
|
||||
# endif
|
||||
|
||||
ver = get_build_number();
|
||||
vtp_working = (ver >= VTP_FIRST_SUPPORT_BUILD) ? 1 : 0;
|
||||
@@ -7690,8 +7705,17 @@ vtp_init(void)
|
||||
csbi.cbSize = sizeof(csbi);
|
||||
if (has_csbiex)
|
||||
pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
|
||||
save_console_bg_rgb = (guicolor_T)csbi.ColorTable[0];
|
||||
save_console_fg_rgb = (guicolor_T)csbi.ColorTable[7];
|
||||
save_console_bg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_bg];
|
||||
save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg];
|
||||
|
||||
# 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
|
||||
|
||||
set_console_color_rgb();
|
||||
}
|
||||
@@ -7788,14 +7812,16 @@ set_console_color_rgb(void)
|
||||
ctermfg = -1;
|
||||
if (id > 0)
|
||||
syn_id2cterm_bg(id, &ctermfg, &ctermbg);
|
||||
fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : 0xc0c0c0; /* white */
|
||||
fg = ctermfg != -1 ? ctermtoxterm(ctermfg) : default_console_color_fg;
|
||||
cterm_normal_fg_gui_color = fg;
|
||||
}
|
||||
if (bg == INVALCOLOR)
|
||||
{
|
||||
ctermbg = -1;
|
||||
if (id > 0)
|
||||
syn_id2cterm_bg(id, &ctermfg, &ctermbg);
|
||||
bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : 0x000000; /* black */
|
||||
bg = ctermbg != -1 ? ctermtoxterm(ctermbg) : default_console_color_bg;
|
||||
cterm_normal_bg_gui_color = bg;
|
||||
}
|
||||
fg = (GetRValue(fg) << 16) | (GetGValue(fg) << 8) | GetBValue(fg);
|
||||
bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg);
|
||||
@@ -7807,8 +7833,8 @@ set_console_color_rgb(void)
|
||||
csbi.cbSize = sizeof(csbi);
|
||||
csbi.srWindow.Right += 1;
|
||||
csbi.srWindow.Bottom += 1;
|
||||
csbi.ColorTable[0] = (COLORREF)bg;
|
||||
csbi.ColorTable[7] = (COLORREF)fg;
|
||||
csbi.ColorTable[g_color_index_bg] = (COLORREF)bg;
|
||||
csbi.ColorTable[g_color_index_fg] = (COLORREF)fg;
|
||||
if (has_csbiex)
|
||||
pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
|
||||
# endif
|
||||
@@ -7827,8 +7853,8 @@ reset_console_color_rgb(void)
|
||||
csbi.cbSize = sizeof(csbi);
|
||||
csbi.srWindow.Right += 1;
|
||||
csbi.srWindow.Bottom += 1;
|
||||
csbi.ColorTable[0] = (COLORREF)save_console_bg_rgb;
|
||||
csbi.ColorTable[7] = (COLORREF)save_console_fg_rgb;
|
||||
csbi.ColorTable[g_color_index_bg] = (COLORREF)save_console_bg_rgb;
|
||||
csbi.ColorTable[g_color_index_fg] = (COLORREF)save_console_fg_rgb;
|
||||
if (has_csbiex)
|
||||
pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
|
||||
# endif
|
||||
|
||||
@@ -794,6 +794,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
338,
|
||||
/**/
|
||||
337,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user