[vim/vim] win32: disable quickedit mode when enabling mouse support (#8280)

105 views
Skip to first unread message

Wez Furlong

unread,
May 28, 2021, 1:13:30 PM5/28/21
to vim/vim, Subscribed

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


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/8280

Commit Summary

  • win32: disable quickedit mode when enabling mouse support

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

K.Takata

unread,
May 28, 2021, 1:30:24 PM5/28/21
to vim/vim, Subscribed

@k-takata commented on this pull request.


In src/os_win32.c:

> @@ -1165,6 +1165,7 @@ decode_key_event(
 
 #endif // FEAT_GUI_MSWIN
 
+static DWORD g_cmodein = 0;

This line should be moved to near line 1184 because this variable is not needed for the GUI.


In src/os_win32.c:

> @@ -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;

I think it's better to move g_cmodeout together with g_cmodein for readability.

Wez Furlong

unread,
May 28, 2021, 1:38:43 PM5/28/21
to vim/vim, Push

@wez pushed 1 commit.


You are receiving this because you are subscribed to this thread.

View it on GitHub or unsubscribe.

K.Takata

unread,
May 28, 2021, 1:46:55 PM5/28/21
to vim/vim, Subscribed

Doesn't the line cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE; need to be added after here? https://github.com/vim/vim/pull/8280/files#diff-6e09d275741ed4a17372f6e64995645e818d605e41a0591b2c20741f4878d3c1R3778-R3779

Wez Furlong

unread,
May 28, 2021, 2:24:32 PM5/28/21
to vim/vim, Push

@wez pushed 1 commit.

  • c4d83e8 always set ENABLE_EXTENDED_FLAGS when calling SetConsoleMode for input


You are receiving this because you are subscribed to this thread.

Wez Furlong

unread,
May 28, 2021, 2:25:28 PM5/28/21
to vim/vim, Subscribed

Doesn't the line cmodein |= g_cmodein & ENABLE_QUICK_EDIT_MODE; need to be added after here? https://github.com/vim/vim/pull/8280/files#diff-6e09d275741ed4a17372f6e64995645e818d605e41a0591b2c20741f4878d3c1R3778-R3779

Yeah, good catch! I've restructured this a bit to always set the extended flags when setting the input mode so that it is harder to overlook this again!

codecov[bot]

unread,
May 28, 2021, 3:49:35 PM5/28/21
to vim/vim, Subscribed

Codecov Report

Merging #8280 (c4d83e8) into master (dc3275a) will decrease coverage by 87.03%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@

##           master    #8280       +/-   ##

===========================================

- Coverage   89.53%    2.50%   -87.04%     

===========================================

  Files         148      146        -2     

  Lines      167020   161877     -5143     

===========================================

- Hits       149544     4050   -145494     

- Misses      17476   157827   +140351     
Flag Coverage Δ
huge-clang-none ?
huge-gcc-none ?
huge-gcc-testgui ?
huge-gcc-unittests 2.50% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/sha256.c 0.00% <0.00%> (-97.96%) ⬇️
src/digraph.c 0.00% <0.00%> (-97.78%) ⬇️
src/gui_gtk_f.c 0.00% <0.00%> (-97.54%) ⬇️
src/match.c 0.00% <0.00%> (-97.13%) ⬇️
src/crypt_zip.c 0.00% <0.00%> (-97.06%) ⬇️
src/evalbuffer.c 0.00% <0.00%> (-96.83%) ⬇️
src/debugger.c 0.00% <0.00%> (-96.62%) ⬇️
src/libvterm/src/rect.h 0.00% <0.00%> (-96.56%) ⬇️
src/evalfunc.c 0.00% <0.00%> (-96.51%) ⬇️
src/textprop.c 0.00% <0.00%> (-96.45%) ⬇️
... and 134 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc3275a...c4d83e8. Read the comment docs.

Bram Moolenaar

unread,
May 29, 2021, 1:39:17 PM5/29/21
to vim/vim, Subscribed

Can some people try this out and give feedback?

Wez Furlong

unread,
May 29, 2021, 1:50:57 PM5/29/21
to vim/vim, Subscribed

If someone wants to give it a try, my manual test plan for this is:

  • Install either the latest version of Windows Terminal Preview (from the MS Store, or download from GitHub) or the Nightly WezTerm build (https://wezfurlong.org/wezterm/install/windows.html)
  • Run vim.exe
  • :set mouse=a
  • Drag the status line or otherwise try to use the mouse for mouse selection of something

Without this change, the mouse won't function.

After exiting vim, run a vim.exe without this change: mouse shouldn't work there because quickedit status should have been restored to its default enabled state when vim exited.

Wez Furlong

unread,
May 29, 2021, 1:53:54 PM5/29/21
to vim/vim, Subscribed

Also: in regular cmd.exe, mouse should work without having to manually change "Quick Edit Mode" in command prompt properties.

K.Takata

unread,
May 29, 2021, 10:56:38 PM5/29/21
to vim/vim, Subscribed

I have already used a similar patch based on the old patch in the vim_dev mailing list.
So, I think this should be okay, but I will try this later.

K.Takata

unread,
May 29, 2021, 11:37:32 PM5/29/21
to vim/vim, Subscribed

@k-takata commented on this pull request.


In src/os_win32.c:

> @@ -1165,7 +1165,6 @@ decode_key_event(
 
 #endif // FEAT_GUI_MSWIN
 
-

This change is unnecessary.

Wez Furlong

unread,
May 30, 2021, 10:50:34 AM5/30/21
to vim/vim, Push

@wez pushed 1 commit.

  • c504990 win32: disable quickedit mode when enabling mouse support


You are receiving this because you are subscribed to this thread.

Wez Furlong

unread,
May 30, 2021, 10:51:17 AM5/30/21
to vim/vim, Subscribed

@wez commented on this pull request.


In src/os_win32.c:

> @@ -1165,7 +1165,6 @@ decode_key_event(
 
 #endif // FEAT_GUI_MSWIN
 
-

fixed!

Bram Moolenaar

unread,
May 30, 2021, 1:30:20 PM5/30/21
to vim/vim, Subscribed

Closed #8280 via 6ef5ab5.

K.Takata

unread,
May 30, 2021, 10:16:29 PM5/30/21
to vim/vim, Subscribed

The following item can be removed from the todo.txt:

Win32: Patch for enabling quick edit mode in console. (Craig Barkhouse, 2010
Sep 1)

Bram Moolenaar

unread,
May 31, 2021, 4:06:59 PM5/31/21
to vim/vim, Subscribed


Ken Takata wrote:

> The following item can be removed from the todo.txt:
> ```
> Win32: Patch for enabling quick edit mode in console. (Craig Barkhouse, 2010
> Sep 1)
> ```

Didn't we disable quick edit mode with the included change?

--
Lose weight, NEVER Diet again with
The "Invisible Weight Loss Patch"
(spam e-mail)

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

K.Takata

unread,
May 31, 2021, 7:26:29 PM5/31/21
to vim/vim, Subscribed

Oh, it looks that it's a mistake of the todo item.
Craig's patch actually disabled the QE mode: https://groups.google.com/g/vim_dev/c/bQ7jfMwa8Zg/m/KTEu7WkUAvIJ .

Reply all
Reply to author
Forward
0 new messages