summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-30 17:47:05 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-30 17:47:05 +0200
commitf6ceaf1e058c64775fd46cbdb8962f5c19ef83e0 (patch)
tree29417a9b32b7ef2b5b981daaf5aea35dbeb85b5a
parent379fb76b080521f7c09265ec3264b9e698923518 (diff)
patch 8.1.0338: MS-Windows: VTP doesn't work properly with Powershellv8.1.0338
Problem: MS-Windows: VTP doesn't work properly with Powershell. Solution: Adjust the color index. (Nobuhiro Takasaki, closes #3347)
-rw-r--r--src/os_win32.c42
-rw-r--r--src/version.c2
2 files changed, 36 insertions, 8 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index 2cfcecfc1c..02bcaaede9 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -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
diff --git a/src/version.c b/src/version.c
index 12c86aaba7..7dd15914e5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -795,6 +795,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 338,
+/**/
337,
/**/
336,