]> granicus.if.org Git - vim/commitdiff
patch 8.1.1416: popup_getposition() not implemented yet v8.1.1416
authorBram Moolenaar <Bram@vim.org>
Wed, 29 May 2019 18:26:46 +0000 (20:26 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 29 May 2019 18:26:46 +0000 (20:26 +0200)
Problem:    Popup_getposition() not implemented yet.
Solution:   Implement it. (Yasuhiro Matsumoto, closes #4449)

runtime/doc/popup.txt
src/evalfunc.c
src/popupwin.c
src/proto/popupwin.pro
src/testdir/test_popupwin.vim
src/version.c

index b92871506f04a8e67d9b2e8b8a516b6f073cd6b7..1954754548ec6a58d8ca93a6987bafd4a20a1497 100644 (file)
@@ -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}
index ccced484eef3c9c6454d9f980f276f7cfb14de40..1a0e113b16583e03cec18cd9e26bc50d14fdbbde 100644 (file)
@@ -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},
index 9970c5afe9957480774c7a14a19cfe4f448cbd4c..82ef27a1a951b543a802779c1f22e5eae057073f 100644 (file)
@@ -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
index f4d476095cf9e45494ba01c3c38c959c6f3c3f2d..37b5273226be7b15f3d8b969ca360203ee207fb9 100644 (file)
@@ -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);
index 756ad68c4dc19f375238648ae307cc362fc04438..7d7d9a8784284d10968772cc22df940845a75a79 100644 (file)
@@ -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
index eac5b026e8c1aff367ba831fdcc9c40ee031ab0e..b0323470227c7f27a777738694c6579fedf84a57 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1416,
 /**/
     1415,
 /**/