mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
patch 9.0.0868: MS-Windows: after Vim exits console resizing problem
Problem: MS-Windows: after Vim exits console resizing does not work properly. Solution: Restore screen behavior checks for various WT and VTP combinations. (Christopher Plewright, closes #11526, closes #11507)
This commit is contained in:
parent
d6e91385f0
commit
1140b51e83
@ -202,7 +202,7 @@ static void vtp_sgr_bulk(int arg);
|
|||||||
static void vtp_sgr_bulks(int argc, int *argv);
|
static void vtp_sgr_bulks(int argc, int *argv);
|
||||||
|
|
||||||
static int wt_working = 0;
|
static int wt_working = 0;
|
||||||
static void wt_init();
|
static void wt_init(void);
|
||||||
|
|
||||||
static int g_color_index_bg = 0;
|
static int g_color_index_bg = 0;
|
||||||
static int g_color_index_fg = 7;
|
static int g_color_index_fg = 7;
|
||||||
@ -238,6 +238,7 @@ static int suppress_winsize = 1; // don't fiddle with console
|
|||||||
static char_u *exe_path = NULL;
|
static char_u *exe_path = NULL;
|
||||||
|
|
||||||
static BOOL win8_or_later = FALSE;
|
static BOOL win8_or_later = FALSE;
|
||||||
|
static BOOL win11_or_later = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get version number including build number
|
* Get version number including build number
|
||||||
@ -893,6 +894,10 @@ PlatformId(void)
|
|||||||
|| ovi.dwMajorVersion > 6)
|
|| ovi.dwMajorVersion > 6)
|
||||||
win8_or_later = TRUE;
|
win8_or_later = TRUE;
|
||||||
|
|
||||||
|
if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 22000)
|
||||||
|
|| ovi.dwMajorVersion > 10)
|
||||||
|
win11_or_later = TRUE;
|
||||||
|
|
||||||
#ifdef HAVE_ACL
|
#ifdef HAVE_ACL
|
||||||
// Enable privilege for getting or setting SACLs.
|
// Enable privilege for getting or setting SACLs.
|
||||||
win32_enable_privilege(SE_SECURITY_NAME, TRUE);
|
win32_enable_privilege(SE_SECURITY_NAME, TRUE);
|
||||||
@ -2683,6 +2688,11 @@ SaveConsoleBuffer(
|
|||||||
}
|
}
|
||||||
cb->IsValid = TRUE;
|
cb->IsValid = TRUE;
|
||||||
|
|
||||||
|
// VTP uses alternate screen buffer.
|
||||||
|
// No need to save buffer contents for restoration.
|
||||||
|
if (win11_or_later && vtp_working)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a buffer large enough to hold the entire console screen
|
* Allocate a buffer large enough to hold the entire console screen
|
||||||
* buffer. If this ConsoleBuffer structure has already been initialized
|
* buffer. If this ConsoleBuffer structure has already been initialized
|
||||||
@ -2776,6 +2786,11 @@ RestoreConsoleBuffer(
|
|||||||
SMALL_RECT WriteRegion;
|
SMALL_RECT WriteRegion;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
// VTP uses alternate screen buffer.
|
||||||
|
// No need to restore buffer contents.
|
||||||
|
if (win11_or_later && vtp_working)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
if (cb == NULL || !cb->IsValid)
|
if (cb == NULL || !cb->IsValid)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -5736,7 +5751,9 @@ termcap_mode_start(void)
|
|||||||
if (g_fTermcapMode)
|
if (g_fTermcapMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!p_rs && USE_VTP)
|
// VTP uses alternate screen buffer.
|
||||||
|
// Switch to a new alternate screen buffer.
|
||||||
|
if (win11_or_later && p_rs && vtp_working)
|
||||||
vtp_printf("\033[?1049h");
|
vtp_printf("\033[?1049h");
|
||||||
|
|
||||||
SaveConsoleBuffer(&g_cbNonTermcap);
|
SaveConsoleBuffer(&g_cbNonTermcap);
|
||||||
@ -5816,15 +5833,20 @@ termcap_mode_end(void)
|
|||||||
# endif
|
# endif
|
||||||
RestoreConsoleBuffer(cb, p_rs);
|
RestoreConsoleBuffer(cb, p_rs);
|
||||||
restore_console_color_rgb();
|
restore_console_color_rgb();
|
||||||
SetConsoleCursorInfo(g_hConOut, &g_cci);
|
|
||||||
|
|
||||||
if (p_rs || exiting)
|
// VTP uses alternate screen buffer.
|
||||||
|
// Switch back to main screen buffer.
|
||||||
|
if (exiting && win11_or_later && p_rs && vtp_working)
|
||||||
|
vtp_printf("\033[?1049l");
|
||||||
|
|
||||||
|
if (!USE_WT && (p_rs || exiting))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Clear anything that happens to be on the current line.
|
* Clear anything that happens to be on the current line.
|
||||||
*/
|
*/
|
||||||
coord.X = 0;
|
coord.X = 0;
|
||||||
coord.Y = (SHORT) (p_rs ? cb->Info.dwCursorPosition.Y : (Rows - 1));
|
coord.Y = (SHORT) (p_rs ? cb->Info.dwCursorPosition.Y : (Rows - 1));
|
||||||
|
if (!vtp_working)
|
||||||
FillConsoleOutputCharacter(g_hConOut, ' ',
|
FillConsoleOutputCharacter(g_hConOut, ' ',
|
||||||
cb->Info.dwSize.X, coord, &dwDummy);
|
cb->Info.dwSize.X, coord, &dwDummy);
|
||||||
/*
|
/*
|
||||||
@ -5842,10 +5864,7 @@ termcap_mode_end(void)
|
|||||||
*/
|
*/
|
||||||
SetConsoleCursorPosition(g_hConOut, coord);
|
SetConsoleCursorPosition(g_hConOut, coord);
|
||||||
}
|
}
|
||||||
|
SetConsoleCursorInfo(g_hConOut, &g_cci);
|
||||||
if (!p_rs && USE_VTP)
|
|
||||||
vtp_printf("\033[?1049l");
|
|
||||||
|
|
||||||
g_fTermcapMode = FALSE;
|
g_fTermcapMode = FALSE;
|
||||||
}
|
}
|
||||||
#endif // !FEAT_GUI_MSWIN || VIMDLL
|
#endif // !FEAT_GUI_MSWIN || VIMDLL
|
||||||
@ -7946,8 +7965,12 @@ mch_setenv(char *var, char *value, int x UNUSED)
|
|||||||
* Not stable now.
|
* Not stable now.
|
||||||
*/
|
*/
|
||||||
#define CONPTY_STABLE_BUILD MAKE_VER(10, 0, 32767) // T.B.D.
|
#define CONPTY_STABLE_BUILD MAKE_VER(10, 0, 32767) // T.B.D.
|
||||||
// Note: Windows 11 (build >= 22000 means Windows 11, even though the major
|
// Notes:
|
||||||
// version says 10!)
|
// Win 10 22H2 Final is build 19045, it's conpty is widely used.
|
||||||
|
// Strangely, 19045 is newer but is a lower build number than the 2020 insider
|
||||||
|
// preview which had a build 19587. And, not sure how stable that was?
|
||||||
|
// Win Server 2022 (May 10, 2022) is build 20348, its conpty is widely used.
|
||||||
|
// Win 11 starts from build 22000, even though the major version says 10!
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vtp_flag_init(void)
|
vtp_flag_init(void)
|
||||||
@ -8202,13 +8225,7 @@ vtp_sgr_bulks(
|
|||||||
static void
|
static void
|
||||||
wt_init(void)
|
wt_init(void)
|
||||||
{
|
{
|
||||||
wt_working = (mch_getenv("WT_SESSION") != NULL);
|
wt_working = mch_getenv("WT_SESSION") != NULL;
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
use_wt(void)
|
|
||||||
{
|
|
||||||
return USE_WT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef FEAT_TERMGUICOLORS
|
# ifdef FEAT_TERMGUICOLORS
|
||||||
|
@ -72,7 +72,6 @@ void set_alist_count(void);
|
|||||||
void fix_arg_enc(void);
|
void fix_arg_enc(void);
|
||||||
int mch_setenv(char *var, char *value, int x);
|
int mch_setenv(char *var, char *value, int x);
|
||||||
int vtp_printf(char *format, ...);
|
int vtp_printf(char *format, ...);
|
||||||
int use_wt(void);
|
|
||||||
void get_default_console_color(int *cterm_fg, int *cterm_bg, guicolor_T *gui_fg, guicolor_T *gui_bg);
|
void get_default_console_color(int *cterm_fg, int *cterm_bg, guicolor_T *gui_fg, guicolor_T *gui_bg);
|
||||||
void control_console_color_rgb(void);
|
void control_console_color_rgb(void);
|
||||||
int use_vtp(void);
|
int use_vtp(void);
|
||||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
868,
|
||||||
/**/
|
/**/
|
||||||
867,
|
867,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user