summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-25 19:51:39 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-25 19:51:39 +0200
commit4d784b21d14fc66e98a2b07f70343cdd4acd62aa (patch)
treec2e869a4f07eebdf7e0272c74b0fe7392807836c
parent8f46e4c4bde13fd5ad68a6670b79cc462b65fbec (diff)
patch 8.1.1391: no popup window supportv8.1.1391
Problem: No popup window support. Solution: Add initial code for popup windows. Add the 'wincolor' option.
-rw-r--r--Filelist2
-rw-r--r--runtime/doc/options.txt8
-rw-r--r--runtime/doc/popup.txt117
-rw-r--r--src/Make_cyg_ming.mak1
-rw-r--r--src/Make_mvc.mak5
-rw-r--r--src/Make_vms.mms10
-rw-r--r--src/Makefile10
-rw-r--r--src/autocmd.c18
-rw-r--r--src/buffer.c14
-rw-r--r--src/eval.c26
-rw-r--r--src/evalfunc.c4
-rw-r--r--src/ex_cmdidxs.h24
-rw-r--r--src/ex_cmds.h3
-rw-r--r--src/feature.h2
-rw-r--r--src/globals.h12
-rw-r--r--src/option.c11
-rw-r--r--src/option.h1
-rw-r--r--src/popupwin.c231
-rw-r--r--src/proto.h1
-rw-r--r--src/proto/buffer.pro1
-rw-r--r--src/proto/popupwin.pro7
-rw-r--r--src/proto/window.pro5
-rw-r--r--src/screen.c171
-rw-r--r--src/structs.h58
-rw-r--r--src/terminal.c4
-rw-r--r--src/testdir/Make_all.mak6
-rw-r--r--src/testdir/dumps/Test_popupwin_01.dump10
-rw-r--r--src/testdir/test_popupwin.vim26
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h17
-rw-r--r--src/window.c176
31 files changed, 812 insertions, 171 deletions
diff --git a/Filelist b/Filelist
index 7cca776849..7ce0cb0027 100644
--- a/Filelist
+++ b/Filelist
@@ -79,6 +79,7 @@ SRC_ALL = \
src/option.c \
src/option.h \
src/popupmnu.c \
+ src/popupwin.c \
src/quickfix.c \
src/regexp.c \
src/regexp_nfa.c \
@@ -200,6 +201,7 @@ SRC_ALL = \
src/proto/ops.pro \
src/proto/option.pro \
src/proto/popupmnu.pro \
+ src/proto/popupwin.pro \
src/proto/quickfix.pro \
src/proto/regexp.pro \
src/proto/screen.pro \
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 2c2afa17c2..e7bb4fd7fa 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1361,6 +1361,8 @@ A jump table for the options with a short description can be found at |Q_op|.
prompt buffer where only the last line can be edited, meant
to be used by a plugin, see |prompt-buffer|
{only when compiled with the |+channel| feature}
+ popup buffer used in a popup window, see |popup|.
+ {only when compiled with the |+textprop| feature}
This option is used together with 'bufhidden' and 'swapfile' to
specify special kinds of buffers. See |special-buffers|.
@@ -8687,6 +8689,12 @@ A jump table for the options with a short description can be found at |Q_op|.
This option is not used for <F10>; on Win32 and with GTK <F10> will
select the menu, unless it has been mapped.
+ *'wincolor'* *'wcr'*
+'wincolor' 'wcr' string (default empty)
+ local to window
+ Highlight group name to use for this window instead of the Normal
+ color |hl-Normal|.
+
*'window'* *'wi'*
'window' 'wi' number (default screen height - 1)
global
diff --git a/runtime/doc/popup.txt b/runtime/doc/popup.txt
index 4813308903..8d3619acf7 100644
--- a/runtime/doc/popup.txt
+++ b/runtime/doc/popup.txt
@@ -27,12 +27,19 @@ popup window like with regular windows.
A popup window can be used for such things as:
- briefly show a message without changing the command line
- prompt the user with a dialog
-- display information while typing
+- display contextual information while typing
- give extra information for auto-completion
The text in the popup window can be colored with |text-properties|. It is
also possible to use syntax highlighting.
+The default color used is "Pmenu". If you prefer something else use the
+"highlight" argument or the 'wincolor' option, e.g.: >
+ hi MyPopupColor ctermbg=lightblue guibg=lightblue
+ call setwinvar(winid, '&wincolor', 'MyPopupColor')
+
+'hlsearch' and match highlighting are not displayed in a popup window.
+
A popup window has a window-ID like other windows, but behaves differently.
The size can be up to the whole Vim window and it overlaps other windows.
It contains a buffer, and that buffer is always associated with the popup
@@ -46,6 +53,20 @@ If this is not what you are looking for, check out other popup functionality:
- balloon, see |balloon-eval|
+WINDOW POSITION AND SIZE *popup-position*
+
+The height of the window is normally equal to the number of lines in the
+buffer. It can be limited with the "maxheight" property. You can use empty
+lines to increase the height.
+
+The width of the window is normally equal to the longest line in the buffer.
+It can be limited with the "maxwidth" property. You can use spaces to
+increase the width.
+
+By default the 'wrap' option is set, so that no text disappears. However, if
+there is not enough space, some text may be invisible.
+
+
TODO:
Example how to use syntax highlighting of a code snippet.
@@ -57,22 +78,14 @@ happens with popups?
the scroll offset into account.
Probably 2. is the best choice.
-Positioning relative to the popup-menu to avoid overlapping with it; add a
-function to get the position and size of the popup-menu.
-
IMPLEMENTATION:
-- Put code in popupwin.c
-- Use win_update() for displaying
-- At first redraw all windows NOT_VALID when the popup moves or hides.
-- At first always display the popup windows at the end of update_screen(),
- lowest zindex first.
-- Later make it more efficient and avoid flicker
-- Use a separate list of windows, one for each tab and one global. Also put
- "aucmd_win" in there.
-- add optional {buf} command to execute(). Only works for a buffer that is
- visible in a window in the current tab or in a popup window.
- E.g. for execute('syntax enable', 'silent', bufnr)
+- Code is in popupwin.c
+- handle screen resize in screenalloc().
+- Support tab-local popup windows, use tp_first_popupwin and
+ first_tab_popupwin. Swap like with firstwin/curwin.
+- Make redrawing more efficient and avoid flicker.
+- implement all the unimplemented features.
==============================================================================
@@ -89,6 +102,7 @@ popup_create({text}, {options}) *popup_create()*
- a string
- a list of strings
- a list of text lines with text properties
+ {not implemented yet}
{options} is a dictionary with many possible entries.
See |popup_create-usage| for details.
@@ -98,9 +112,16 @@ popup_create({text}, {options}) *popup_create()*
let winid = popup_create('hello', {})
let bufnr = winbufnr(winid)
call setbufline(bufnr, 2, 'second line')
+< In case of failure zero is returned.
+
+
+popup_close({id}) *popup_close()*
+ Close popup {id}. The window and the associated buffer will
+ be deleted.
popup_dialog({text}, {options}) *popup_dialog()*
+ {not implemented yet}
Just like |popup_create()| but with these default options: >
call popup_create({text}, {
\ 'pos': 'center',
@@ -111,6 +132,7 @@ popup_dialog({text}, {options}) *popup_dialog()*
popup_notification({text}, {options}) *popup_notification()*
+ {not implemented yet}
Show the {text} for 3 seconds at the top of the Vim window.
This works like: >
call popup_create({text}, {
@@ -126,6 +148,7 @@ popup_notification({text}, {options}) *popup_notification()*
popup_atcursor({text}, {options}) *popup_atcursor()*
+ {not implemented yet}
Show the {text} above the cursor, and close it when the cursor
moves. This works like: >
call popup_create({text}, {
@@ -137,6 +160,7 @@ popup_atcursor({text}, {options}) *popup_atcursor()*
popup_menu({text}, {options}) *popup_menu()*
+ {not implemented yet}
Show the {text} near the cursor, handle selecting one of the
items with cursorkeys, and close it an item is selected with
Space or Enter. {text} should have multiple lines to make this
@@ -153,14 +177,17 @@ popup_menu({text}, {options}) *popup_menu()*
popup_show({id}) *popup_show()*
+ {not implemented yet}
If {id} is a hidden popup, show it now.
popup_hide({id}) *popup_hide()*
+ {not implemented yet}
If {id} is a displayed popup, hide it now. If the popup has a
filter it will not be invoked for so long as the popup is
hidden.
popup_move({id}, {options}) *popup_move()*
+ {not implemented yet}
Move popup {id} to the position speficied with {options}.
{options} may contain the items from |popup_create()| that
specify the popup position: "line", "col", "pos", "maxheight",
@@ -168,6 +195,7 @@ popup_move({id}, {options}) *popup_move()*
popup_filter_menu({id}, {key}) *popup_filter_menu()*
+ {not implemented yet}
Filter that can be used for a popup. It handles the cursor
keys to move the selected index in the popup. Space and Enter
can be used to select an item. Invokes the "callback" of the
@@ -176,6 +204,7 @@ popup_filter_menu({id}, {key}) *popup_filter_menu()*
popup_filter_yesno({id}, {key}) *popup_filter_yesno()*
+ {not implemented yet}
Filter that can be used for a popup. It handles only the keys
'y', 'Y' and 'n' or 'N'. Invokes the "callback" of the
popup menu with the 1 for 'y' or 'Y' and zero for 'n' or 'N'
@@ -184,15 +213,31 @@ popup_filter_yesno({id}, {key}) *popup_filter_yesno()*
popup_setoptions({id}, {options}) *popup_setoptions()*
+ {not implemented yet}
Override options in popup {id} with entries in {options}.
popup_getoptions({id}) *popup_getoptions()*
+ {not implemented yet}
Return the {options} for popup {id}.
-
-popup_close({id}) *popup_close()*
- Close popup {id}.
+popup_getposition({id}) *popup_getposition()*
+ {not implemented yet}
+ Return the position and size of popup {id}. Returns a Dict
+ with these entries:
+ col screen column of the popup, one-based
+ line screen line of the popup, one-based
+ width width of the popup in screen cells
+ height height of the popup in screen cells
+
+win_execute({id}, {command})
+ {not implemented yet}
+ Like `execute()` but in the context of window {id}.
+ The window will temporarily be made the current window,
+ without triggering autocommands.
+ Example: >
+ call win_execute(winid, 'syntax enable')
+<
*:popupclear* *:popupc*
:popupc[lear] Emergency solution to a misbehaving plugin: close all popup
@@ -209,6 +254,7 @@ manipulation is restricted:
- 'swapfile' is off
- 'bufhidden' is "hide"
- 'buflisted' is off
+- 'undolevels' is -1: no undo at all
TODO: more
The window does have a cursor position, but the cursor is not displayed.
@@ -226,6 +272,7 @@ optionally text properties. It is in one of three forms:
- a string
- a list of strings
- a list of dictionaries, where each dictionary has these entries:
+ {not implemented yet}
text String with the text to display.
props A list of text properties. Optional.
Each entry is a dictionary, like the third argument of
@@ -238,55 +285,73 @@ The second argument of |popup_create()| is a dictionary with options:
"cursor", "cursor+1" or "cursor-1" to use the line of
the cursor and add or subtract a number of lines;
default is "cursor-1".
+ {only number is implemented}
col screen column where to position the popup; can use
"cursor" to use the column of the cursor, "cursor+99"
and "cursor-99" to add or subtract a number of
columns; default is "cursor"
+ {only number is implemented}
pos "topleft", "topright", "botleft" or "botright":
defines what corner of the popup "line" and "col" are
used for. Default is "botleft". Alternatively
- "center" can be used to position the popup somewhere
- near the cursor.
+ "center" can be used to position the popup in the
+ center of the Vim window.
+ {not implemented yet}
flip when TRUE (the default) and the position is relative
to the cursor, flip to below or above the cursor to
avoid overlap with the |popupmenu-completion| or
another popup with a higher "zindex"
+ {not implemented yet}
maxheight maximum height
minheight minimum height
+ {not implemented yet}
maxwidth maximum width
minwidth minimum width
+ {not implemented yet}
hidden when TRUE the popup exists but is not displayed; use
`popup_show()` to unhide it.
+ {not implemented yet}
tab when -1: display the popup on all tabs; when 0 (the
default): display the popup on the current tab;
otherwise the number of the tab page the popup is
displayed on; when invalid the current tab is used
+ {only -1 and 0 are implemented}
title text to be displayed above the first item in the
popup, on top of any border
+ {not implemented yet}
wrap TRUE to make the lines wrap (default TRUE)
- highlight highlight group name to use for the text, defines the
- background and foreground color
+ {not implemented yet}
+ highlight highlight group name to use for the text, stored in
+ 'wincolor'
+ {not implemented yet}
border list with numbers, defining the border thickness
above/right/below/left of the popup; an empty list
uses a border of 1 all around
+ {not implemented yet}
borderhighlight highlight group name to use for the border
+ {not implemented yet}
borderchars list with characters, defining the character to use
for the top/right/bottom/left border; optionally
followed by the character to use for the
topright/botright/botleft/topleft corner; an empty
list can be used to show a double line all around
+ {not implemented yet}
zindex priority for the popup, default 50
time time in milliseconds after which the popup will close;
when omitted |popup_close()| must be used.
+ {not implemented yet}
moved "cell": close the popup if the cursor moved at least
one screen cell; "word" allows for moving within
|<cword>|, "WORD" allows for moving within |<cWORD>|,
a list with two numbers specifies the start and end
column
+ {not implemented yet}
filter a callback that can filter typed characters, see
|popup-filter|
+ {not implemented yet}
callback a callback to be used when the popup closes, e.g. when
using |popup_filter_menu()|, see |popup-callback|.
+ {not implemented yet}
Depending on the "zindex" the popup goes under or above other popups. The
completion menu (|popup-menu|) has zindex 100. For messages that occur for a
@@ -299,6 +364,7 @@ outside of the Vim window will not be displayed, thus truncated.
POPUP TEXT PROPERTIES *popup-props*
+{not implemented yet}
These are similar to the third argument of |prop_add()|, but not exactly the
same, since they only apply to one line.
col starting column, counted in bytes, use one for the
@@ -318,11 +384,15 @@ same, since they only apply to one line.
POPUP FILTER *popup-filter*
+{not implemented yet}
A callback that gets any typed keys while a popup is displayed. The filter is
-not invoked for as long as the popup is hidden.
+not invoked when the popup is hidden.
The filter can return TRUE to indicate the key has been handled and is to be
discarded, or FALSE to let Vim handle the key as usual in the current state.
+In case it returns FALSE and there is another popup window visible, that
+filter is also called. The filter of the popup window with the highest zindex
+is called first.
The filter function is called with two arguments: the ID of the popup and the
key.
@@ -342,6 +412,7 @@ Vim provides standard filters |popup_filter_menu()| and
POPUP CALLBACK *popup-callback*
+{not implemented yet}
A callback that is invoked when the popup closes. Used by
|popup_filter_menu()|. Invoked with two arguments: the ID of the popup and
the result, which would usually be an index in the popup lines, or whatever
diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak
index 7844e004c6..f47981216c 100644
--- a/src/Make_cyg_ming.mak
+++ b/src/Make_cyg_ming.mak
@@ -740,6 +740,7 @@ OBJ = \
$(OUTDIR)/os_win32.o \
$(OUTDIR)/pathdef.o \
$(OUTDIR)/popupmnu.o \
+ $(OUTDIR)/popupwin.o \
$(OUTDIR)/quickfix.o \
$(OUTDIR)/regexp.o \
$(OUTDIR)/screen.o \
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index f8e406e436..c1cd0a460c 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -743,6 +743,8 @@ OBJ = \
$(OUTDIR)\os_win32.obj \
$(OUTDIR)\pathdef.obj \
$(OUTDIR)\popupmnu.obj \
+ $(OUTDIR)\popupwin.obj \
+ $(OUTDIR)\popupwin.obj \
$(OUTDIR)\quickfix.obj \
$(OUTDIR)\regexp.obj \
$(OUTDIR)\screen.obj \
@@ -1575,6 +1577,8 @@ $(OUTDIR)/pathdef.obj: $(OUTDIR) $(PATHDEF_SRC) $(INCL)
$(OUTDIR)/popupmnu.obj: $(OUTDIR) popupmnu.c $(INCL)
+$(OUTDIR)/popupwin.obj: $(OUTDIR) popupwin.c $(INCL)
+
$(OUTDIR)/quickfix.obj: $(OUTDIR) quickfix.c $(INCL)
$(OUTDIR)/regexp.obj: $(OUTDIR) regexp.c regexp_nfa.c $(INCL)
@@ -1745,6 +1749,7 @@ proto.h: \
proto/winclip.pro \
proto/os_win32.pro \
proto/popupmnu.pro \
+ proto/popupwin.pro \
proto/quickfix.pro \
proto/regexp.pro \
proto/screen.pro \
diff --git a/src/Make_vms.mms b/src/Make_vms.mms
index 1a0537bc8a..f01d325c0a 100644
--- a/src/Make_vms.mms
+++ b/src/Make_vms.mms
@@ -2,7 +2,7 @@
# Makefile for Vim on OpenVMS
#
# Maintainer: Zoltan Arpadffy <arpadffy@polarhome.com>
-# Last change: 2019 May 11
+# Last change: 2019 May 24
#
# This has script been tested on VMS 6.2 to 8.2 on DEC Alpha, VAX and IA64
# with MMS and MMK
@@ -313,7 +313,7 @@ SRC = arabic.c autocmd.c beval.c blob.c blowfish.c buffer.c change.c charset.c \
if_cscope.c if_xcmdsrv.c fileio.c findfile.c fold.c getchar.c \
hardcopy.c hashtab.c indent.c insexpand.c json.c list.c main.c mark.c \
menu.c mbyte.c memfile.c memline.c message.c misc1.c misc2.c move.c \
- normal.c ops.c option.c popupmnu.c quickfix.c regexp.c search.c \
+ normal.c ops.c option.c popupmnu.c popupwin.c, quickfix.c regexp.c search.c \
sha256.c sign.c spell.c spellfile.c syntax.c tag.c term.c termlib.c \
textprop.c ui.c undo.c usercmd.c userfunc.c version.c screen.c \
window.c os_unix.c os_vms.c pathdef.c \
@@ -327,7 +327,7 @@ OBJ = arabic.obj autocmd.obj beval.obj blob.obj blowfish.obj buffer.obj change.
fileio.obj findfile.obj fold.obj getchar.obj hardcopy.obj hashtab.obj \
indent.obj insexpand.obj json.obj list.obj main.obj mark.obj \
menu.obj memfile.obj memline.obj message.obj misc1.obj misc2.obj \
- move.obj mbyte.obj normal.obj ops.obj option.obj popupmnu.obj \
+ move.obj mbyte.obj normal.obj ops.obj option.obj popupmnu.obj popupwin.obj\
quickfix.obj regexp.obj search.obj sha256.obj sign.obj spell.obj \
spellfile.obj syntax.obj tag.obj term.obj termlib.obj textprop.obj \
ui.obj undo.obj usercmd.obj userfunc.obj screen.obj version.obj \
@@ -688,6 +688,10 @@ popupmnu.obj : popupmnu.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
globals.h
+popupwin.obj : popupwin.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h structs.h regexp.h \
+ gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
+ globals.h
quickfix.obj : quickfix.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
diff --git a/src/Makefile b/src/Makefile
index ff5ae10160..d74eac40a0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1620,6 +1620,7 @@ BASIC_SRC = \
os_unix.c \
auto/pathdef.c \
popupmnu.c \
+ popupwin.c \
pty.c \
quickfix.c \
regexp.c \
@@ -1734,6 +1735,7 @@ OBJ_COMMON = \
objects/os_unix.o \
objects/pathdef.o \
objects/popupmnu.o \
+ objects/popupwin.o \
objects/pty.o \
objects/quickfix.o \
objects/regexp.o \
@@ -1873,6 +1875,7 @@ PRO_AUTO = \
os_mac_conv.pro \
os_unix.pro \
popupmnu.pro \
+ popupwin.pro \
pty.pro \
quickfix.pro \
regexp.pro \
@@ -3208,6 +3211,9 @@ objects/pathdef.o: auto/pathdef.c
objects/popupmnu.o: popupmnu.c
$(CCC) -o $@ popupmnu.c
+objects/popupwin.o: popupwin.c
+ $(CCC) -o $@ popupwin.c
+
objects/pty.o: pty.c
$(CCC) -o $@ pty.c
@@ -3612,6 +3618,10 @@ objects/popupmnu.o: popupmnu.c vim.h protodef.h auto/config.h feature.h os_unix.
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h
+objects/popupwin.o: popupwin.c vim.h protodef.h auto/config.h feature.h os_unix.h \
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
+ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
+ proto.h globals.h
objects/pty.o: pty.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
diff --git a/src/autocmd.c b/src/autocmd.c
index 614bc331f5..152dabde7d 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -1349,7 +1349,7 @@ ex_doautoall(exarg_T *eap)
*/
FOR_ALL_BUFFERS(buf)
{
- if (buf->b_ml.ml_mfp != NULL)
+ if (buf->b_ml.ml_mfp != NULL && !bt_popup(buf))
{
// find a window for this buffer and save some values
aucmd_prepbuf(&aco, buf);
@@ -1423,7 +1423,7 @@ aucmd_prepbuf(
// back to using the current window.
if (win == NULL && aucmd_win == NULL)
{
- win_alloc_aucmd_win();
+ aucmd_win = win_alloc_popup_win();
if (aucmd_win == NULL)
win = curwin;
}
@@ -1451,20 +1451,12 @@ aucmd_prepbuf(
// unexpected results.
aco->use_aucmd_win = TRUE;
aucmd_win_used = TRUE;
- aucmd_win->w_buffer = buf;
-#if defined(FEAT_SYN_HL) || defined(FEAT_SPELL)
- aucmd_win->w_s = &buf->b_s;
-#endif
- ++buf->b_nwindows;
- win_init_empty(aucmd_win); // set cursor and topline to safe values
- // Make sure w_localdir and globaldir are NULL to avoid a chdir() in
- // win_enter_ext().
- VIM_CLEAR(aucmd_win->w_localdir);
+ win_init_popup_win(aucmd_win, buf);
+
aco->globaldir = globaldir;
globaldir = NULL;
-
// Split the current window, put the aucmd_win in the upper half.
// We don't want the BufEnter or WinEnter autocommands.
block_autocmds();
@@ -1620,6 +1612,8 @@ apply_autocmds(
int force, // when TRUE, ignore autocmd_busy
buf_T *buf) // buffer for <abuf>
{
+ if (bt_popup(buf))
+ return FALSE;
return apply_autocmds_group(event, fname, fname_io, force,
AUGROUP_ALL, buf, NULL);
}
diff --git a/src/buffer.c b/src/buffer.c
index f6210952d6..6174d80ce2 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -456,7 +456,7 @@ close_buffer(
win_T *win, /* if not NULL, set b_last_cursor */
buf_T *buf,
int action,
- int abort_if_last UNUSED)
+ int abort_if_last)
{
int is_curbuf;
int nwindows;
@@ -5678,7 +5678,17 @@ bt_help(buf_T *buf)
int
bt_prompt(buf_T *buf)
{
- return buf != NULL && buf->b_p_bt[0] == 'p';
+ return buf != NULL && buf->b_p_bt[0] == 'p' && buf->b_p_bt[1] == 'r';
+}
+
+/*
+ * Return TRUE if "buf" is a buffer for a popup window.
+ */
+ int
+bt_popup(buf_T *buf)
+{
+ return buf != NULL && buf->b_p_bt != NULL
+ && buf->b_p_bt[0] == 'p' && buf->b_p_bt[1] == 'o';
}
/*
diff --git a/src/eval.c b/src/eval.c
index 1d5d0f11a9..fb417c8b41 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -5585,6 +5585,19 @@ garbage_collect(int testing)
if (aucmd_win != NULL)
abort = abort || set_ref_in_item(&aucmd_win->w_winvar.di_tv, copyID,
NULL, NULL);
+#ifdef FEAT_TEXT_PROP
+ for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
+ abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,
+ NULL, NULL);
+ for (wp = first_tab_popupwin; wp != NULL; wp = wp->w_next)
+ abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,
+ NULL, NULL);
+ FOR_ALL_TABPAGES(tp)
+ if (tp != curtab)
+ for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
+ abort = abort || set_ref_in_item(&wp->w_winvar.di_tv, copyID,
+ NULL, NULL);
+#endif
/* tabpage-local variables */
FOR_ALL_TABPAGES(tp)
@@ -8801,7 +8814,20 @@ find_win_by_nr(
break;
}
if (nr >= LOWEST_WIN_ID)
+ {
+#ifdef FEAT_TEXT_PROP
+ // popup windows are in a separate list
+ for (wp = (tp == NULL || tp == curtab)
+ ? first_tab_popupwin : tp->tp_first_popupwin;
+ wp != NULL; wp = wp->w_next)
+ if (wp->w_id == nr)
+ return wp;
+ for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
+ if (wp->w_id == nr)
+ return wp;
+#endif
return NULL;
+ }
return wp;
}
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 58ea7103fc..914efb1c9d 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -807,6 +807,10 @@ static struct fst
#ifdef FEAT_PERL
{"perleval", 1, 1, f_perleval},
#endif
+#ifdef FEAT_TEXT_PROP
+ {"popup_close", 1, 1, f_popup_close},
+ {"popup_create", 2, 2, f_popup_create},
+#endif
#ifdef FEAT_FLOAT
{"pow", 2, 2, f_pow},
#endif
diff --git a/src/ex_cmdidxs.h b/src/ex_cmdidxs.h
index 0103a1741a..2aae4b63d8 100644
--- a/src/ex_cmdidxs.h
+++ b/src/ex_cmdidxs.h
@@ -21,16 +21,16 @@ static const unsigned short cmdidxs1[26] =
/* n */ 285,
/* o */ 305,
/* p */ 317,
- /* q */ 356,
- /* r */ 359,
- /* s */ 379,
- /* t */ 447,
- /* u */ 492,
- /* v */ 503,
- /* w */ 521,
- /* x */ 535,
- /* y */ 545,
- /* z */ 546
+ /* q */ 357,
+ /* r */ 360,
+ /* s */ 380,
+ /* t */ 448,
+ /* u */ 493,
+ /* v */ 504,
+ /* w */ 522,
+ /* x */ 536,
+ /* y */ 546,
+ /* z */ 547
};
/*
@@ -56,7 +56,7 @@ static const unsigned char cmdidxs2[26][26] =
/* m */ { 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 },
/* n */ { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 8, 10, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0 },
/* o */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 5, 0, 0, 0, 0, 0, 0, 9, 0, 11, 0, 0, 0 },
- /* p */ { 1, 0, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 9, 0, 0, 16, 17, 26, 0, 27, 0, 28, 0 },
+ /* p */ { 1, 0, 3, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 10, 0, 0, 17, 18, 27, 0, 28, 0, 29, 0 },
/* q */ { 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
/* r */ { 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 19, 0, 0, 0, 0 },
/* s */ { 2, 6, 15, 0, 19, 23, 0, 25, 26, 0, 0, 29, 31, 35, 39, 41, 0, 49, 0, 50, 0, 62, 63, 0, 64, 0 },
@@ -69,4 +69,4 @@ static const unsigned char cmdidxs2[26][26] =
/* z */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
-static const int command_count = 559;
+static const int command_count = 560;
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index 5ec69be364..9c913a8f6a 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -1091,6 +1091,9 @@ EX(CMD_pop, "pop", ex_tag,
EX(CMD_popup, "popup", ex_popup,
NEEDARG|EXTRA|BANG|TRLBAR|NOTRLCOM|CMDWIN,
ADDR_NONE),
+EX(CMD_popupclear, "popupclear", ex_popupclear,
+ TRLBAR,
+ ADDR_NONE),
EX(CMD_ppop, "ppop", ex_ptag,
RANGE|BANG|COUNT|TRLBAR|ZEROR,
ADDR_OTHER),
diff --git a/src/feature.h b/src/feature.h
index bfbabe0afa..c613c4bc94 100644
--- a/src/feature.h
+++ b/src/feature.h
@@ -477,7 +477,7 @@
#endif
/*
- * +textprop Text properties
+ * +textprop Text properties and popup windows
*/
#if defined(FEAT_EVAL) && defined(FEAT_SYN_HL)
# define FEAT_TEXT_PROP
diff --git a/src/globals.h b/src/globals.h
index 09ac6b5e80..7d250f443f 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -550,9 +550,10 @@ EXTERN int clip_unnamed_saved INIT(= 0);
#endif
/*
- * All windows are linked in a list. firstwin points to the first entry,
- * lastwin to the last entry (can be the same as firstwin) and curwin to the
- * currently active window.
+ * All regular windows are linked in a list. "firstwin" points to the first
+ * entry, "lastwin" to the last entry (can be the same as firstwin) and
+ * "curwin" to the currently active window.
+ * When switching tabs these swapped with the pointers in "tabpage_T".
*/
EXTERN win_T *firstwin; /* first window */
EXTERN win_T *lastwin; /* last window */
@@ -580,6 +581,11 @@ EXTERN win_T *curwin; /* currently active window */
EXTERN win_T *aucmd_win; /* window used in aucmd_prepbuf() */
EXTERN int aucmd_win_used INIT(= FALSE); /* aucmd_win is being used */
+#ifdef FEAT_TEXT_PROP
+EXTERN win_T *first_tab_popupwin; // first popup window local to tab page
+EXTERN win_T *first_popupwin; // first global popup window
+#endif
+
/*
* The window layout is kept in a tree of frames. topframe points to the top
* of the tree.
diff --git a/src/option.c b/src/option.c
index 42a252e0f6..9b23eed58e 100644
--- a/src/option.c
+++ b/src/option.c
@@ -196,6 +196,7 @@
# define PV_BRI OPT_WIN(WV_BRI)
# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
#endif
+# define PV_WCR OPT_WIN(WV_WCR)
#ifdef FEAT_DIFF
# define PV_DIFF OPT_WIN(WV_DIFF)
#endif
@@ -3033,6 +3034,10 @@ static struct vimoption options[] =
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
+ {"wincolor", "wcr", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
+ (char_u *)VAR_WIN, PV_WCR,
+ {(char_u *)"", (char_u *)NULL}
+ SCTX_INIT},
{"window", "wi", P_NUM|P_VI_DEF,
(char_u *)&p_window, PV_NONE,
{(char_u *)0L, (char_u *)0L} SCTX_INIT},
@@ -3211,7 +3216,7 @@ static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
-static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", "prompt", NULL};
+static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", "prompt", "popup", NULL};
static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};<