summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-29 20:26:46 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-29 20:26:46 +0200
commitbc133543b8b0ebb1d8624e37d840b739eb00f3f3 (patch)
tree9e4d3f60b3643beea68e42efa9153f8c524502ed
parent59edb00e2219d4eda34b32a5d405f245053c5b74 (diff)
patch 8.1.1416: popup_getposition() not implemented yetv8.1.1416
Problem: Popup_getposition() not implemented yet. Solution: Implement it. (Yasuhiro Matsumoto, closes #4449)
-rw-r--r--runtime/doc/popup.txt13
-rw-r--r--src/evalfunc.c1
-rw-r--r--src/popupwin.c21
-rw-r--r--src/proto/popupwin.pro1
-rw-r--r--src/testdir/test_popupwin.vim17
-rw-r--r--src/version.c2
6 files changed, 53 insertions, 2 deletions
diff --git a/runtime/doc/popup.txt b/runtime/doc/popup.txt
index b92871506f..1954754548 100644
--- a/runtime/doc/popup.txt
+++ b/runtime/doc/popup.txt
@@ -84,11 +84,17 @@ Probably 2. is the best choice.
IMPLEMENTATION:
- Code is in popupwin.c
-- implement popup_getposition({id}), use in tests
+- when creating the window set options to Vim default? (verify with 'number')
+- Do not show tilde below last line.
- Implement filter.
+ Check that popup_close() works in the filter.
- Handle screen resize in screenalloc().
- Make redrawing more efficient and avoid flicker.
+ Fix redrawing problem with completion.
+ Fix redrawing problem when scrolling non-current window
+ Fix redrawing the statusline on top of a popup
- Properly figure out the size and position.
+- Can the buffer be re-used, to avoid using up lots of buffer numbers?
- Implement all the unimplemented options and features.
@@ -225,13 +231,16 @@ popup_getoptions({id}) *popup_getoptions()*
Return the {options} for popup {id}.
popup_getposition({id}) *popup_getposition()*
- {not implemented yet}
Return the position and size of popup {id}. Returns a Dict
with these entries:
col screen column of the popup, one-based
line screen line of the popup, one-based
width width of the popup in screen cells
height height of the popup in screen cells
+ Note that these are the actual screen positions. They differ
+ from the values in `popup_getoptions()` for the sizing and
+ positioning mechanism applied.
+ If popup window {id} is not found an empty Dict is returned.
win_execute({id}, {command})
{not implemented yet}
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ccced484ee..1a0e113b16 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -810,6 +810,7 @@ static struct fst
#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 9970c5afe9..82ef27a1a9 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -487,4 +487,25 @@ f_popup_move(typval_T *argvars, typval_T *rettv UNUSED)
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 f4d476095c..37b5273226 100644
--- a/src/proto/popupwin.pro
+++ b/src/proto/popupwin.pro
@@ -3,6 +3,7 @@ void f_popup_create(typval_T *argvars, typval_T *rettv);
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 756ad68c4d..7d7d9a8784 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -159,3 +159,20 @@ func Test_popup_move()
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 eac5b026e8..b032347022 100644
--- a/src/version.c
+++ b/src/version.c
@@ -768,6 +768,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1416,
+/**/
1415,
/**/
1414,