I noticed that while editing the command line, I can't click away to focus on a window. This is mildly annoying to me for whatever reason, so I fixed it.
1. Open a bunch of windows. 2. Edit the cmdline with ":test" 3. Try to left click on any window, you stay in the command line. My patch leaves the command line as if you'd pressed Ctrl_C, but adjusts your window focus based on where you click. It needs some review to make sure I'm using the mouse facilities properly. Also, how can I test this? -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
>From f5f4ff37a407dfcd6bad5cd1a69809f0b7860ecc Mon Sep 17 00:00:00 2001 From: Jason Franklin <[email protected]> Date: Sun, 5 Aug 2018 09:06:11 -0400 Subject: [PATCH] Allow clicking away from the command line --- src/ex_getln.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/ex_getln.c b/src/ex_getln.c index 54b37961f..4bee7de6d 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -1426,20 +1426,17 @@ getcmdline( # endif if (!mouse_has(MOUSE_COMMAND)) goto cmdline_not_changed; /* Ignore mouse */ + + int button, is_click, is_drag; + button = get_mouse_button(KEY2TERMCAP1(c), &is_click, &is_drag); # ifdef FEAT_CLIPBOARD if (mouse_row < cmdline_row && clip_star.available) { - int button, is_click, is_drag; - - /* - * Handle modeless selection. - */ - button = get_mouse_button(KEY2TERMCAP1(c), - &is_click, &is_drag); + // Handle modeless selection. if (mouse_model_popup() && button == MOUSE_LEFT && (mod_mask & MOD_MASK_SHIFT)) { - /* Translate shift-left to right button. */ + // Translate shift-left to right button. button = MOUSE_RIGHT; mod_mask &= ~MOD_MASK_SHIFT; } @@ -1447,6 +1444,15 @@ getcmdline( goto cmdline_not_changed; } # endif + // Handle a left mouse click away from the cmdline. + // Behave as if "Ctrl_C" was pressed, but focus on the selected window. + if (button == MOUSE_LEFT && is_click && mouse_row < cmdline_row) + { + curwin = mouse_find_win(&mouse_row, &mouse_col); + status_redraw_all(); + gotesc = TRUE; + goto returncmd; + } set_cmdspos(); for (ccline.cmdpos = 0; ccline.cmdpos < ccline.cmdlen; -- 2.17.1
