changeset 17545:1e45331bd2ab v8.1.1770

patch 8.1.1770: cannot get the window ID of the popup preview window commit https://github.com/vim/vim/commit/56c0c4749d58e9331b212c38df46e2993d5d97c1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 28 17:57:43 2019 +0200 patch 8.1.1770: cannot get the window ID of the popup preview window Problem: Cannot get the window ID of the popup preview window. Solution: Add popup_getpreview().
author Bram Moolenaar <Bram@vim.org>
date Sun, 28 Jul 2019 18:00:05 +0200
parents 531324882cb8
children 69fe6408aef0
files runtime/doc/eval.txt runtime/doc/popup.txt src/evalfunc.c src/popupwin.c src/proto/popupwin.pro src/testdir/dumps/Test_popupwin_previewpopup_3.dump src/version.c
diffstat 7 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2554,6 +2554,7 @@ popup_filter_menu({id}, {key})  Number	f
 popup_filter_yesno({id}, {key}) Number	filter for a dialog popup window
 popup_getoptions({id})		Dict	get options of popup window {id}
 popup_getpos({id})		Dict	get position of popup window {id}
+popup_getpreview()		Number	get window ID of preview popup window
 popup_hide({id})		none	hide popup menu {id}
 popup_menu({what}, {options})	Number	create a popup window used as a menu
 popup_move({id}, {options})	none	set position of popup window {id}
--- a/runtime/doc/popup.txt
+++ b/runtime/doc/popup.txt
@@ -1,4 +1,4 @@
-*popup.txt*  For Vim version 8.1.  Last change: 2019 Jul 18
+*popup.txt*  For Vim version 8.1.  Last change: 2019 Jul 28
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -335,6 +335,10 @@ popup_getpos({id})					*popup_getpos()*
 
 		If popup window {id} is not found an empty Dict is returned.
 
+popup_getpreview()					*popup_getpreview()*
+		Get the |window-ID| for the popup preview window.
+		Return zero if there is none.
+
 
 popup_hide({id})						*popup_hide()*
 		If {id} is a displayed popup, hide it now. If the popup has a
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -715,6 +715,7 @@ static struct fst
     {"popup_filter_yesno", 2, 2, f_popup_filter_yesno},
     {"popup_getoptions", 1, 1, f_popup_getoptions},
     {"popup_getpos",	1, 1, f_popup_getpos},
+    {"popup_getpreview", 0, 0, f_popup_getpreview},
     {"popup_hide",	1, 1, f_popup_hide},
     {"popup_locate",	2, 2, f_popup_locate},
     {"popup_menu",	2, 2, f_popup_menu},
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -3019,7 +3019,15 @@ popup_find_preview_window(void)
     for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
 	if (wp->w_p_pvw)
 	    return wp;
-    return wp;
+    return NULL;
+}
+
+    void
+f_popup_getpreview(typval_T *argvars UNUSED, typval_T *rettv)
+{
+    win_T   *wp = popup_find_preview_window();
+
+    rettv->vval.v_number = wp == NULL ? 0 : wp->w_id;
 }
 
     int
--- a/src/proto/popupwin.pro
+++ b/src/proto/popupwin.pro
@@ -42,6 +42,7 @@ void may_update_popup_mask(int type);
 void update_popups(void (*win_update)(win_T *wp));
 int set_ref_in_popups(int copyID);
 win_T *popup_find_preview_window(void);
+void f_popup_getpreview(typval_T *argvars, typval_T *rettv);
 int popup_is_popup(win_T *wp);
 int popup_create_preview_window(void);
 void popup_close_preview(void);
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_3.dump
@@ -0,0 +1,14 @@
+|o+0&#ffffff0|n|e| @71
+|t|w|o| @71
+|t|h|r|e@1| @69
+|f|o|u|r| @9|╔+0#0000001#ffd7ff255|═@40|X| +0#0000000#ffffff0@17
+|f|i|v|e| @9|║+0#0000001#ffd7ff255|2|7| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
+|s|i|x| @10|║+0#0000001#ffd7ff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
+|s|e|v|e|n| @8|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
+|f|i|n|d| |t|h|e|w|o|r|d| |s|║+0#0000001#ffd7ff255|3|0| @37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@17
+|n|i|n|e| @9|╚+0#0000001#ffd7ff255|═@40|╝| +0#0000000#ffffff0@17
+|t|h|i|s| |i|s| >a|n|o|t|h|e|r| |w|o|r|d| @54
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|:+0#0000000&| @55|1|0|,|9| @9|A|l@1| 
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1770,
+/**/
     1769,
 /**/
     1768,