Skip to content

Commit 6ef5ab5

Browse files
wezbrammool
authored andcommitted
patch 8.2.2913: MS-Windows conpty supports using mouse events
Problem: MS-Windows conpty supports using mouse events. Solution: When enabling the mouse enable mouse input and disable quick edit mode. (Wez Furlong, closes #8280)
1 parent f883d90 commit 6ef5ab5

2 files changed

Lines changed: 29 additions & 7 deletions

File tree

src/os_win32.c

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,8 @@ static int g_fMouseActive = FALSE; // mouse enabled
11801180
static int g_nMouseClick = -1; // mouse status
11811181
static int g_xMouse; // mouse x coordinate
11821182
static int g_yMouse; // mouse y coordinate
1183+
static DWORD g_cmodein = 0; // Original console input mode
1184+
static DWORD g_cmodeout = 0; // Original console output mode
11831185

11841186
/*
11851187
* Enable or disable mouse input
@@ -1200,11 +1202,17 @@ mch_setmouse(int on)
12001202
GetConsoleMode(g_hConIn, &cmodein);
12011203

12021204
if (g_fMouseActive)
1205+
{
12031206
cmodein |= ENABLE_MOUSE_INPUT;
1207+
cmodein &= ~ENABLE_QUICK_EDIT_MODE;
1208+
}
12041209
else
1210+
{
12051211
cmodein &= ~ENABLE_MOUSE_INPUT;
1212+
cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE;
1213+
}
12061214

1207-
SetConsoleMode(g_hConIn, cmodein);
1215+
SetConsoleMode(g_hConIn, cmodein | ENABLE_EXTENDED_FLAGS);
12081216
}
12091217

12101218

@@ -2782,8 +2790,6 @@ SaveConsoleTitleAndIcon(void)
27822790
static int g_fWindInitCalled = FALSE;
27832791
static int g_fTermcapMode = FALSE;
27842792
static CONSOLE_CURSOR_INFO g_cci;
2785-
static DWORD g_cmodein = 0;
2786-
static DWORD g_cmodeout = 0;
27872793

27882794
/*
27892795
* non-GUI version of mch_init().
@@ -2924,7 +2930,7 @@ mch_exit_c(int r)
29242930
}
29252931

29262932
SetConsoleCursorInfo(g_hConOut, &g_cci);
2927-
SetConsoleMode(g_hConIn, g_cmodein);
2933+
SetConsoleMode(g_hConIn, g_cmodein | ENABLE_EXTENDED_FLAGS);
29282934
SetConsoleMode(g_hConOut, g_cmodeout);
29292935

29302936
# ifdef DYNAMIC_GETTEXT
@@ -3747,7 +3753,14 @@ mch_settmode(tmode_T tmode)
37473753
cmodein &= ~(ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT |
37483754
ENABLE_ECHO_INPUT);
37493755
if (g_fMouseActive)
3756+
{
37503757
cmodein |= ENABLE_MOUSE_INPUT;
3758+
cmodein &= ~ENABLE_QUICK_EDIT_MODE;
3759+
}
3760+
else
3761+
{
3762+
cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE;
3763+
}
37513764
cmodeout &= ~(
37523765
# ifdef FEAT_TERMGUICOLORS
37533766
// Do not turn off the ENABLE_PROCESSED_OUTPUT flag when using
@@ -3766,7 +3779,7 @@ mch_settmode(tmode_T tmode)
37663779
cmodeout |= (ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT);
37673780
bEnableHandler = FALSE;
37683781
}
3769-
SetConsoleMode(g_hConIn, cmodein);
3782+
SetConsoleMode(g_hConIn, cmodein | ENABLE_EXTENDED_FLAGS);
37703783
SetConsoleMode(g_hConOut, cmodeout);
37713784
SetConsoleCtrlHandler(handler_routine, bEnableHandler);
37723785

@@ -5621,11 +5634,17 @@ termcap_mode_start(void)
56215634

56225635
GetConsoleMode(g_hConIn, &cmodein);
56235636
if (g_fMouseActive)
5637+
{
56245638
cmodein |= ENABLE_MOUSE_INPUT;
5639+
cmodein &= ~ENABLE_QUICK_EDIT_MODE;
5640+
}
56255641
else
5642+
{
56265643
cmodein &= ~ENABLE_MOUSE_INPUT;
5644+
cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE;
5645+
}
56275646
cmodein |= ENABLE_WINDOW_INPUT;
5628-
SetConsoleMode(g_hConIn, cmodein);
5647+
SetConsoleMode(g_hConIn, cmodein | ENABLE_EXTENDED_FLAGS);
56295648

56305649
redraw_later_clear();
56315650
g_fTermcapMode = TRUE;
@@ -5650,7 +5669,8 @@ termcap_mode_end(void)
56505669

56515670
GetConsoleMode(g_hConIn, &cmodein);
56525671
cmodein &= ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT);
5653-
SetConsoleMode(g_hConIn, cmodein);
5672+
cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE;
5673+
SetConsoleMode(g_hConIn, cmodein | ENABLE_EXTENDED_FLAGS);
56545674

56555675
# ifdef FEAT_RESTORE_ORIG_SCREEN
56565676
cb = exiting ? &g_cbOrig : &g_cbNonTermcap;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2913,
753755
/**/
754756
2912,
755757
/**/

0 commit comments

Comments
 (0)