diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-04 18:15:19 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-04 18:15:19 +0200 |
commit | 6a124e622cfe52619781c6a02119177a44d09210 (patch) | |
tree | cce9965defdf07591d00ff9d6bcd0aeaebe1a316 /src | |
parent | 08c308aeb5e7dfa18fa61f261b0bff79517a4883 (diff) |
patch 8.1.1982: more functions can be used as methodsv8.1.1982
Problem: More functions can be used as methods.
Solution: Make popup functions usable as a method.
Diffstat (limited to 'src')
-rw-r--r-- | src/evalfunc.c | 28 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 31 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 32 insertions, 29 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index 4fbecc304d..784132f5ae 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -633,26 +633,26 @@ static funcentry_T global_functions[] = {"perleval", 1, 1, 0, f_perleval}, #endif #ifdef FEAT_TEXT_PROP - {"popup_atcursor", 2, 2, 0, f_popup_atcursor}, - {"popup_beval", 2, 2, 0, f_popup_beval}, + {"popup_atcursor", 2, 2, FEARG_1, f_popup_atcursor}, + {"popup_beval", 2, 2, FEARG_1, f_popup_beval}, {"popup_clear", 0, 0, 0, f_popup_clear}, - {"popup_close", 1, 2, 0, f_popup_close}, - {"popup_create", 2, 2, 0, f_popup_create}, - {"popup_dialog", 2, 2, 0, f_popup_dialog}, + {"popup_close", 1, 2, FEARG_1, f_popup_close}, + {"popup_create", 2, 2, FEARG_1, f_popup_create}, + {"popup_dialog", 2, 2, FEARG_1, f_popup_dialog}, {"popup_filter_menu", 2, 2, 0, f_popup_filter_menu}, {"popup_filter_yesno", 2, 2, 0, f_popup_filter_yesno}, {"popup_findinfo", 0, 0, 0, f_popup_findinfo}, {"popup_findpreview", 0, 0, 0, f_popup_findpreview}, - {"popup_getoptions", 1, 1, 0, f_popup_getoptions}, - {"popup_getpos", 1, 1, 0, f_popup_getpos}, - {"popup_hide", 1, 1, 0, f_popup_hide}, + {"popup_getoptions", 1, 1, FEARG_1, f_popup_getoptions}, + {"popup_getpos", 1, 1, FEARG_1, f_popup_getpos}, + {"popup_hide", 1, 1, FEARG_1, f_popup_hide}, {"popup_locate", 2, 2, 0, f_popup_locate}, - {"popup_menu", 2, 2, 0, f_popup_menu}, - {"popup_move", 2, 2, 0, f_popup_move}, - {"popup_notification", 2, 2, 0, f_popup_notification}, - {"popup_setoptions", 2, 2, 0, f_popup_setoptions}, - {"popup_settext", 2, 2, 0, f_popup_settext}, - {"popup_show", 1, 1, 0, f_popup_show}, + {"popup_menu", 2, 2, FEARG_1, f_popup_menu}, + {"popup_move", 2, 2, FEARG_1, f_popup_move}, + {"popup_notification", 2, 2, FEARG_1, f_popup_notification}, + {"popup_setoptions", 2, 2, FEARG_1, f_popup_setoptions}, + {"popup_settext", 2, 2, FEARG_1, f_popup_settext}, + {"popup_show", 1, 1, FEARG_1, f_popup_show}, #endif #ifdef FEAT_FLOAT {"pow", 2, 2, FEARG_1, f_pow}, diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 36cf306a71..03cada32a3 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -145,7 +145,7 @@ func Test_popup_with_border_and_padding() \ scrollbar: 0, \ visible: 1} let winid = popup_create('hello border', #{line: 2, col: 3, border: []})", - call assert_equal(with_border_or_padding, popup_getpos(winid)) + call assert_equal(with_border_or_padding, winid->popup_getpos()) let options = popup_getoptions(winid) call assert_equal([], options.border) call assert_false(has_key(options, "padding")) @@ -337,7 +337,7 @@ func Test_popup_firstline() call assert_equal(3, popup_getoptions(winid).firstline) call popup_setoptions(winid, #{firstline: 1}) call assert_equal(1, popup_getoptions(winid).firstline) - call popup_close(winid) + eval winid->popup_close() let winid = popup_create(['xxx']->repeat(50), #{ \ maxheight: 3, @@ -878,7 +878,7 @@ func Test_popup_hide() " buffer is still listed but hidden call assert_match(winbufnr(winid) .. 'u h.*\[Popup\]', execute('ls u')) - call popup_show(winid) + eval winid->popup_show() redraw let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '') call assert_equal('world', line) @@ -894,7 +894,7 @@ func Test_popup_hide() call assert_fails('call popup_hide(win_getid())', 'E993:') " no error non-existing window - call popup_hide(1234234) + eval 1234234->popup_hide() call popup_show(41234234) bwipe! @@ -920,7 +920,7 @@ func Test_popup_move() let line = join(map(range(1, 6), 'screenstring(2, v:val)'), '') call assert_equal('~world', line) - call popup_move(winid, #{line: 1}) + eval winid->popup_move(#{line: 1}) redraw let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '') call assert_equal('hworld', line) @@ -1076,7 +1076,7 @@ func Test_popup_atcursor() call cursor(3, 4) redraw - let winid = popup_atcursor('vim', {}) + let winid = 'vim'->popup_atcursor({}) redraw let line = join(map(range(1, 17), 'screenstring(2, v:val)'), '') call assert_equal('xxxvimxxxxxxxxxxx', line) @@ -1144,7 +1144,7 @@ func Test_popup_beval() set balloonexpr=BalloonExpr() set balloondelay=100 func BalloonExpr() - let s:winid = popup_beval([v:beval_text], {}) + let s:winid = [v:beval_text]->popup_beval({}) return '' endfunc func Hover() @@ -1199,7 +1199,7 @@ func Test_popup_filter() return 0 endfunc - let winid = popup_create('something', #{filter: 'MyPopupFilter'}) + let winid = 'something'->popup_create(#{filter: 'MyPopupFilter'}) redraw " e is consumed by the filter @@ -1787,7 +1787,7 @@ func Test_popup_settext() let lines =<< trim END let opts = #{wrap: 0} let p = popup_create('test', opts) - call popup_settext(p, 'this is a text') + eval p->popup_settext('this is a text') END call writefile(lines, 'XtestPopupSetText') @@ -1840,7 +1840,7 @@ func Test_popup_hidden() let s:cb_winid = a:id let s:cb_res = a:res endfunc - let winid = popup_dialog('make a choice', #{hidden: 1, + let winid = 'make a choice'->popup_dialog(#{hidden: 1, \ filter: 'popup_filter_yesno', \ callback: 'QuitCallback', \ }) @@ -2020,7 +2020,7 @@ func Test_popupwin_width() \ maxheight: 10, \ }) for top in range(1, 20) - call popup_setoptions(winid, #{firstline: top}) + eval winid->popup_setoptions(#{firstline: top}) redraw call assert_equal(19, popup_getpos(winid).width) endfor @@ -2100,8 +2100,9 @@ func Test_popup_menu_with_scrollbar() call setline(1, range(1, 20)) hi ScrollThumb ctermbg=blue hi ScrollBar ctermbg=red - call popup_menu(['one', 'two', 'three', 'four', 'five', - \ 'six', 'seven', 'eight', 'nine'], #{ + eval ['one', 'two', 'three', 'four', 'five', + \ 'six', 'seven', 'eight', 'nine'] + \ ->popup_menu(#{ \ minwidth: 8, \ maxheight: 3, \ }) @@ -2435,7 +2436,7 @@ func Get_popupmenu_lines() call setline(1, 'text text text text text text text ') func ChangeColor() let id = popup_findinfo() - call popup_setoptions(id, #{highlight: 'InfoPopup'}) + eval id->popup_setoptions(#{highlight: 'InfoPopup'}) endfunc END return lines @@ -2522,7 +2523,7 @@ endfunc func Test_popupwin_recycle_bnr() let bufnr = popup_notification('nothing wrong', {})->winbufnr() call popup_clear() - let winid = popup_notification('nothing wrong', {}) + let winid = 'nothing wrong'->popup_notification({}) call assert_equal(bufnr, winbufnr(winid)) call popup_clear() endfunc diff --git a/src/version.c b/src/version.c index fb68068bc1..515564d642 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1982, +/**/ 1981, /**/ 1980, |