Skip to content

Commit 3ff5f0f

Browse files
committed
patch 8.1.1513: all popup functionality is in functions, except :popupclear
Problem: All popup functionality is in functions, except :popupclear. Solution: Add popup_clear() for consistency. Also rename sound_stopall() to sound_clear().
1 parent 38ea784 commit 3ff5f0f

12 files changed

Lines changed: 189 additions & 167 deletions

File tree

runtime/doc/eval.txt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.1. Last change: 2019 Jun 06
1+
*eval.txt* For Vim version 8.1. Last change: 2019 Jun 10
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -2623,12 +2623,12 @@ sin({expr}) Float sine of {expr}
26232623
sinh({expr}) Float hyperbolic sine of {expr}
26242624
sort({list} [, {func} [, {dict}]])
26252625
List sort {list}, using {func} to compare
2626+
sound_clear() none stop playing all sounds
26262627
sound_playevent({name} [, {callback}])
26272628
Number play an event sound
2628-
sound_playfile({name} [, {callback}])
2629-
Number play a sound file
2629+
sound_playfile({path} [, {callback}])
2630+
Number play sound file {path}
26302631
sound_stop({id}) none stop playing sound {id}
2631-
sound_stopall() none stop playing all sounds
26322632
soundfold({word}) String sound-fold {word}
26332633
spellbadword() String badly spelled word at cursor
26342634
spellsuggest({word} [, {max} [, {capital}]])
@@ -7360,7 +7360,7 @@ prop_remove({props} [, {lnum} [, {lnum-end}]])
73607360
not just the first one
73617361
A property matches when either "id" or "type" matches.
73627362
If buffer "bufnr" does not exist you get an error message.
7363-
If buffer 'bufnr" is not loaded then nothing happens.
7363+
If buffer "bufnr" is not loaded then nothing happens.
73647364

73657365
Returns the number of properties that were removed.
73667366

@@ -8852,6 +8852,10 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
88528852
return a:i1 - a:i2
88538853
endfunc
88548854
<
8855+
sound_clear() *sound_clear()*
8856+
Stop playing all sounds.
8857+
{only available when compiled with the +sound feature}
8858+
88558859
*sound_playevent()*
88568860
sound_playevent({name} [, {callback}])
88578861
Play a sound identified by {name}. Which event names are
@@ -8877,22 +8881,17 @@ sound_playevent({name} [, {callback}])
88778881
{only available when compiled with the +sound feature}
88788882

88798883
*sound_playfile()*
8880-
sound_playfile({name} [, {callback}])
8881-
Like `sound_playevent()` but play sound file {name}. {name}
8884+
sound_playfile({path} [, {callback}])
8885+
Like `sound_playevent()` but play sound file {path}. {path}
88828886
must be a full path. On Ubuntu you may find files to play
88838887
with this command: >
88848888
:!find /usr/share/sounds -type f | grep -v index.theme
8885-
88868889
< {only available when compiled with the +sound feature}
88878890

88888891

88898892
sound_stop({id}) *sound_stop()*
88908893
Stop playing sound {id}. {id} must be previously returned by
88918894
`sound_playevent()` or `sound_playfile()`.
8892-
{only available when compiled with the +sound feature}
8893-
8894-
sound_stopall() *sound_stopall()*
8895-
Stop playing all sounds.
88968895
{only available when compiled with the +sound feature}
88978896

88988897
*soundfold()*
@@ -13083,19 +13082,22 @@ Sometimes old syntax of functionality gets in the way of making Vim better.
1308313082
When support is taken away this will break older Vim scripts. To make this
1308413083
explicit the |:scriptversion| command can be used. When a Vim script is not
1308513084
compatible with older versions of Vim this will give an explicit error,
13086-
instead of failing in mysterious ways. >
13085+
instead of failing in mysterious ways.
1308713086

13087+
*scriptversion-1* >
1308813088
:scriptversion 1
1308913089
< This is the original Vim script, same as not using a |:scriptversion|
1309013090
command. Can be used to go back to old syntax for a range of lines.
1309113091
Test for support with: >
1309213092
has('vimscript-1')
1309313093
13094+
< *scriptversion-2* >
1309413095
:scriptversion 2
1309513096
< String concatenation with "." is not supported, use ".." instead.
1309613097
This avoids the ambiguity using "." for Dict member access and
1309713098
floating point numbers. Now ".5" means the number 0.5.
13098-
>
13099+
13100+
*scriptversion-3* >
1309913101
:scriptversion 3
1310013102
< All |vim-variable|s must be prefixed by "v:". E.g. "version" doesn't
1310113103
work as |v:version| anymore, it can be used as a normal variable.

runtime/doc/popup.txt

Lines changed: 101 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*popup.txt* For Vim version 8.1. Last change: 2019 Jun 02
1+
*popup.txt* For Vim version 8.1. Last change: 2019 Jun 09
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -89,15 +89,18 @@ Probably 2. is the best choice.
8989

9090

9191
IMPLEMENTATION:
92-
- Code is in popupwin.c
92+
- buffers remain after popup was deleted.
93+
- do not redraw whole window when popup was changed, mark affected lines for
94+
redraw.
9395
- Why does 'nrformats' leak from the popup window buffer???
94-
- Make redrawing more efficient and avoid flicker.
95-
First draw popups, creating a mask, use the mask in screen_line() when
96-
drawing other windows and stuff. Mask contains zindex of popups.
97-
Keep mask until next update_screen(), use when drawing status lines.
98-
Remove update_popup() calls after draw_tabline()/updating statusline
99-
Fix redrawing problem with completion.
100-
Fix redrawing problem when scrolling non-current window
96+
- Add 'balloonpopup': instead of showing text, let the callback open a balloon
97+
and return the window ID. The popup will then be closed when the mouse
98+
moves, except when it moves inside the popup.
99+
- For the "moved" property also include mouse movement?
100+
- Make redrawing more efficient and avoid flicker:
101+
- put popup menu also put in popup_mask?
102+
- Use changes in popup_mask to decide what windows and range of lines to
103+
redraw?
101104
- Disable commands, feedkeys(), CTRL-W, etc. in a popup window.
102105
Use NOT_IN_POPUP_WINDOW for more commands.
103106
- Invoke filter with character before mapping?
@@ -115,6 +118,33 @@ THIS IS UNDER DESIGN - ANYTHING MAY STILL CHANGE
115118

116119
[functions to be moved to eval.txt later, keep overview of functions here]
117120

121+
popup_atcursor({text}, {options}) *popup_atcursor()*
122+
Show the {text} above the cursor, and close it when the cursor
123+
moves. This works like: >
124+
call popup_create({text}, {
125+
\ 'pos': 'botleft',
126+
\ 'line': 'cursor-1',
127+
\ 'col': 'cursor',
128+
\ 'moved': 'WORD',
129+
\ })
130+
< Use {options} to change the properties.
131+
132+
133+
*popup_clear()*
134+
popup_clear() Emergency solution to a misbehaving plugin: close all popup
135+
windows.
136+
137+
138+
popup_close({id} [, {result}]) *popup_close()*
139+
Close popup {id}. The window and the associated buffer will
140+
be deleted.
141+
142+
If the popup has a callback it will be called just before the
143+
popup window is deleted. If the optional {result} is present
144+
it will be passed as the second argument of the callback.
145+
Otherwise zero is passed to the callback.
146+
147+
118148
popup_create({text}, {options}) *popup_create()*
119149
Open a popup window showing {text}, which is either:
120150
- a string
@@ -133,16 +163,6 @@ popup_create({text}, {options}) *popup_create()*
133163
< In case of failure zero is returned.
134164

135165

136-
popup_close({id} [, {result}]) *popup_close()*
137-
Close popup {id}. The window and the associated buffer will
138-
be deleted.
139-
140-
If the popup has a callback it will be called just before the
141-
popup window is deleted. If the optional {result} is present
142-
it will be passed as the second argument of the callback.
143-
Otherwise zero is passed to the callback.
144-
145-
146166
popup_dialog({text}, {options}) *popup_dialog()*
147167
{not implemented yet}
148168
Just like |popup_create()| but with these default options: >
@@ -155,70 +175,6 @@ popup_dialog({text}, {options}) *popup_dialog()*
155175
< Use {options} to change the properties.
156176

157177

158-
popup_notification({text}, {options}) *popup_notification()*
159-
{not implemented yet}
160-
Show the {text} for 3 seconds at the top of the Vim window.
161-
This works like: >
162-
call popup_create({text}, {
163-
\ 'line': 1,
164-
\ 'col': 10,
165-
\ 'time': 3000,
166-
\ 'tab': -1,
167-
\ 'zindex': 200,
168-
\ 'highlight': 'WarningMsg',
169-
\ 'border': [],
170-
\ })
171-
< Use {options} to change the properties.
172-
173-
174-
popup_atcursor({text}, {options}) *popup_atcursor()*
175-
Show the {text} above the cursor, and close it when the cursor
176-
moves. This works like: >
177-
call popup_create({text}, {
178-
\ 'pos': 'botleft',
179-
\ 'line': 'cursor-1',
180-
\ 'col': 'cursor',
181-
\ 'moved': 'WORD',
182-
\ })
183-
< Use {options} to change the properties.
184-
185-
186-
popup_menu({text}, {options}) *popup_menu()*
187-
{not implemented yet}
188-
Show the {text} near the cursor, handle selecting one of the
189-
items with cursorkeys, and close it an item is selected with
190-
Space or Enter. {text} should have multiple lines to make this
191-
useful. This works like: >
192-
call popup_create({text}, {
193-
\ 'pos': 'center',
194-
\ 'zindex': 200,
195-
\ 'wrap': 0,
196-
\ 'border': [],
197-
\ 'filter': 'popup_filter_menu',
198-
\ })
199-
< Use {options} to change the properties. Should at least set
200-
"callback" to a function that handles the selected item.
201-
202-
203-
popup_hide({id}) *popup_hide()*
204-
If {id} is a displayed popup, hide it now. If the popup has a
205-
filter it will not be invoked for so long as the popup is
206-
hidden.
207-
If window {id} does not exist nothing happens. If window {id}
208-
exists but is not a popup window an error is given. *E993*
209-
210-
popup_show({id}) *popup_show()*
211-
If {id} is a hidden popup, show it now.
212-
For {id} see `popup_hide()`.
213-
214-
popup_move({id}, {options}) *popup_move()*
215-
Move popup {id} to the position speficied with {options}.
216-
{options} may contain the items from |popup_create()| that
217-
specify the popup position: "line", "col", "pos", "maxheight",
218-
"minheight", "maxwidth" and "minwidth".
219-
For {id} see `popup_hide()`.
220-
221-
222178
popup_filter_menu({id}, {key}) *popup_filter_menu()*
223179
{not implemented yet}
224180
Filter that can be used for a popup. It handles the cursor
@@ -237,11 +193,6 @@ popup_filter_yesno({id}, {key}) *popup_filter_yesno()*
237193
pressing 'n'.
238194

239195

240-
popup_setoptions({id}, {options}) *popup_setoptions()*
241-
{not implemented yet}
242-
Override options in popup {id} with entries in {options}.
243-
244-
245196
popup_getoptions({id}) *popup_getoptions()*
246197
Return the {options} for popup {id} in a Dict.
247198
A zero value means the option was not set. For "zindex" the
@@ -253,6 +204,7 @@ popup_getoptions({id}) *popup_getoptions()*
253204
254205
< If popup window {id} is not found an empty Dict is returned.
255206

207+
256208
popup_getpos({id}) *popup_getpos()*
257209
Return the position and size of popup {id}. Returns a Dict
258210
with these entries:
@@ -274,9 +226,64 @@ popup_getpos({id}) *popup_getpos()*
274226
If popup window {id} is not found an empty Dict is returned.
275227

276228

277-
*:popupclear* *:popupc*
278-
:popupc[lear] Emergency solution to a misbehaving plugin: close all popup
279-
windows.
229+
popup_hide({id}) *popup_hide()*
230+
If {id} is a displayed popup, hide it now. If the popup has a
231+
filter it will not be invoked for so long as the popup is
232+
hidden.
233+
If window {id} does not exist nothing happens. If window {id}
234+
exists but is not a popup window an error is given. *E993*
235+
236+
237+
popup_menu({text}, {options}) *popup_menu()*
238+
{not implemented yet}
239+
Show the {text} near the cursor, handle selecting one of the
240+
items with cursorkeys, and close it an item is selected with
241+
Space or Enter. {text} should have multiple lines to make this
242+
useful. This works like: >
243+
call popup_create({text}, {
244+
\ 'pos': 'center',
245+
\ 'zindex': 200,
246+
\ 'wrap': 0,
247+
\ 'border': [],
248+
\ 'filter': 'popup_filter_menu',
249+
\ })
250+
< Use {options} to change the properties. Should at least set
251+
"callback" to a function that handles the selected item.
252+
253+
254+
popup_move({id}, {options}) *popup_move()*
255+
Move popup {id} to the position speficied with {options}.
256+
{options} may contain the items from |popup_create()| that
257+
specify the popup position: "line", "col", "pos", "maxheight",
258+
"minheight", "maxwidth" and "minwidth".
259+
For {id} see `popup_hide()`.
260+
261+
262+
popup_notification({text}, {options}) *popup_notification()*
263+
{not implemented yet}
264+
Show the {text} for 3 seconds at the top of the Vim window.
265+
This works like: >
266+
call popup_create({text}, {
267+
\ 'line': 1,
268+
\ 'col': 10,
269+
\ 'time': 3000,
270+
\ 'tab': -1,
271+
\ 'zindex': 200,
272+
\ 'highlight': 'WarningMsg',
273+
\ 'border': [],
274+
\ })
275+
< Use {options} to change the properties.
276+
277+
278+
popup_show({id}) *popup_show()*
279+
If {id} is a hidden popup, show it now.
280+
For {id} see `popup_hide()`.
281+
282+
283+
popup_setoptions({id}, {options}) *popup_setoptions()*
284+
{not implemented yet}
285+
Override options in popup {id} with entries in {options}.
286+
280287

281288

282289
POPUP BUFFER AND WINDOW *popup-buffer*
@@ -405,7 +412,8 @@ The second argument of |popup_create()| is a dictionary with options:
405412
By default a double line is used all around when
406413
'encoding' is "utf-8", otherwise ASCII characters are
407414
used.
408-
zindex Priority for the popup, default 50.
415+
zindex Priority for the popup, default 50. Mininum value is
416+
1, maximum value is 32000.
409417
time Time in milliseconds after which the popup will close.
410418
When omitted |popup_close()| must be used.
411419
moved Specifies to close the popup if the cursor moved:
@@ -496,7 +504,7 @@ Vim provides standard filters |popup_filter_menu()| and
496504

497505
Note that "x" is the normal way to close a popup. You may want to use Esc,
498506
but since many keys start with an Esc character, there may be a delay before
499-
Vim recognizes the Esc key. If you do use Esc, it is reecommended to set the
507+
Vim recognizes the Esc key. If you do use Esc, it is recommended to set the
500508
'ttimeoutlen' option to 100 and set 'timeout' and/or 'ttimeout'.
501509

502510

src/evalfunc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,7 @@ static struct fst
812812
#endif
813813
#ifdef FEAT_TEXT_PROP
814814
{"popup_atcursor", 2, 2, f_popup_atcursor},
815+
{"popup_clear", 0, 0, f_popup_clear},
815816
{"popup_close", 1, 2, f_popup_close},
816817
{"popup_create", 2, 2, f_popup_create},
817818
{"popup_getoptions", 1, 1, f_popup_getoptions},
@@ -928,10 +929,10 @@ static struct fst
928929
#endif
929930
{"sort", 1, 3, f_sort},
930931
#ifdef FEAT_SOUND
932+
{"sound_clear", 0, 0, f_sound_clear},
931933
{"sound_playevent", 1, 2, f_sound_playevent},
932934
{"sound_playfile", 1, 2, f_sound_playfile},
933935
{"sound_stop", 1, 1, f_sound_stop},
934-
{"sound_stopall", 0, 0, f_sound_stopall},
935936
#endif
936937
{"soundfold", 1, 1, f_soundfold},
937938
{"spellbadword", 0, 1, f_spellbadword},

0 commit comments

Comments
 (0)