@@ -146,6 +146,8 @@ Creating a popup window:
146146 | popup_create() | centered in the screen
147147 | popup_atcursor() | just above the cursor position, closes when
148148 the cursor moves away
149+ | popup_beval() | at the position indicated by v:beval_
150+ variables, closes when the mouse moves away
149151 | popup_notification() | show a notification for three seconds
150152 | popup_dialog() | centered with padding and border
151153 | popup_menu() | prompt for selecting an item from a list
@@ -184,6 +186,20 @@ popup_atcursor({what}, {options}) *popup_atcursor()*
184186< Use {options} to change the properties.
185187
186188
189+ popup_beval({what} , {options} ) *popup_beval()*
190+ Show the {what} above the position from 'ballooneval' and
191+ close it when the mouse moves. This works like: >
192+ let pos = screenpos(v:beval_winnr, v:beval_lnum, v:beval_col)
193+ call popup_create({what}, {
194+ \ 'pos': 'botleft',
195+ \ 'line': pos.lnum - 1,
196+ \ 'col': pos.col,
197+ \ 'mousemoved': 'WORD',
198+ \ })
199+ < Use {options} to change the properties.
200+ See | popup_beval_example | for an example use.
201+
202+
187203 *popup_clear()*
188204popup_clear() Emergency solution to a misbehaving plugin: close all popup
189205 windows for the current tab and global popups.
@@ -276,8 +292,11 @@ popup_getoptions({id}) *popup_getoptions()*
276292 A zero value means the option was not set. For "zindex" the
277293 default value is returned, not zero.
278294
279- The "moved" entry is a list with minimum and maximum column,
280- [0, 0] when not set.
295+ The "moved" entry is a list with line number, minimum and
296+ maximum column, [0, 0, 0] when not set.
297+
298+ The "mousemoved" entry is a list with screen row, minimum and
299+ maximum screen column, [0, 0, 0] when not set.
281300
282301 "border" and "padding" are not included when all values are
283302 zero. When all values are one then an empty list is included.
@@ -566,6 +585,7 @@ The second argument of |popup_create()| is a dictionary with options:
566585 - "any": if the cursor moved at all
567586 - "word": if the cursor moved outside | <cword> |
568587 - "WORD": if the cursor moved outside | <cWORD> |
588+ - "expr": if the cursor moved outside | <cexpr> |
569589 - [{start} , {end} ]: if the cursor moved before column
570590 {start} or after {end}
571591 The popup also closes if the cursor moves to another
@@ -736,5 +756,45 @@ Extend popup_filter_menu() with shortcut keys: >
736756 return popup_filter_menu(a:id, a:key)
737757 endfunc
738758<
759+ *popup_beval_example*
760+ Example for using a popup window for 'ballooneval' : >
761+
762+ set ballooneval balloonevalterm
763+ set balloonexpr=BalloonExpr()
764+ let s:winid = 0
765+
766+ func BalloonExpr()
767+ if s:winid
768+ call popup_close(s:winid)
769+ let s:winid = 0
770+ endif
771+ let s:winid = popup_beval([bufname(v:beval_bufnr), v:beval_text], {})
772+ return ''
773+ endfunc
774+ <
775+ If the text has to be obtained asynchronously return an empty string from the
776+ expression function and call popup_beval() once the text is available. In
777+ this example similated with a timer callback: >
778+
779+ set ballooneval balloonevalterm
780+ set balloonexpr=BalloonExpr()
781+ let s:winid = 0
782+
783+ func BalloonExpr()
784+ if s:winid
785+ call popup_close(s:winid)
786+ let s:winid = 0
787+ endif
788+ " simulate an asynchronous loopup for the text to display
789+ let s:balloonFile = bufname(v:beval_bufnr)
790+ let s:balloonWord = v:beval_text
791+ call timer_start(100, 'ShowPopup')
792+ return ''
793+ endfunc
794+
795+ func ShowPopup(id)
796+ let s:winid = popup_beval([s:balloonFile, s:balloonWord], {})
797+ endfunc
798+ <
739799
740800 vim:tw=78:ts=8:noet:ft=help:norl:
0 commit comments