Mercurial > vim
comparison src/os_win32.c @ 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 | 2ef19eed524a |
children | 16d538568dc8 |
comparison
equal
deleted
inserted
replaced
19238:ec0bc60b3906 | 19239:c189e3826ec3 |
---|---|
198 static void vtp_sgr_bulk(int arg); | 198 static void vtp_sgr_bulk(int arg); |
199 static void vtp_sgr_bulks(int argc, int *argv); | 199 static void vtp_sgr_bulks(int argc, int *argv); |
200 | 200 |
201 static guicolor_T save_console_bg_rgb; | 201 static guicolor_T save_console_bg_rgb; |
202 static guicolor_T save_console_fg_rgb; | 202 static guicolor_T save_console_fg_rgb; |
203 static guicolor_T store_console_bg_rgb; | |
204 static guicolor_T store_console_fg_rgb; | |
203 | 205 |
204 static int g_color_index_bg = 0; | 206 static int g_color_index_bg = 0; |
205 static int g_color_index_fg = 7; | 207 static int g_color_index_fg = 7; |
206 | 208 |
207 # ifdef FEAT_TERMGUICOLORS | 209 # ifdef FEAT_TERMGUICOLORS |
215 # define USE_VTP 0 | 217 # define USE_VTP 0 |
216 # endif | 218 # endif |
217 | 219 |
218 static void set_console_color_rgb(void); | 220 static void set_console_color_rgb(void); |
219 static void reset_console_color_rgb(void); | 221 static void reset_console_color_rgb(void); |
222 static void restore_console_color_rgb(void); | |
220 #endif | 223 #endif |
221 | 224 |
222 // This flag is newly created from Windows 10 | 225 // This flag is newly created from Windows 10 |
223 #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING | 226 #ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING |
224 # define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 | 227 # define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 |
5494 cb = exiting ? &g_cbOrig : &g_cbNonTermcap; | 5497 cb = exiting ? &g_cbOrig : &g_cbNonTermcap; |
5495 # else | 5498 # else |
5496 cb = &g_cbNonTermcap; | 5499 cb = &g_cbNonTermcap; |
5497 # endif | 5500 # endif |
5498 RestoreConsoleBuffer(cb, p_rs); | 5501 RestoreConsoleBuffer(cb, p_rs); |
5499 reset_console_color_rgb(); | 5502 restore_console_color_rgb(); |
5500 SetConsoleCursorInfo(g_hConOut, &g_cci); | 5503 SetConsoleCursorInfo(g_hConOut, &g_cci); |
5501 | 5504 |
5502 if (p_rs || exiting) | 5505 if (p_rs || exiting) |
5503 { | 5506 { |
5504 /* | 5507 /* |
7325 csbi.cbSize = sizeof(csbi); | 7328 csbi.cbSize = sizeof(csbi); |
7326 if (has_csbiex) | 7329 if (has_csbiex) |
7327 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | 7330 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |
7328 save_console_bg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_bg]; | 7331 save_console_bg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_bg]; |
7329 save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg]; | 7332 save_console_fg_rgb = (guicolor_T)csbi.ColorTable[g_color_index_fg]; |
7333 store_console_bg_rgb = save_console_bg_rgb; | |
7334 store_console_fg_rgb = save_console_fg_rgb; | |
7330 | 7335 |
7331 # ifdef FEAT_TERMGUICOLORS | 7336 # ifdef FEAT_TERMGUICOLORS |
7332 bg = (COLORREF)csbi.ColorTable[g_color_index_bg]; | 7337 bg = (COLORREF)csbi.ColorTable[g_color_index_bg]; |
7333 fg = (COLORREF)csbi.ColorTable[g_color_index_fg]; | 7338 fg = (COLORREF)csbi.ColorTable[g_color_index_fg]; |
7334 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); | 7339 bg = (GetRValue(bg) << 16) | (GetGValue(bg) << 8) | GetBValue(bg); |
7341 } | 7346 } |
7342 | 7347 |
7343 static void | 7348 static void |
7344 vtp_exit(void) | 7349 vtp_exit(void) |
7345 { | 7350 { |
7346 reset_console_color_rgb(); | 7351 restore_console_color_rgb(); |
7347 } | 7352 } |
7348 | 7353 |
7349 static int | 7354 static int |
7350 vtp_printf( | 7355 vtp_printf( |
7351 char *format, | 7356 char *format, |
7431 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | 7436 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |
7432 | 7437 |
7433 csbi.cbSize = sizeof(csbi); | 7438 csbi.cbSize = sizeof(csbi); |
7434 csbi.srWindow.Right += 1; | 7439 csbi.srWindow.Right += 1; |
7435 csbi.srWindow.Bottom += 1; | 7440 csbi.srWindow.Bottom += 1; |
7441 store_console_bg_rgb = csbi.ColorTable[g_color_index_bg]; | |
7442 store_console_fg_rgb = csbi.ColorTable[g_color_index_fg]; | |
7436 csbi.ColorTable[g_color_index_bg] = (COLORREF)bg; | 7443 csbi.ColorTable[g_color_index_bg] = (COLORREF)bg; |
7437 csbi.ColorTable[g_color_index_fg] = (COLORREF)fg; | 7444 csbi.ColorTable[g_color_index_fg] = (COLORREF)fg; |
7438 if (has_csbiex) | 7445 if (has_csbiex) |
7439 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | 7446 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); |
7440 # endif | 7447 # endif |
7483 *gui_fg = guifg; | 7490 *gui_fg = guifg; |
7484 *gui_bg = guibg; | 7491 *gui_bg = guibg; |
7485 } | 7492 } |
7486 # endif | 7493 # endif |
7487 | 7494 |
7495 /* | |
7496 * Set the console colors to the original colors or the last set colors. | |
7497 */ | |
7488 static void | 7498 static void |
7489 reset_console_color_rgb(void) | 7499 reset_console_color_rgb(void) |
7500 { | |
7501 # ifdef FEAT_TERMGUICOLORS | |
7502 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; | |
7503 | |
7504 csbi.cbSize = sizeof(csbi); | |
7505 if (has_csbiex) | |
7506 pGetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | |
7507 | |
7508 csbi.cbSize = sizeof(csbi); | |
7509 csbi.srWindow.Right += 1; | |
7510 csbi.srWindow.Bottom += 1; | |
7511 csbi.ColorTable[g_color_index_bg] = (COLORREF)store_console_bg_rgb; | |
7512 csbi.ColorTable[g_color_index_fg] = (COLORREF)store_console_fg_rgb; | |
7513 if (has_csbiex) | |
7514 pSetConsoleScreenBufferInfoEx(g_hConOut, &csbi); | |
7515 # endif | |
7516 } | |
7517 | |
7518 /* | |
7519 * Set the console colors to the original colors. | |
7520 */ | |
7521 static void | |
7522 restore_console_color_rgb(void) | |
7490 { | 7523 { |
7491 # ifdef FEAT_TERMGUICOLORS | 7524 # ifdef FEAT_TERMGUICOLORS |
7492 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; | 7525 DYN_CONSOLE_SCREEN_BUFFER_INFOEX csbi; |
7493 | 7526 |
7494 csbi.cbSize = sizeof(csbi); | 7527 csbi.cbSize = sizeof(csbi); |