Patch 8.1.1982
Problem: More functions can be used as methods.
Solution: Make popup functions usable as a method.
Files: runtime/doc/popup.txt, src/evalfunc.c,
src/testdir/test_popupwin.vim
*** ../vim-8.1.1981/runtime/doc/popup.txt 2019-09-03 22:08:13.673035035
+0200
--- runtime/doc/popup.txt 2019-09-04 18:12:49.439360484 +0200
***************
*** 189,194 ****
--- 189,197 ----
\ })
< Use {options} to change the properties.
+ Can also be used as a |method|: >
+ GetText()->popup_atcursor({})
+
popup_beval({what}, {options}) *popup_beval()*
Show the {what} above the position from 'ballooneval' and
***************
*** 203,209 ****
< Use {options} to change the properties.
See |popup_beval_example| for an example use.
!
*popup_clear()*
popup_clear() Emergency solution to a misbehaving plugin: close all popup
windows for the current tab and global popups.
--- 206,214 ----
< Use {options} to change the properties.
See |popup_beval_example| for an example use.
! Can also be used as a |method|: >
! GetText()->popup_beval({})
! <
*popup_clear()*
popup_clear() Emergency solution to a misbehaving plugin: close all popup
windows for the current tab and global popups.
***************
*** 218,223 ****
--- 223,230 ----
it will be passed as the second argument of the callback.
Otherwise zero is passed to the callback.
+ Can also be used as a |method|: >
+ GetPopup()->popup_close()
popup_create({what}, {options}) *popup_create()*
Open a popup window showing {what}, which is either:
***************
*** 240,245 ****
--- 247,254 ----
call setbufline(bufnr, 2, 'second line')
< In case of failure zero is returned.
+ Can also be used as a |method|: >
+ GetText()->popup_create({})
popup_dialog({what}, {options}) *popup_dialog()*
Just like |popup_create()| but with these default options: >
***************
*** 261,266 ****
--- 270,277 ----
< By default the dialog can be dragged, so that text below it
can be read if needed.
+ Can also be used as a |method|: >
+ GetText()->popup_dialog({})
popup_filter_menu({id}, {key})
*popup_filter_menu()*
Filter that can be used for a popup. These keys can be used:
***************
*** 337,342 ****
--- 348,355 ----
If popup window {id} is not found an empty Dict is returned.
+ Can also be used as a |method|: >
+ GetPopup()->popup_getoptions()
popup_getpos({id}) *popup_getpos()*
Return the position and size of popup {id}. Returns a Dict
***************
*** 361,366 ****
--- 374,381 ----
If popup window {id} is not found an empty Dict is returned.
+ Can also be used as a |method|: >
+ GetPopup()->popup_getpos()
popup_hide({id}) *popup_hide()*
If {id} is a displayed popup, hide it now. If the popup has a
***************
*** 369,374 ****
--- 384,391 ----
If window {id} does not exist nothing happens. If window {id}
exists but is not a popup window an error is given. *E993*
+ Can also be used as a |method|: >
+ GetPopup()->popup_hide()
popup_locate({row}, {col}) *popup_locate()*
Return the |window-ID| of the popup at screen position {row}
***************
*** 406,411 ****
--- 423,430 ----
\ callback: 'ColorSelected',
\ })
+ < Can also be used as a |method|: >
+ GetChoices()->popup_menu({})
popup_move({id}, {options}) *popup_move()*
Move popup {id} to the position specified with {options}.
***************
*** 422,427 ****
--- 441,448 ----
For {id} see `popup_hide()`.
For other options see |popup_setoptions()|.
+ Can also be used as a |method|: >
+ GetPopup()->popup_move(options)
popup_notification({what}, {options}) *popup_notification()*
Show the {what} for 3 seconds at the top of the Vim window.
***************
*** 449,454 ****
--- 470,477 ----
notifications.
Use {options} to change the properties.
+ Can also be used as a |method|: >
+ GetText()->popup_notification({})
popup_show({id}) *popup_show()*
If {id} is a hidden popup, show it now.
***************
*** 485,490 ****
--- 508,516 ----
For "hidden" use |popup_hide()| and |popup_show()|.
"tabpage" cannot be changed.
+ Can also be used as a |method|: >
+ GetPopup()->popup_setoptions(options)
+
popup_settext({id}, {text}) *popup_settext()*
Set the text of the buffer in popup win {id}. {text} is the
same as supplied to |popup_create()|, except that a buffer
***************
*** 492,497 ****
--- 518,525 ----
Does not change the window size or position, other than caused
by the different text.
+ Can also be used as a |method|: >
+ GetPopup()->popup_settext('hello')
==============================================================================
3. Usage *popup-usage*
*** ../vim-8.1.1981/src/evalfunc.c 2019-09-04 17:48:11.712877356 +0200
--- src/evalfunc.c 2019-09-04 18:13:17.719204079 +0200
***************
*** 633,658 ****
{"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_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_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_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},
#endif
#ifdef FEAT_FLOAT
{"pow", 2, 2, FEARG_1, f_pow},
--- 633,658 ----
{"perleval", 1, 1, 0, f_perleval},
#endif
#ifdef FEAT_TEXT_PROP
! {"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, 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, 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, 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},
*** ../vim-8.1.1981/src/testdir/test_popupwin.vim 2019-09-03
22:08:13.673035035 +0200
--- src/testdir/test_popupwin.vim 2019-09-04 18:14:15.446892131 +0200
***************
*** 145,151 ****
\ 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))
let options = popup_getoptions(winid)
call assert_equal([], options.border)
call assert_false(has_key(options, "padding"))
--- 145,151 ----
\ scrollbar: 0,
\ visible: 1}
let winid = popup_create('hello border', #{line: 2, col: 3, border: []})",
! 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,343 ****
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)
let winid = popup_create(['xxx']->repeat(50), #{
\ maxheight: 3,
--- 337,343 ----
call assert_equal(3, popup_getoptions(winid).firstline)
call popup_setoptions(winid, #{firstline: 1})
call assert_equal(1, popup_getoptions(winid).firstline)
! eval winid->popup_close()
let winid = popup_create(['xxx']->repeat(50), #{
\ maxheight: 3,
***************
*** 878,884 ****
" buffer is still listed but hidden
call assert_match(winbufnr(winid) .. 'u h.*\[Popup\]', execute('ls u'))
! call popup_show(winid)
redraw
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
call assert_equal('world', line)
--- 878,884 ----
" buffer is still listed but hidden
call assert_match(winbufnr(winid) .. 'u h.*\[Popup\]', execute('ls u'))
! eval winid->popup_show()
redraw
let line = join(map(range(1, 5), 'screenstring(1, v:val)'), '')
call assert_equal('world', line)
***************
*** 894,900 ****
call assert_fails('call popup_hide(win_getid())', 'E993:')
" no error non-existing window
! call popup_hide(1234234)
call popup_show(41234234)
bwipe!
--- 894,900 ----
call assert_fails('call popup_hide(win_getid())', 'E993:')
" no error non-existing window
! eval 1234234->popup_hide()
call popup_show(41234234)
bwipe!
***************
*** 920,926 ****
let line = join(map(range(1, 6), 'screenstring(2, v:val)'), '')
call assert_equal('~world', line)
! call popup_move(winid, #{line: 1})
redraw
let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
call assert_equal('hworld', line)
--- 920,926 ----
let line = join(map(range(1, 6), 'screenstring(2, v:val)'), '')
call assert_equal('~world', line)
! eval winid->popup_move(#{line: 1})
redraw
let line = join(map(range(1, 6), 'screenstring(1, v:val)'), '')
call assert_equal('hworld', line)
***************
*** 1076,1082 ****
call cursor(3, 4)
redraw
! let winid = popup_atcursor('vim', {})
redraw
let line = join(map(range(1, 17), 'screenstring(2, v:val)'), '')
call assert_equal('xxxvimxxxxxxxxxxx', line)
--- 1076,1082 ----
call cursor(3, 4)
redraw
! let winid = 'vim'->popup_atcursor({})
redraw
let line = join(map(range(1, 17), 'screenstring(2, v:val)'), '')
call assert_equal('xxxvimxxxxxxxxxxx', line)
***************
*** 1144,1150 ****
set balloonexpr=BalloonExpr()
set balloondelay=100
func BalloonExpr()
! let s:winid = popup_beval([v:beval_text], {})
return ''
endfunc
func Hover()
--- 1144,1150 ----
set balloonexpr=BalloonExpr()
set balloondelay=100
func BalloonExpr()
! let s:winid = [v:beval_text]->popup_beval({})
return ''
endfunc
func Hover()
***************
*** 1199,1205 ****
return 0
endfunc
! let winid = popup_create('something', #{filter: 'MyPopupFilter'})
redraw
" e is consumed by the filter
--- 1199,1205 ----
return 0
endfunc
! let winid = 'something'->popup_create(#{filter: 'MyPopupFilter'})
redraw
" e is consumed by the filter
***************
*** 1787,1793 ****
let lines =<< trim END
let opts = #{wrap: 0}
let p = popup_create('test', opts)
! call popup_settext(p, 'this is a text')
END
call writefile(lines, 'XtestPopupSetText')
--- 1787,1793 ----
let lines =<< trim END
let opts = #{wrap: 0}
let p = popup_create('test', opts)
! eval p->popup_settext('this is a text')
END
call writefile(lines, 'XtestPopupSetText')
***************
*** 1840,1846 ****
let s:cb_winid = a:id
let s:cb_res = a:res
endfunc
! let winid = popup_dialog('make a choice', #{hidden: 1,
\ filter: 'popup_filter_yesno',
\ callback: 'QuitCallback',
\ })
--- 1840,1846 ----
let s:cb_winid = a:id
let s:cb_res = a:res
endfunc
! let winid = 'make a choice'->popup_dialog(#{hidden: 1,
\ filter: 'popup_filter_yesno',
\ callback: 'QuitCallback',
\ })
***************
*** 2020,2026 ****
\ maxheight: 10,
\ })
for top in range(1, 20)
! call popup_setoptions(winid, #{firstline: top})
redraw
call assert_equal(19, popup_getpos(winid).width)
endfor
--- 2020,2026 ----
\ maxheight: 10,
\ })
for top in range(1, 20)
! eval winid->popup_setoptions(#{firstline: top})
redraw
call assert_equal(19, popup_getpos(winid).width)
endfor
***************
*** 2100,2107 ****
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'], #{
\ minwidth: 8,
\ maxheight: 3,
\ })
--- 2100,2108 ----
call setline(1, range(1, 20))
hi ScrollThumb ctermbg=blue
hi ScrollBar ctermbg=red
! eval ['one', 'two', 'three', 'four', 'five',
! \ 'six', 'seven', 'eight', 'nine']
! \ ->popup_menu(#{
\ minwidth: 8,
\ maxheight: 3,
\ })
***************
*** 2435,2441 ****
call setline(1, 'text text text text text text text ')
func ChangeColor()
let id = popup_findinfo()
! call popup_setoptions(id, #{highlight: 'InfoPopup'})
endfunc
END
return lines
--- 2436,2442 ----
call setline(1, 'text text text text text text text ')
func ChangeColor()
let id = popup_findinfo()
! eval id->popup_setoptions(#{highlight: 'InfoPopup'})
endfunc
END
return lines
***************
*** 2522,2528 ****
func Test_popupwin_recycle_bnr()
let bufnr = popup_notification('nothing wrong', {})->winbufnr()
call popup_clear()
! let winid = popup_notification('nothing wrong', {})
call assert_equal(bufnr, winbufnr(winid))
call popup_clear()
endfunc
--- 2523,2529 ----
func Test_popupwin_recycle_bnr()
let bufnr = popup_notification('nothing wrong', {})->winbufnr()
call popup_clear()
! let winid = 'nothing wrong'->popup_notification({})
call assert_equal(bufnr, winbufnr(winid))
call popup_clear()
endfunc
*** ../vim-8.1.1981/src/version.c 2019-09-04 17:48:11.712877356 +0200
--- src/version.c 2019-09-04 18:14:43.998741251 +0200
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 1982,
/**/
--
hundred-and-one symptoms of being an internet addict:
182. You may not know what is happening in the world, but you know
every bit of net-gossip there is.
/// Bram Moolenaar -- [email protected] -- 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 ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/201909041615.x84GFh93023993%40masaka.moolenaar.net.