Skip to content

Commit 931a277

Browse files
committed
patch 8.1.1628: popup window functions not in list of functions
Problem: Popup window functions not in list of functions. Solution: Add popup window functins to the list of functions. Reorganise the popup window help.
1 parent 6cb39f9 commit 931a277

4 files changed

Lines changed: 107 additions & 77 deletions

File tree

runtime/doc/eval.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,6 +2534,24 @@ nr2char({expr} [, {utf8}]) String single char with ASCII/UTF8 value {expr}
25342534
or({expr}, {expr}) Number bitwise OR
25352535
pathshorten({expr}) String shorten directory names in a path
25362536
perleval({expr}) any evaluate |Perl| expression
2537+
popup_atcursor({what}, {options}) Number create popup window near the cursor
2538+
popup_clear() none close all popup windows
2539+
popup_close({id} [, {result}]) none close popup window {id}
2540+
popup_create({what}, {options}) Number create a popup window
2541+
popup_dialog({what}, {options}) Number create a popup window used as a dialog
2542+
popup_filter_menu({id}, {key}) Number filter for a menu popup window
2543+
popup_filter_yesno({id}, {key}) Number filter for a dialog popup window
2544+
popup_getoptions({id}) Dict get options of popup window {id}
2545+
popup_getpos({id}) Dict get position of popup window {id}
2546+
popup_hide({id}) none hide popup menu {id}
2547+
popup_menu({what}, {options}) Number create a popup window used as a menu
2548+
popup_move({id}, {options}) none set position of popup window {id}
2549+
popup_notification({what}, {options})
2550+
Number create a notification popup window
2551+
popup_show({id}) none unhide popup window {id}
2552+
popup_setoptions({id}, {options})
2553+
none set options for popup window {id}
2554+
popup_settext({id}, {text}) none set the text of popup window {id}
25372555
pow({x}, {y}) Float {x} to the power of {y}
25382556
prevnonblank({lnum}) Number line nr of non-blank line <= {lnum}
25392557
printf({fmt}, {expr1}...) String format text
@@ -7035,6 +7053,10 @@ perleval({expr}) *perleval()*
70357053
< [1, 2, 3, 4]
70367054
{only available when compiled with the |+perl| feature}
70377055

7056+
7057+
popup_ functions are documented here: |popup-functions|.
7058+
7059+
70387060
pow({x}, {y}) *pow()*
70397061
Return the power of {x} to the exponent {y} as a |Float|.
70407062
{x} and {y} must evaluate to a |Float| or a |Number|.

runtime/doc/popup.txt

Lines changed: 55 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
*popup.txt* For Vim version 8.1. Last change: 2019 Jun 30
1+
*popup.txt* For Vim version 8.1. Last change: 2019 Jul 04
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
55

66

7-
Displaying text in floating window. *popup* *popup-window*
7+
Displaying text in a floating window. *popup* *popup-window*
88

9-
THIS IS UNDER DESIGN - ANYTHING MAY STILL CHANGE
109

1110
1. Introduction |popup-intro|
11+
Window position and size |popup-position|
12+
Closing the popup window |popup-close|
13+
Popup buffer and window |popup-buffer|
1214
2. Functions |popup-functions|
13-
3. Examples |popup-examples|
15+
Details |popup-function-details|
16+
3. Usage |popup-usage|
17+
popup_create() arguments |popup_create-arguments|
18+
Popup text properties |popup-props|
19+
Popup filter |popup-filter|
20+
Popup callback |popup-callback|
21+
Popup scrollbar |popup-scrollbar|
22+
Popup mask |popup-mask|
23+
4. Examples |popup-examples|
1424

1525

1626
{not available if the |+textprop| feature was disabled at compile time}
@@ -55,7 +65,7 @@ If this is not what you are looking for, check out other popup functionality:
5565
- balloon, see |balloon-eval|
5666

5767

58-
WINDOW POSITION AND SIZE *popup-position*
68+
WINDOW POSITION AND SIZE *popup-position*
5969

6070
The height of the window is normally equal to the number of, possibly
6171
wrapping, lines in the buffer. It can be limited with the "maxheight"
@@ -85,7 +95,7 @@ That way you can still see where it is, even though you cannot see the text
8595
that it is in.
8696

8797

88-
CLOSING THE POPUP WINDOW *popup-close*
98+
CLOSING THE POPUP WINDOW *popup-close*
8999

90100
Normally the plugin that created the popup window is also in charge of closing
91101
it. If somehow a popup hangs around, you can close all of them with: >
@@ -97,40 +107,41 @@ or by clicking anywhere inside the popup. This must be enabled with the
97107
"close" property. It is set by default for notifications.
98108

99109

100-
TODO:
101-
- Add test for when popup with mask is off the left and off the right of the
102-
screen.
103-
- check padding/border when popup is off the left and right of the screen.
104-
- Have a way to scroll to the bottom? (#4577)
105-
- Why does 'nrformats' leak from the popup window buffer???
106-
- Disable commands, feedkeys(), CTRL-W, etc. in a popup window.
107-
Use ERROR_IF_POPUP_WINDOW for more commands.
108-
- Add 'balloonpopup': instead of showing text, let the callback open a popup
109-
window and return the window ID. The popup will then be closed when the
110-
mouse moves, except when it moves inside the popup.
111-
- For the "moved" property also include mouse movement?
112-
- Can the buffer be re-used, to avoid using up lots of buffer numbers?
113-
- Have an option to attach the popup to a text position, like text properties
114-
do. (#4560)
115-
- Make redrawing more efficient and avoid flicker:
116-
- put popup menu also put in popup_mask?
117-
- Invoke filter with character before mapping?
118-
- Figure out the size and position better.
119-
if wrapping splits a double-wide character
120-
if wrapping inserts indent
121-
- When drawing on top half a double-wide character, display ">" or "<" in the
122-
incomplete cell.
123-
- Use a popup window for the "info" item of completion instead of using a
124-
preview window. Ideas in issue #4544.
125-
How to add highlighting?
126-
- Implement:
127-
flip option
110+
POPUP BUFFER AND WINDOW *popup-buffer*
111+
112+
If a popup function is called to create a popup from text, a new buffer is
113+
created to hold the text and text properties of the popup window. The buffer
114+
is always associated with the popup window and manipulation is restricted:
115+
- the buffer has no name
116+
- 'buftype' is "popup"
117+
- 'swapfile' is off
118+
- 'bufhidden' is "hide"
119+
- 'buflisted' is off
120+
- 'undolevels' is -1: no undo at all
121+
- all other buffer-local and window-local options are set to their Vim default
122+
value.
123+
124+
It is possible to change the specifically mentioned options, but anything
125+
might break then, so better leave them alone.
126+
127+
The window does have a cursor position, but the cursor is not displayed.
128+
129+
To execute a command in the context of the popup window and buffer use
130+
`win_execute()`. Example: >
131+
call win_execute(winid, 'syntax enable')
132+
133+
Options can be set on the window with `setwinvar()`, e.g.: >
134+
call setwinvar(winid, '&wrap', 0)
135+
And options can be set on the buffer with `setbufvar()`, e.g.: >
136+
call setbufvar(winbufnr(winid), '&filetype', 'java')
137+
Note that this does not trigger autocommands. Use `win_execute()` if you do
138+
need them.
139+
140+
128141

129142
==============================================================================
130143
2. Functions *popup-functions*
131144

132-
THIS IS UNDER DESIGN - ANYTHING MAY STILL CHANGE
133-
134145
Creating a popup window:
135146
|popup_create()| centered in the screen
136147
|popup_atcursor()| just above the cursor position, closes when
@@ -159,9 +170,9 @@ Other:
159170
|popup_getpos()| get actual position and size of a popup
160171

161172

162-
[functions help to be moved to eval.txt later]
173+
DETAILS *popup-function-details*
163174

164-
popup_atcursor({what}, {options}) *popup_atcursor()*
175+
popup_atcursor({what}, {options}) *popup_atcursor()*
165176
Show the {what} above the cursor, and close it when the cursor
166177
moves. This works like: >
167178
call popup_create({what}, {
@@ -199,7 +210,7 @@ popup_create({what}, {options}) *popup_create()*
199210
the popup closes.
200211

201212
{options} is a dictionary with many possible entries.
202-
See |popup_create-usage| for details.
213+
See |popup_create-arguments| for details.
203214

204215
Returns a window-ID, which can be used with other popup
205216
functions. Use `winbufnr()` to get the number of the buffer
@@ -417,38 +428,10 @@ popup_settext({id}, {text}) *popup_settext()*
417428
by the different text.
418429

419430

420-
POPUP BUFFER AND WINDOW *popup-buffer*
421-
422-
A new buffer is created to hold the text and text properties of the popup
423-
window. The buffer is always associated with the popup window and
424-
manipulation is restricted:
425-
- the buffer has no name
426-
- 'buftype' is "popup"
427-
- 'swapfile' is off
428-
- 'bufhidden' is "hide"
429-
- 'buflisted' is off
430-
- 'undolevels' is -1: no undo at all
431-
- all other buffer-local and window-local options are set to their Vim default
432-
value.
433-
434-
It is possible to change the specifically mentioned options, but anything
435-
might break then, so better leave them alone.
436-
437-
The window does have a cursor position, but the cursor is not displayed.
438-
439-
To execute a command in the context of the popup window and buffer use
440-
`win_execute()`. Example: >
441-
call win_execute(winid, 'syntax enable')
442-
443-
Options can be set on the window with `setwinvar()`, e.g.: >
444-
call setwinvar(winid, '&wrap', 0)
445-
And options can be set on the buffer with `setbufvar()`, e.g.: >
446-
call setbufvar(winbufnr(winid), '&filetype', 'java')
447-
Note that this does not trigger autocommands. Use `win_execute()` if you do
448-
need them.
449-
431+
==============================================================================
432+
3. Usage *popup-usage*
450433

451-
POPUP_CREATE() ARGUMENTS *popup_create-usage*
434+
POPUP_CREATE() ARGUMENTS *popup_create-arguments*
452435

453436
The first argument of |popup_create()| (and the second argument to
454437
|popup_settext()|) specifies the text to be displayed, and optionally text
@@ -709,9 +692,9 @@ To make the four corners transparent:
709692
[[1, 1, 1, 1], [-1, -1, 1, 1], [1, 1, -1, -1], [-1, -1, -1, -1]]
710693

711694
==============================================================================
712-
3. Examples *popup-examples*
695+
4. Examples *popup-examples*
713696

714-
TODO
697+
TODO: more interesting examples
715698
*popup_dialog-example*
716699
Prompt the user to press y/Y or n/N: >
717700

runtime/doc/usr_41.txt

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*usr_41.txt* For Vim version 8.1. Last change: 2019 Jun 09
1+
*usr_41.txt* For Vim version 8.1. Last change: 2019 Jul 04
22

33
VIM USER MANUAL - by Bram Moolenaar
44

@@ -748,6 +748,12 @@ Working with text in the current buffer: *text-functions*
748748
getcharsearch() return character search information
749749
setcharsearch() set character search information
750750

751+
Working with text in another buffer:
752+
getbufline() get a list of lines from the specified buffer
753+
setbufline() replace a line in the specified buffer
754+
appendbufline() append a list of lines in the specified buffer
755+
deletebufline() delete lines from a specified buffer
756+
751757
*system-functions* *file-functions*
752758
System functions and manipulation of files:
753759
glob() expand wildcards
@@ -799,8 +805,10 @@ Buffers, windows and the argument list:
799805
argidx() current position in the argument list
800806
arglistid() get id of the argument list
801807
argv() get one entry from the argument list
808+
bufadd() add a file to the list of buffers
802809
bufexists() check if a buffer exists
803810
buflisted() check if a buffer exists and is listed
811+
bufload() ensure a buffer is loaded
804812
bufloaded() check if a buffer exists and is loaded
805813
bufname() get the name of a specific buffer
806814
bufnr() get the buffer number of a specific buffer
@@ -811,10 +819,6 @@ Buffers, windows and the argument list:
811819
bufwinid() get the window ID of a specific buffer
812820
bufwinnr() get the window number of a specific buffer
813821
winbufnr() get the buffer number of a specific window
814-
getbufline() get a list of lines from the specified buffer
815-
setbufline() replace a line in the specified buffer
816-
appendbufline() append a list of lines in the specified buffer
817-
deletebufline() delete lines from a specified buffer
818822
listener_add() add a callback to listen to changes
819823
listener_flush() invoke listener callbacks
820824
listener_remove() remove a listener callback
@@ -1038,6 +1042,25 @@ Terminal window: *terminal-functions*
10381042
term_setrestore() set command to restore a terminal
10391043
term_setsize() set the size of a terminal
10401044

1045+
Popup window: *popup-window-functions*
1046+
popup_create() create popup centered in the screen
1047+
popup_atcursor() create popup just above the cursor position,
1048+
closes when the cursor moves away
1049+
popup_notification() show a notification for three seconds
1050+
popup_dialog() create popup centered with padding and border
1051+
popup_menu() prompt for selecting an item from a list
1052+
popup_hide() hide a popup temporarily
1053+
popup_show() show a previously hidden popup
1054+
popup_move() change the position and size of a popup
1055+
popup_setoptions() override options of a popup
1056+
popup_settext() replace the popup buffer contents
1057+
popup_close() close one popup
1058+
popup_clear() close all popups
1059+
popup_filter_menu() select from a list of items
1060+
popup_filter_yesno() blocks until 'y' or 'n' is pressed
1061+
popup_getoptions() get current options for a popup
1062+
popup_getpos() get actual position and size of a popup
1063+
10411064
Timers: *timer-functions*
10421065
timer_start() create a timer
10431066
timer_pause() pause or unpause a timer

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ static char *(features[]) =
777777

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1628,
780782
/**/
781783
1627,
782784
/**/

0 commit comments

Comments
 (0)