summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-01-30 11:53:59 +0100
committerBram Moolenaar <Bram@vim.org>2020-01-30 11:53:59 +0100
commitdf54382eacdbfa10291adb80ad6b89ad83bd7c9b (patch)
tree606046b076419a8e32df9d2e6383083792567261
parent70b3e706b40fc2c84c1f9f33fa64945a481df395 (diff)
patch 8.2.0178: with VTP the screen may not be restored properlyv8.2.0178
Problem: With VTP the screen may not be restored properly. Solution: Add another set of saved RGB values. (Nobuhiro Takasaki, closes #5548)
-rw-r--r--src/os_win32.c37
-rw-r--r--src/version.c2
2 files changed, 37 insertions, 2 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index 6bbd492055..7dc37a1114 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -200,6 +200,8 @@ static void vtp_sgr_bulks(int argc, int *argv);
static guicolor_T save_console_bg_rgb;
static guicolor_T save_console_fg_rgb;
+static guicolor_T store_console_bg_rgb;
+static guicolor_T store_console_fg_rgb;
static int g_color_index_bg = 0;
static int g_color_index_fg = 7;
@@ -217,6 +219,7 @@ static int default_console_color_fg = 0xc0c0c0; // white
static void set_console_color_rgb(void);
static void reset_console_color_rgb(void);
+static void restore_console_color_rgb(void);
#endif
// This flag is newly created from Windows 10
@@ -5496,7 +5499,7 @@ termcap_mode_end(void)
cb = &g_cbNonTermcap;
# endif
RestoreConsoleBuffer(cb, p_rs);
- reset_console_color_rgb();
+ restore_console_color_rgb();
SetConsoleCursorInfo(g_hConOut, &g_cci);
if (p_rs || exiting)
@@ -7327,6 +7330,8 @@ vtp_init(void)
pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
save_console_bg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_bg];
save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg];
+ store_console_bg_rgb = save_console_bg_rgb;
+ store_console_fg_rgb = save_console_fg_rgb;
# ifdef FEAT_TERMGUICOLORS
bg = (COLORREF)csbi.ColorTable[g_color_index_bg];
@@ -7343,7 +7348,7 @@ vtp_init(void)
static void
vtp_exit(void)
{
- reset_console_color_rgb();
+ restore_console_color_rgb();
}
static int
@@ -7433,6 +7438,8 @@ set_console_color_rgb(void)
csbi.cbSize = sizeof(csbi);
csbi.srWindow.Right += 1;
csbi.srWindow.Bottom += 1;
+ store_console_bg_rgb = csbi.ColorTable[g_color_index_bg];
+ store_console_fg_rgb = csbi.ColorTable[g_color_index_fg];
csbi.ColorTable[g_color_index_bg] = (COLORREF)bg;
csbi.ColorTable[g_color_index_fg] = (COLORREF)fg;
if (has_csbiex)
@@ -7485,6 +7492,9 @@ get_default_console_color(
}
# endif
+/*
+ * Set the console colors to the original colors or the last set colors.
+ */
static void
reset_console_color_rgb(void)
{
@@ -7498,6 +7508,29 @@ reset_console_color_rgb(void)
csbi.cbSize = sizeof(csbi);
csbi.srWindow.Right += 1;
csbi.srWindow.Bottom += 1;
+ csbi.ColorTable[g_color_index_bg] = (COLORREF)store_console_bg_rgb;
+ csbi.ColorTable[g_color_index_fg] = (COLORREF)store_console_fg_rgb;
+ if (has_csbiex)
+ pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
+# endif
+}
+
+/*
+ * Set the console colors to the original colors.
+ */
+ static void
+restore_console_color_rgb(void)
+{
+# ifdef FEAT_TERMGUICOLORS
+ DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi;
+
+ csbi.cbSize = sizeof(csbi);
+ if (has_csbiex)
+ pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi);
+
+ csbi.cbSize = sizeof(csbi);
+ csbi.srWindow.Right += 1;
+ csbi.srWindow.Bottom += 1;
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)
diff --git a/src/version.c b/src/version.c
index e6935a289b..3d4b1cbcc0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 178,
+/**/
177,
/**/
176,