Patch 8.1.1673
Problem: Cannot easily find the popup window at a certain position.
Solution: Add popup_locate().
Files: runtime/doc/popup.txt, src/evalfunc.c, src/popupwin.c,
src/proto/popupwin.pro, src/testdir/test_popupwin.vim
*** ../vim-8.1.1672/runtime/doc/popup.txt 2019-07-10 21:55:50.766597954
+0200
--- runtime/doc/popup.txt 2019-07-12 20:55:47.197785769 +0200
***************
*** 170,175 ****
--- 170,176 ----
Other:
|popup_getoptions()| get current options for a popup
|popup_getpos()| get actual position and size of a popup
+ |popup_locate()| find popup window at a screen position
DETAILS *popup-function-details*
***************
*** 343,348 ****
--- 344,356 ----
exists but is not a popup window an error is given. *E993*
+ popup_locate({row}, {col}) *popup_locate()*
+ Return the |window-ID| of the popup at screen positoin {row}
+ and {col}. If there are multiple popups the one with the
+ highest zindex is returned. If there are no popups at this
+ position then zero is returned.
+
+
popup_menu({what}, {options}) *popup_menu()*
Show the {what} near the cursor, handle selecting one of the
items with cursorkeys, and close it an item is selected with
*** ../vim-8.1.1672/src/evalfunc.c 2019-07-12 17:57:54.832524048 +0200
--- src/evalfunc.c 2019-07-12 20:56:02.989834227 +0200
***************
*** 781,786 ****
--- 781,787 ----
{"popup_getoptions", 1, 1, f_popup_getoptions},
{"popup_getpos", 1, 1, f_popup_getpos},
{"popup_hide", 1, 1, f_popup_hide},
+ {"popup_locate", 2, 2, f_popup_locate},
{"popup_menu", 2, 2, f_popup_menu},
{"popup_move", 2, 2, f_popup_move},
{"popup_notification", 2, 2, f_popup_notification},
*** ../vim-8.1.1672/src/popupwin.c 2019-07-12 16:35:31.206326782 +0200
--- src/popupwin.c 2019-07-12 21:06:38.037895459 +0200
***************
*** 1890,1895 ****
--- 1890,1909 ----
win_valid(wp) && (wp->w_popup_flags & POPF_HIDDEN) == 0);
}
}
+ /*
+ * popup_locate({row}, {col})
+ */
+ void
+ f_popup_locate(typval_T *argvars, typval_T *rettv)
+ {
+ int row = tv_get_number(&argvars[0]) - 1;
+ int col = tv_get_number(&argvars[1]) - 1;
+ win_T *wp;
+
+ wp = mouse_find_win(&row, &col, FIND_POPUP);
+ if (WIN_IS_POPUP(wp))
+ rettv->vval.v_number = wp->w_id;
+ }
/*
* For popup_getoptions(): add a "border" or "padding" entry to "dict".
*** ../vim-8.1.1672/src/proto/popupwin.pro 2019-07-07 18:27:52.365277132
+0200
--- src/proto/popupwin.pro 2019-07-12 21:01:25.442231100 +0200
***************
*** 29,34 ****
--- 29,35 ----
void f_popup_move(typval_T *argvars, typval_T *rettv);
void f_popup_setoptions(typval_T *argvars, typval_T *rettv);
void f_popup_getpos(typval_T *argvars, typval_T *rettv);
+ void f_popup_locate(typval_T *argvars, typval_T *rettv);
void f_popup_getoptions(typval_T *argvars, typval_T *rettv);
int error_if_popup_window(void);
void popup_reset_handled(void);
*** ../vim-8.1.1672/src/testdir/test_popupwin.vim 2019-07-12
18:12:48.638823398 +0200
--- src/testdir/test_popupwin.vim 2019-07-12 21:06:12.385940567 +0200
***************
*** 713,719 ****
topleft vnew
call setline(1, 'hello')
! call popup_create('world', {
\ 'line': 1,
\ 'col': 1,
\ 'minwidth': 20,
--- 713,719 ----
topleft vnew
call setline(1, 'hello')
! let winid = popup_create('world', {
\ 'line': 1,
\ 'col': 1,
\ 'minwidth': 20,
***************
*** 723,728 ****
--- 723,733 ----
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
call assert_equal('world', line)
+ call assert_equal(winid, popup_locate(1, 1))
+ call assert_equal(winid, popup_locate(1, 20))
+ call assert_equal(0, popup_locate(1, 21))
+ call assert_equal(0, popup_locate(2, 1))
+
sleep 700m
redraw
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
*** ../vim-8.1.1672/src/version.c 2019-07-12 20:24:54.121206682 +0200
--- src/version.c 2019-07-12 21:06:57.909858806 +0200
***************
*** 779,780 ****
--- 779,782 ----
{ /* Add new patch number below this line */
+ /**/
+ 1673,
/**/
--
Mental Floss prevents moral decay!
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/201907121908.x6CJ89IJ027783%40masaka.moolenaar.net.
For more options, visit https://groups.google.com/d/optout.