From 3b9e75b3664652e5557dd6423adda9b55d113c4f Mon Sep 17 00:00:00 2001 From: Daniel Steinberg Date: Tue, 29 Jun 2021 17:55:54 -0400 Subject: vim-patch:8.1.2304: cannot get the mouse position when getting a mouse click Problem: Cannot get the mouse position when getting a mouse click. Solution: Add getmousepos(). https://github.com/vim/vim/commit/db3a205147ce2c335d5c2181c1f789277f8775b0 --- runtime/doc/eval.txt | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index ac02bdae32..ce16ff36d8 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2431,6 +2431,7 @@ getloclist({nr}) List list of location list items getloclist({nr}, {what}) Dict get specific location list properties getmarklist([{buf}]) List list of global/local marks getmatches([{win}]) List list of current matches +getmousepos() Dict last known mouse position getpid() Number process ID of Vim getpos({expr}) List position of cursor, mark, etc. getqflist() List list of quickfix items @@ -4709,7 +4710,8 @@ getchar([expr]) *getchar()* When the user clicks a mouse button, the mouse event will be returned. The position can then be found in |v:mouse_col|, |v:mouse_lnum|, |v:mouse_winid| and |v:mouse_win|. - Mouse move events will be ignored. + |getmousepos()| can also be used. Mouse move events will be + ignored. This example positions the mouse as it would normally happen: > let c = getchar() if c == "\" && v:mouse_win > 0 @@ -5099,6 +5101,36 @@ getmatches([{win}]) *getmatches()* 'pattern': 'FIXME', 'priority': 10, 'id': 2}] > :unlet m < +getmousepos() *getmousepos()* + Returns a Dictionary with the last known position of the + mouse. This can be used in a mapping for a mouse click. The + items are: + screenrow screen row + screencol screen column + winid Window ID of the click + winrow row inside "winid" + wincol column inside "winid" + line text line inside "winid" + column text column inside "winid" + All numbers are 1-based. + + If not over a window, e.g. when in the command line, then only + "screenrow" and "screencol" are valid, the others are zero. + + When on the status line below a window or the vertical + separater right of a window, the "line" and "column" values + are zero. + + When the position is after the text then "column" is the + length of the text in bytes. + + If the mouse is over a focusable floating window then that + window is used. + + + When using |getchar()| the Vim variables |v:mouse_lnum|, + |v:mouse_col| and |v:mouse_winid| also provide these values. + *getpid()* getpid() Return a Number which is the process ID of the Vim process. This is a unique number, until Vim exits. -- cgit From 096309037bf9237a10df8a02bb4d32345268667f Mon Sep 17 00:00:00 2001 From: Daniel Steinberg Date: Sat, 3 Jul 2021 14:50:33 -0400 Subject: chore: remove empty line This update was part of vim-patch:4c29502. https://github.com/vim/vim/commit/4c295027a426986566cd7a76c47a6d3a529727e7 The other parts of that patch were applied to Neovim in ad6bb38. --- runtime/doc/eval.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index ce16ff36d8..b298733d06 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -5127,7 +5127,6 @@ getmousepos() *getmousepos()* If the mouse is over a focusable floating window then that window is used. - When using |getchar()| the Vim variables |v:mouse_lnum|, |v:mouse_col| and |v:mouse_winid| also provide these values. -- cgit From 88442c2fa66a7303d6a9b52a254d49073bda5541 Mon Sep 17 00:00:00 2001 From: Daniel Steinberg Date: Thu, 8 Jul 2021 00:38:00 -0400 Subject: docs: add 'plus one' to correct getmousepos docs This change was applied to Vim as part of 90df4b9. https://github.com/vim/vim/commit/90df4b9d423485f7db16e3a65cab4f14edc815ae --- runtime/doc/eval.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index b298733d06..d6f72b68f7 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -5122,7 +5122,7 @@ getmousepos() *getmousepos()* are zero. When the position is after the text then "column" is the - length of the text in bytes. + length of the text in bytes plus one. If the mouse is over a focusable floating window then that window is used. -- cgit