patch 8.1.1416: popup_getposition() not implemented yet
Problem: Popup_getposition() not implemented yet.
Solution: Implement it. (Yasuhiro Matsumoto, closes #4449)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ccced48..1a0e113 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -810,6 +810,7 @@
#ifdef FEAT_TEXT_PROP
{"popup_close", 1, 1, f_popup_close},
{"popup_create", 2, 2, f_popup_create},
+ {"popup_getposition", 1, 1, f_popup_getposition},
{"popup_hide", 1, 1, f_popup_hide},
{"popup_move", 2, 2, f_popup_move},
{"popup_show", 1, 1, f_popup_show},
diff --git a/src/popupwin.c b/src/popupwin.c
index 9970c5a..82ef27a 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -487,4 +487,25 @@
redraw_all_later(NOT_VALID);
}
+/*
+ * popup_getposition({id})
+ */
+ void
+f_popup_getposition(typval_T *argvars, typval_T *rettv)
+{
+ dict_T *dict;
+ int id = (int)tv_get_number(argvars);
+ win_T *wp = find_popup_win(id);
+
+ if (rettv_dict_alloc(rettv) == OK)
+ {
+ if (wp == NULL)
+ return; // invalid {id}
+ dict = rettv->vval.v_dict;
+ dict_add_number(dict, "line", wp->w_winrow + 1);
+ dict_add_number(dict, "col", wp->w_wincol + 1);
+ dict_add_number(dict, "width", wp->w_width);
+ dict_add_number(dict, "height", wp->w_height);
+ }
+}
#endif // FEAT_TEXT_PROP
diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro
index f4d4760..37b5273 100644
--- a/src/proto/popupwin.pro
+++ b/src/proto/popupwin.pro
@@ -3,6 +3,7 @@
int popup_any_visible(void);
void f_popup_close(typval_T *argvars, typval_T *rettv);
void f_popup_hide(typval_T *argvars, typval_T *rettv);
+void f_popup_getposition(typval_T *argvars, typval_T *rettv);
void f_popup_show(typval_T *argvars, typval_T *rettv);
void popup_close(int id);
void popup_close_tabpage(tabpage_T *tp, int id);
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 756ad68..7d7d9a8 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -159,3 +159,20 @@
bwipe!
endfunc
+
+func Test_popup_getposition()
+ let winid = popup_create('hello', {
+ \ 'line': 2,
+ \ 'col': 3,
+ \ 'minwidth': 10,
+ \ 'minheight': 11,
+ \})
+ redraw
+ let res = popup_getposition(winid)
+ call assert_equal(2, res.line)
+ call assert_equal(3, res.col)
+ call assert_equal(10, res.width)
+ call assert_equal(11, res.height)
+
+ call popup_close(winid)
+endfunc
diff --git a/src/version.c b/src/version.c
index eac5b02..b032347 100644
--- a/src/version.c
+++ b/src/version.c
@@ -768,6 +768,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1416,
+/**/
1415,
/**/
1414,