To: vim_dev@googlegroups.com Subject: Patch 8.2.0748 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0748 Problem: Cannot get a list of all popups. Solution: Add popup_list(). Use it in the test runner. Files: runtime/doc/eval.txt, runtime/doc/popup.txt, src/popupwin.c, src/proto/popupwin.pro, src/evalfunc.c, src/testdir/test_popupwin.vim, src/testdir/runtest.vim *** ../vim-8.2.0747/runtime/doc/eval.txt 2020-04-26 15:59:51.202952140 +0200 --- runtime/doc/eval.txt 2020-05-13 16:10:15.738475735 +0200 *************** *** 2623,2628 **** --- 2627,2634 ---- popup_getoptions({id}) Dict get options of popup window {id} popup_getpos({id}) Dict get position of popup window {id} popup_hide({id}) none hide popup menu {id} + popup_list() List get a list of window IDs of al popups + popup_locate({row}, {col}) Number get window ID of popup at position popup_menu({what}, {options}) Number create a popup window used as a menu popup_move({id}, {options}) none set position of popup window {id} popup_notification({what}, {options}) *** ../vim-8.2.0747/runtime/doc/popup.txt 2020-05-13 13:40:12.686995655 +0200 --- runtime/doc/popup.txt 2020-05-13 16:08:09.346889947 +0200 *************** *** 191,196 **** --- 198,204 ---- |popup_getoptions()| get current options for a popup |popup_getpos()| get actual position and size of a popup |popup_locate()| find popup window at a screen position + |popup_list()| get list of all popups DETAILS *popup-function-details* *************** *** 416,421 **** --- 424,433 ---- Can also be used as a |method|: > GetPopup()->popup_hide() + popup_list() *popup_list()* + Return a List with the |window-ID| of all existing popups. + + popup_locate({row}, {col}) *popup_locate()* Return the |window-ID| of the popup at screen position {row} and {col}. If there are multiple popups the one with the *** ../vim-8.2.0747/src/popupwin.c 2020-05-13 13:40:12.690995638 +0200 --- src/popupwin.c 2020-05-13 16:17:57.640943266 +0200 *************** *** 2720,2725 **** --- 2720,2744 ---- hash_unlock(&dict->dv_hashtab); } } + + /* + * popup_list() + */ + void + f_popup_list(typval_T *argvars UNUSED, typval_T *rettv) + { + win_T *wp; + tabpage_T *tp; + + if (rettv_list_alloc(rettv) != OK) + return; + FOR_ALL_POPUPWINS(wp) + list_append_number(rettv->vval.v_list, wp->w_id); + FOR_ALL_TABPAGES(tp) + FOR_ALL_POPUPWINS_IN_TAB(tp, wp) + list_append_number(rettv->vval.v_list, wp->w_id); + } + /* * popup_locate({row}, {col}) */ *** ../vim-8.2.0747/src/proto/popupwin.pro 2020-05-13 13:40:12.690995638 +0200 --- src/proto/popupwin.pro 2020-05-13 16:17:42.608993171 +0200 *************** *** 40,45 **** --- 40,46 ---- void f_popup_move(typval_T *argvars, typval_T *rettv); void f_popup_setoptions(typval_T *argvars, typval_T *rettv); void f_popup_getpos(typval_T *argvars, typval_T *rettv); + void f_popup_list(typval_T *argvars, typval_T *rettv); void f_popup_locate(typval_T *argvars, typval_T *rettv); void f_popup_getoptions(typval_T *argvars, typval_T *rettv); int error_if_term_popup_window(void); *** ../vim-8.2.0747/src/evalfunc.c 2020-05-13 13:40:12.686995655 +0200 --- src/evalfunc.c 2020-05-13 16:11:28.862235835 +0200 *************** *** 715,720 **** --- 715,721 ---- {"popup_getoptions", 1, 1, FEARG_1, ret_dict_any, PROP_FUNC(f_popup_getoptions)}, {"popup_getpos", 1, 1, FEARG_1, ret_dict_any, PROP_FUNC(f_popup_getpos)}, {"popup_hide", 1, 1, FEARG_1, ret_void, PROP_FUNC(f_popup_hide)}, + {"popup_list", 0, 0, 0, ret_list_number, PROP_FUNC(f_popup_list)}, {"popup_locate", 2, 2, 0, ret_number, PROP_FUNC(f_popup_locate)}, {"popup_menu", 2, 2, FEARG_1, ret_number, PROP_FUNC(f_popup_menu)}, {"popup_move", 2, 2, FEARG_1, ret_void, PROP_FUNC(f_popup_move)}, *** ../vim-8.2.0747/src/testdir/test_popupwin.vim 2020-05-12 22:02:17.893963155 +0200 --- src/testdir/test_popupwin.vim 2020-05-13 16:30:22.938475383 +0200 *************** *** 428,434 **** call delete('XtestPopupNospace') endfunc ! func Test_popup_firstline() CheckScreendump let lines =<< trim END --- 428,434 ---- call delete('XtestPopupNospace') endfunc ! func Test_popup_firstline_dump() CheckScreendump let lines =<< trim END *************** *** 449,455 **** --- 449,457 ---- " clean up call StopVimInTerminal(buf) call delete('XtestPopupFirstline') + endfunc + func Test_popup_firstline() let winid = popup_create(['1111', '222222', '33333', '44444'], #{ \ maxheight: 2, \ firstline: 3, *************** *** 491,496 **** --- 493,499 ---- call popup_setoptions(winid, #{line: 3}) call assert_equal(0, popup_getoptions(winid).firstline) call assert_equal(10, popup_getpos(winid).firstline) + call popup_close(winid) " CTRL-D scrolls down half a page let winid = popup_create(['xxx']->repeat(50), #{ *************** *** 826,835 **** --- 829,841 ---- endfunc func Test_popup_valid_arguments() + call assert_equal(0, len(popup_list())) + " Zero value is like the property wasn't there let winid = popup_create("text", #{col: 0}) let pos = popup_getpos(winid) call assert_inrange(&columns / 2 - 1, &columns / 2 + 1, pos.col) + call assert_equal([winid], popup_list()) call popup_clear() " using cursor column has minimum value of 1 *************** *** 1619,1630 **** --- 1625,1638 ---- let pos = popup_getpos(winid) call assert_equal(5, pos.width) call assert_equal(5, pos.height) + call popup_close(winid) let winid = popup_create([], #{border: []}) redraw let pos = popup_getpos(winid) call assert_equal(3, pos.width) call assert_equal(3, pos.height) + call popup_close(winid) endfunc func Test_popup_never_behind() *************** *** 3323,3330 **** set signcolumn=yes call setline(1, repeat('=', &columns)) normal! ggg$ ! call popup_atcursor(repeat('x', 500), #{moved: 'any', border: []}) bwipe! set signcolumn& endfunc --- 3331,3339 ---- set signcolumn=yes call setline(1, repeat('=', &columns)) normal! ggg$ ! let winid = popup_atcursor(repeat('x', 500), #{moved: 'any', border: []}) + call popup_close(winid) bwipe! set signcolumn& endfunc *** ../vim-8.2.0747/src/testdir/runtest.vim 2020-05-13 13:40:12.690995638 +0200 --- src/testdir/runtest.vim 2020-05-13 16:21:25.704253334 +0200 *************** *** 188,195 **** au! au SwapExists * call HandleSwapExists() ! " Close any stray popup windows. if has('popupwin') call popup_clear(1) endif --- 188,196 ---- au! au SwapExists * call HandleSwapExists() ! " Check for and close any stray popup windows. if has('popupwin') + call assert_equal([], popup_list()) call popup_clear(1) endif *** ../vim-8.2.0747/src/version.c 2020-05-13 13:40:12.694995625 +0200 --- src/version.c 2020-05-13 16:31:47.890194660 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 748, /**/ -- I AM THANKFUL... ...for the clothes that fit a little too snug because it means I have more than enough to eat. /// Bram Moolenaar -- Bram@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 ///