Patch 8.1.1416

20 views
Skip to first unread message

Bram Moolenaar

unread,
May 29, 2019, 2:27:16 PM5/29/19
to vim...@googlegroups.com

Patch 8.1.1416
Problem: Popup_getposition() not implemented yet.
Solution: Implement it. (Yasuhiro Matsumoto, closes #4449)
Files: runtime/doc/popup.txt, src/evalfunc.c, src/popupwin.c,
src/proto/popupwin.pro, src/testdir/test_popupwin.vim


*** ../vim-8.1.1415/runtime/doc/popup.txt 2019-05-27 21:53:53.986229323 +0200
--- runtime/doc/popup.txt 2019-05-29 20:18:24.751509209 +0200
***************
*** 84,94 ****

IMPLEMENTATION:
- Code is in popupwin.c
! - implement popup_getposition({id}), use in tests
- Implement filter.
- Handle screen resize in screenalloc().
- Make redrawing more efficient and avoid flicker.
- Properly figure out the size and position.
- Implement all the unimplemented options and features.


--- 84,100 ----

IMPLEMENTATION:
- Code is in popupwin.c
! - 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,237 ****
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

win_execute({id}, {command})
{not implemented yet}
--- 231,246 ----
Return the {options} for popup {id}.

popup_getposition({id}) *popup_getposition()*
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}
*** ../vim-8.1.1415/src/evalfunc.c 2019-05-28 23:08:12.056648758 +0200
--- src/evalfunc.c 2019-05-29 20:24:24.582101066 +0200
***************
*** 810,815 ****
--- 810,816 ----
#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},
*** ../vim-8.1.1415/src/popupwin.c 2019-05-27 21:53:53.986229323 +0200
--- src/popupwin.c 2019-05-29 20:22:24.442608839 +0200
***************
*** 487,490 ****
--- 487,511 ----
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
*** ../vim-8.1.1415/src/proto/popupwin.pro 2019-05-27 21:53:53.990229301 +0200
--- src/proto/popupwin.pro 2019-05-29 20:14:19.844197298 +0200
***************
*** 3,8 ****
--- 3,9 ----
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);
*** ../vim-8.1.1415/src/testdir/test_popupwin.vim 2019-05-27 21:53:53.990229301 +0200
--- src/testdir/test_popupwin.vim 2019-05-29 20:24:44.730013045 +0200
***************
*** 159,161 ****
--- 159,178 ----

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
*** ../vim-8.1.1415/src/version.c 2019-05-28 23:32:42.942257480 +0200
--- src/version.c 2019-05-29 20:15:28.556034833 +0200
***************
*** 769,770 ****
--- 769,772 ----
{ /* Add new patch number below this line */
+ /**/
+ 1416,
/**/

--
hundred-and-one symptoms of being an internet addict:
42. Your virtual girlfriend finds a new net sweetheart with a larger bandwidth.

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///

Christ van Willegen

unread,
May 29, 2019, 3:24:47 PM5/29/19
to vim...@googlegroups.com
Hi, 

Op wo 29 mei 2019 20:27 schreef Bram Moolenaar <Br...@moolenaar.net>:

Patch 8.1.1416
Problem:    Popup_getposition() not implemented yet.
Solution:   Implement it. (Yasuhiro Matsumoto, closes #4449)
+       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);
+     }
+ }

What happens if dict_add_number fails? Can it run out of memory when copying the string?

Christ van Willegen

Bram Moolenaar

unread,
May 29, 2019, 4:28:59 PM5/29/19
to vim...@googlegroups.com, Christ van Willegen
It is possible that memory runs out, yes. You will get an
out-of-memory error message then.

--
hundred-and-one symptoms of being an internet addict:
45. You buy a Captain Kirk chair with a built-in keyboard and mouse.
Reply all
Reply to author
Forward
0 new messages