comparison src/os_win32.c @ 19983:8f2bc094acee v8.2.0547

patch 8.2.0547: Win32: restoring screen not always done right Commit: https://github.com/vim/vim/commit/e7f234120f71a75f0c7c2a67e0b70c6450c50a02 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 11 22:38:34 2020 +0200 patch 8.2.0547: Win32: restoring screen not always done right Problem: Win32: restoring screen not always done right. Solution: Use a more appropriate method. (Nobuhiro Takasaki, closes https://github.com/vim/vim/issues/5909)
author Bram Moolenaar <Bram@vim.org>
date Sat, 11 Apr 2020 22:45:04 +0200
parents a2fa2fc0f403
children aadd1cae2ff5
comparison
equal deleted inserted replaced
19982:30238b032e54 19983:8f2bc094acee
2610 g_hConIn = GetStdHandle(STD_INPUT_HANDLE); 2610 g_hConIn = GetStdHandle(STD_INPUT_HANDLE);
2611 else 2611 else
2612 create_conin(); 2612 create_conin();
2613 g_hConOut = GetStdHandle(STD_OUTPUT_HANDLE); 2613 g_hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
2614 2614
2615 vtp_flag_init();
2616
2615 # ifdef FEAT_RESTORE_ORIG_SCREEN 2617 # ifdef FEAT_RESTORE_ORIG_SCREEN
2616 // Save the initial console buffer for later restoration 2618 // Save the initial console buffer for later restoration
2619 if (vtp_working && p_rs)
2620 vtp_printf("\033[?1049h");
2617 SaveConsoleBuffer(&g_cbOrig); 2621 SaveConsoleBuffer(&g_cbOrig);
2618 g_attrCurrent = g_attrDefault = g_cbOrig.Info.wAttributes; 2622 g_attrCurrent = g_attrDefault = g_cbOrig.Info.wAttributes;
2619 # else 2623 # else
2620 // Get current text attributes 2624 // Get current text attributes
2621 GetConsoleScreenBufferInfo(g_hConOut, &csbi); 2625 GetConsoleScreenBufferInfo(g_hConOut, &csbi);
2669 2673
2670 # ifdef FEAT_CLIPBOARD 2674 # ifdef FEAT_CLIPBOARD
2671 win_clip_init(); 2675 win_clip_init();
2672 # endif 2676 # endif
2673 2677
2674 vtp_flag_init();
2675 vtp_init(); 2678 vtp_init();
2676 } 2679 }
2677 2680
2678 /* 2681 /*
2679 * non-GUI version of mch_exit(). 2682 * non-GUI version of mch_exit().
5429 DWORD cmodein; 5432 DWORD cmodein;
5430 5433
5431 if (g_fTermcapMode) 5434 if (g_fTermcapMode)
5432 return; 5435 return;
5433 5436
5434 if (!p_rs && USE_VTP)
5435 vtp_printf("\033[?1049h");
5436
5437 SaveConsoleBuffer(&g_cbNonTermcap); 5437 SaveConsoleBuffer(&g_cbNonTermcap);
5438 5438
5439 if (g_cbTermcap.IsValid) 5439 if (g_cbTermcap.IsValid)
5440 { 5440 {
5441 /* 5441 /*
5499 cmodein &= ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT); 5499 cmodein &= ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT);
5500 SetConsoleMode(g_hConIn, cmodein); 5500 SetConsoleMode(g_hConIn, cmodein);
5501 5501
5502 # ifdef FEAT_RESTORE_ORIG_SCREEN 5502 # ifdef FEAT_RESTORE_ORIG_SCREEN
5503 cb = exiting ? &g_cbOrig : &g_cbNonTermcap; 5503 cb = exiting ? &g_cbOrig : &g_cbNonTermcap;
5504 if (!(vtp_working && exiting))
5504 # else 5505 # else
5505 cb = &g_cbNonTermcap; 5506 cb = &g_cbNonTermcap;
5506 # endif 5507 # endif
5507 RestoreConsoleBuffer(cb, p_rs); 5508 RestoreConsoleBuffer(cb, p_rs);
5508 restore_console_color_rgb(); 5509 restore_console_color_rgb();
5509 SetConsoleCursorInfo(g_hConOut, &g_cci); 5510 SetConsoleCursorInfo(g_hConOut, &g_cci);
5510 5511
5511 if (p_rs || exiting) 5512 if (p_rs || exiting)
5512 { 5513 {
5528 if (exiting && !p_rs) 5529 if (exiting && !p_rs)
5529 coord.Y--; 5530 coord.Y--;
5530 /* 5531 /*
5531 * Position the cursor at the leftmost column of the desired row. 5532 * Position the cursor at the leftmost column of the desired row.
5532 */ 5533 */
5533 SetConsoleCursorPosition(g_hConOut, coord); 5534 # ifdef FEAT_RESTORE_ORG_SCREEN
5534 } 5535 if (!(vtp_working && exiting))
5535 5536 # endif
5536 if (!p_rs && USE_VTP) 5537 SetConsoleCursorPosition(g_hConOut, coord);
5538 }
5539
5540 # ifdef FEAT_RESTORE_ORIG_SCREEN
5541 if (vtp_working && p_rs && exiting)
5537 vtp_printf("\033[?1049l"); 5542 vtp_printf("\033[?1049l");
5543 # endif
5538 5544
5539 g_fTermcapMode = FALSE; 5545 g_fTermcapMode = FALSE;
5540 } 5546 }
5541 #endif // FEAT_GUI_MSWIN 5547 #endif // FEAT_GUI_MSWIN
5542 5548