changeset 19239:c189e3826ec3 v8.2.0178

patch 8.2.0178: with VTP the screen may not be restored properly Commit: https://github.com/vim/vim/commit/df54382eacdbfa10291adb80ad6b89ad83bd7c9b Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 30 11:53:59 2020 +0100 patch 8.2.0178: with VTP the screen may not be restored properly Problem: With VTP the screen may not be restored properly. Solution: Add another set of saved RGB values. (Nobuhiro Takasaki, closes #5548)
author Bram Moolenaar <Bram@vim.org>
date Thu, 30 Jan 2020 12:00:09 +0100
parents ec0bc60b3906
children b30a4b89d48f
files src/os_win32.c src/version.c
diffstat 2 files changed, 37 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -200,6 +200,8 @@ static void vtp_sgr_bulks(int argc, int 
 
 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 = 0x
 
 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)
--- 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,