-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
win32: disable quickedit mode when enabling mouse support
The Windows conpty layer now allows terminal emulators other than the classic conhost.exe to host win32 console applications that use mouse events. For mouse events to function correctly, mouse input needs to be enabled and quick edit mode needs to be disabled. This commit teaches vim to make this change when it enables mouse mode. I have no special knowledge of vim, and this patch is roughly based on the suggested changes in this discussion: https://groups.google.com/g/vim_dev/c/bQ7jfMwa8Zg The intent is to enable mouse input and disable quickedit when enabling mouse mode, and to disable mouse input and restore the prior quickedit mode state when mouse mode is disabled. refs: microsoft/terminal#9970
- Loading branch information
Showing
1 changed file
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1165,6 +1165,7 @@ decode_key_event( | |
|
||
#endif // FEAT_GUI_MSWIN | ||
|
||
static DWORD g_cmodein = 0; | ||
|
||
/* | ||
* For the GUI the mouse handling is in gui_w32.c. | ||
|
@@ -1200,9 +1201,15 @@ mch_setmouse(int on) | |
GetConsoleMode(g_hConIn, &cmodein); | ||
|
||
if (g_fMouseActive) | ||
{ | ||
cmodein |= ENABLE_MOUSE_INPUT; | ||
cmodein &= ~ENABLE_QUICK_EDIT_MODE; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
k-takata
|
||
} | ||
else | ||
{ | ||
cmodein &= ~ENABLE_MOUSE_INPUT; | ||
cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE; | ||
} | ||
|
||
SetConsoleMode(g_hConIn, cmodein); | ||
} | ||
|
@@ -2782,7 +2789,6 @@ SaveConsoleTitleAndIcon(void) | |
static int g_fWindInitCalled = FALSE; | ||
static int g_fTermcapMode = FALSE; | ||
static CONSOLE_CURSOR_INFO g_cci; | ||
static DWORD g_cmodein = 0; | ||
static DWORD g_cmodeout = 0; | ||
|
||
/* | ||
|
@@ -3747,7 +3753,14 @@ mch_settmode(tmode_T tmode) | |
cmodein &= ~(ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | | ||
ENABLE_ECHO_INPUT); | ||
if (g_fMouseActive) | ||
{ | ||
cmodein |= ENABLE_MOUSE_INPUT; | ||
cmodein &= ~ENABLE_QUICK_EDIT_MODE; | ||
} | ||
else | ||
{ | ||
cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE; | ||
} | ||
cmodeout &= ~( | ||
# ifdef FEAT_TERMGUICOLORS | ||
// Do not turn off the ENABLE_PROCESSED_OUTPUT flag when using | ||
|
@@ -5621,9 +5634,15 @@ termcap_mode_start(void) | |
|
||
GetConsoleMode(g_hConIn, &cmodein); | ||
if (g_fMouseActive) | ||
{ | ||
cmodein |= ENABLE_MOUSE_INPUT; | ||
cmodein &= ~ENABLE_QUICK_EDIT_MODE; | ||
} | ||
else | ||
{ | ||
cmodein &= ~ENABLE_MOUSE_INPUT; | ||
cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE; | ||
} | ||
cmodein |= ENABLE_WINDOW_INPUT; | ||
SetConsoleMode(g_hConIn, cmodein); | ||
|
||
|
@@ -5650,6 +5669,7 @@ termcap_mode_end(void) | |
|
||
GetConsoleMode(g_hConIn, &cmodein); | ||
cmodein &= ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT); | ||
cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE; | ||
SetConsoleMode(g_hConIn, cmodein); | ||
|
||
# ifdef FEAT_RESTORE_ORIG_SCREEN | ||
|
You'll need to set
ENABLE_EXTENDED_FLAGS
to set/clear the QE mode, as it is ignored by default.