Skip to content

Commit

Permalink
Merge remote-tracking branch 'vim/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ychin committed Jul 19, 2019
2 parents 273e46e + 7964873 commit 486f4fd
Show file tree
Hide file tree
Showing 30 changed files with 721 additions and 158 deletions.
11 changes: 10 additions & 1 deletion runtime/doc/options.txt
Expand Up @@ -5776,7 +5776,16 @@ A jump table for the options with a short description can be found at |Q_op|.
{not available when compiled without the |+windows| or
|+quickfix| features}
Default height for a preview window. Used for |:ptag| and associated
commands. Used for |CTRL-W_}| when no count is given.
commands. Used for |CTRL-W_}| when no count is given. Not used when
'previewpopup' is set.

*'previewpopup'* *'pvp'*
'previewpopup' 'pvp' string (default empty)
global
{not available when compiled without the |+windows|,
|+textprop| or |+quickfix| feature}
When not empty a popup window is used for commands that would open a
preview window. See |preview-popup|.

*'previewwindow'* *'nopreviewwindow'*
*'pvw'* *'nopvw'* *E590*
Expand Down
17 changes: 12 additions & 5 deletions runtime/doc/popup.txt
Expand Up @@ -303,7 +303,7 @@ popup_getoptions({id}) *popup_getoptions()*
zero. When all values are one then an empty list is included.

"borderhighlight" is not included when all values are empty.
"scrollbarhighlight" and "thumbhighlight" are onlu included
"scrollbarhighlight" and "thumbhighlight" are only included
when set.

"tabpage" will be -1 for a global popup, zero for a popup on
Expand Down Expand Up @@ -345,7 +345,7 @@ popup_hide({id}) *popup_hide()*


popup_locate({row}, {col}) *popup_locate()*
Return the |window-ID| of the popup at screen positoin {row}
Return the |window-ID| of the popup at screen position {row}
and {col}. If there are multiple popups the one with the
highest zindex is returned. If there are no popups at this
position then zero is returned.
Expand All @@ -362,6 +362,7 @@ popup_menu({what}, {options}) *popup_menu()*
\ drag: 1,
\ wrap: 0,
\ border: [],
\ cursorline: 1,
\ padding: [0,1,0,1],
\ filter: 'popup_filter_menu',
\ })
Expand Down Expand Up @@ -429,6 +430,7 @@ popup_setoptions({id}, {options}) *popup_setoptions()*
callback
close
drag
cursorline
filter
firstline
flip
Expand Down Expand Up @@ -598,6 +600,11 @@ The second argument of |popup_create()| is a dictionary with options:
{start} or after {end}
The popup also closes if the cursor moves to another
line or to another window.
cursorline non-zero: Highlight the cursor line. Also scrolls the
text to show this line (only works properly
when 'wrap' is off).
zero: Do not highlight the cursor line.
Default is zero, except for |popup_menu()|.
filter A callback that can filter typed characters, see
|popup-filter|.
callback A callback that is called when the popup closes, e.g.
Expand Down Expand Up @@ -695,8 +702,8 @@ If the text does not fit in the popup a scrollbar is displayed on the right of
the window. This can be disabled by setting the "scrollbar" option to zero.
When the scrollbar is displayed mouse scroll events, while the mouse pointer
is on the popup, will cause the text to scroll up or down as you would expect.
A click in the upper halve of the scrollbar will scroll the text one line
down. A click in the lower halve wil scroll the text one line up. However,
A click in the upper half of the scrollbar will scroll the text one line
down. A click in the lower half wil scroll the text one line up. However,
this is limited so that the popup does not get smaller.


Expand All @@ -709,7 +716,7 @@ list has four numbers:
leftmost, negative for counting from the right, -1 for
rightmost
endcol last column, like "col"
line start line, positive for conting from the top, 1 for top,
line start line, positive for counting from the top, 1 for top,
negative for counting from the bottom, -1 for bottom
endline end line, like "line"

Expand Down
10 changes: 9 additions & 1 deletion runtime/doc/windows.txt
Expand Up @@ -864,7 +864,15 @@ height of the preview window when it's opened. The 'previewwindow' option is
set in the preview window to be able to recognize it. The 'winfixheight'
option is set to have it keep the same height when opening/closing other
windows.

*preview-popup*
Alternatively, a popup window can be used by setting the 'previewpopup'
option. When set, it overrules the 'previewwindow' and 'previewheight'
settings. The option is a comma separated list of values:
height maximum height of the popup
width maximu width of the popup
Example: >
:set previewpopup=height:10,width:60
<
*:pta* *:ptag*
:pta[g][!] [tagname]
Does ":tag[!] [tagname]" and shows the found tag in a
Expand Down
4 changes: 3 additions & 1 deletion src/beval.c
Expand Up @@ -10,7 +10,7 @@

#include "vim.h"

#if defined(FEAT_BEVAL) || defined(FEAT_TEXT_PROP) || defined(PROT)
#if defined(FEAT_BEVAL) || defined(FEAT_TEXT_PROP) || defined(PROTO)
/*
* Find text under the mouse position "row" / "col".
* If "getword" is TRUE the returned text in "*textp" is not the whole line but
Expand Down Expand Up @@ -72,6 +72,7 @@ find_word_under_cursor(
}

col = vcol2col(wp, lnum, col);
scol = col;

if (VIsual_active
&& wp->w_buffer == curwin->w_buffer
Expand All @@ -95,6 +96,7 @@ find_word_under_cursor(
lbuf = vim_strnsave(lbuf + spos->col, len);
lnum = spos->lnum;
col = spos->col;
scol = col;
}
else
{
Expand Down
53 changes: 10 additions & 43 deletions src/change.c
Expand Up @@ -155,19 +155,16 @@ changed_internal(void)
static long next_listener_id = 0;

/*
* Check if the change at "lnum" / "col" is above or overlaps with an existing
* changed. If above then flush changes and invoke listeners.
* If "merge" is TRUE do the merge.
* Check if the change at "lnum" is above or overlaps with an existing
* change. If above then flush changes and invoke listeners.
* Returns TRUE if the change was merged.
*/
static int
check_recorded_changes(
buf_T *buf,
linenr_T lnum,
colnr_T col,
linenr_T lnume,
long xtra,
int merge)
long xtra)
{
if (buf->b_recorded_changes != NULL && xtra != 0)
{
Expand All @@ -182,42 +179,12 @@ check_recorded_changes(
li->li_tv.vval.v_dict, (char_u *)"lnum");
prev_lnume = (linenr_T)dict_get_number(
li->li_tv.vval.v_dict, (char_u *)"end");
if (prev_lnum >= lnum || prev_lnum > lnume
|| (prev_lnume >= lnum && xtra != 0))
if (prev_lnum >= lnum || prev_lnum > lnume || prev_lnume >= lnum)
{
if (li->li_next == NULL && lnum == prev_lnum
&& xtra == 0
&& col + 1 == (colnr_T)dict_get_number(
li->li_tv.vval.v_dict, (char_u *)"col"))
{
if (merge)
{
dictitem_T *di;

// Same start point and nothing is following, entries
// can be merged.
di = dict_find(li->li_tv.vval.v_dict,
(char_u *)"end", -1);
if (di != NULL)
{
prev_lnum = tv_get_number(&di->di_tv);
if (lnume > prev_lnum)
di->di_tv.vval.v_number = lnume;
}
di = dict_find(li->li_tv.vval.v_dict,
(char_u *)"added", -1);
if (di != NULL)
di->di_tv.vval.v_number += xtra;
return TRUE;
}
}
else
{
// the current change is going to make the line number in
// the older change invalid, flush now
invoke_listeners(curbuf);
break;
}
// the current change is going to make the line number in
// the older change invalid, flush now
invoke_listeners(curbuf);
break;
}
}
}
Expand All @@ -242,7 +209,7 @@ may_record_change(

// If the new change is going to change the line numbers in already listed
// changes, then flush.
if (check_recorded_changes(curbuf, lnum, col, lnume, xtra, TRUE))
if (check_recorded_changes(curbuf, lnum, lnume, xtra))
return;

if (curbuf->b_recorded_changes == NULL)
Expand Down Expand Up @@ -362,7 +329,7 @@ f_listener_remove(typval_T *argvars, typval_T *rettv)
void
may_invoke_listeners(buf_T *buf, linenr_T lnum, linenr_T lnume, int added)
{
check_recorded_changes(buf, lnum, 0, lnume, added, FALSE);
check_recorded_changes(buf, lnum, lnume, added);
}

/*
Expand Down
32 changes: 23 additions & 9 deletions src/ex_cmds.c
Expand Up @@ -6270,28 +6270,42 @@ prepare_tagpreview(
*/
if (!curwin->w_p_pvw)
{
FOR_ALL_WINDOWS(wp)
if (wp->w_p_pvw)
break;
# ifdef FEAT_TEXT_PROP
if (*p_pvp != NUL)
{
wp = popup_find_preview_window();
if (wp != NULL)
popup_set_wantpos(wp);
}
else
# endif
{
FOR_ALL_WINDOWS(wp)
if (wp->w_p_pvw)
break;
}
if (wp != NULL)
win_enter(wp, undo_sync);
else
{
/*
* There is no preview window open yet. Create one.
*/
if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0)
== FAIL)
# ifdef FEAT_TEXT_PROP
if (*p_pvp != NUL)
return popup_create_preview_window();
# endif
if (win_split(g_do_tagpreview > 0 ? g_do_tagpreview : 0, 0) == FAIL)
return FALSE;
curwin->w_p_pvw = TRUE;
curwin->w_p_wfh = TRUE;
RESET_BINDING(curwin); /* don't take over 'scrollbind'
and 'cursorbind' */
RESET_BINDING(curwin); // don't take over 'scrollbind'
// and 'cursorbind'
# ifdef FEAT_DIFF
curwin->w_p_diff = FALSE; /* no 'diff' */
curwin->w_p_diff = FALSE; // no 'diff'
# endif
# ifdef FEAT_FOLDING
curwin->w_p_fdc = 0; /* no 'foldcolumn' */
curwin->w_p_fdc = 0; // no 'foldcolumn'
# endif
return TRUE;
}
Expand Down
7 changes: 6 additions & 1 deletion src/ex_docmd.c
Expand Up @@ -5908,12 +5908,17 @@ ex_pclose(exarg_T *eap)
{
win_T *win;

// First close any normal window.
FOR_ALL_WINDOWS(win)
if (win->w_p_pvw)
{
ex_win_close(eap->forceit, win, NULL);
break;
return;
}
# ifdef FEAT_TEXT_PROP
// Also when 'previewpopup' is empty, it might have been cleared.
popup_close_preview();
# endif
}
#endif

Expand Down
17 changes: 9 additions & 8 deletions src/memline.c
Expand Up @@ -3566,6 +3566,15 @@ adjust_text_props_for_delete(
ml_delete(linenr_T lnum, int message)
{
ml_flush_line(curbuf);
if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count)
return FAIL;

#ifdef FEAT_EVAL
// When inserting above recorded changes: flush the changes before changing
// the text.
may_invoke_listeners(curbuf, lnum, lnum + 1, -1);
#endif

return ml_delete_int(curbuf, lnum, message);
}

Expand All @@ -3590,14 +3599,6 @@ ml_delete_int(buf_T *buf, linenr_T lnum, int message)
int textprop_save_len;
#endif

if (lnum < 1 || lnum > buf->b_ml.ml_line_count)
return FAIL;

#ifdef FEAT_EVAL
// When inserting above recorded changes: flush the changes before changing
// the text.
may_invoke_listeners(buf, lnum, lnum + 1, -1);
#endif
if (lowest_marked && lowest_marked > lnum)
lowest_marked--;

Expand Down
18 changes: 18 additions & 0 deletions src/option.c
Expand Up @@ -2155,6 +2155,15 @@ static struct vimoption options[] =
(char_u *)NULL, PV_NONE,
#endif
{(char_u *)12L, (char_u *)0L} SCTX_INIT},
{"previewpopup", "pvp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
#ifdef FEAT_TEXT_PROP
(char_u *)&p_pvp, PV_NONE,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}
#endif
SCTX_INIT},
{"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
#if defined(FEAT_QUICKFIX)
(char_u *)VAR_WIN, PV_PVW,
Expand Down Expand Up @@ -7954,6 +7963,15 @@ did_set_string_option(
}
#endif

#ifdef FEAT_TEXT_PROP
// 'previewpopup'
else if (varp == &p_pvp)
{
if (parse_previewpopup(NULL) == FAIL)
errmsg = e_invarg;
}
#endif

/* Options that are a list of flags. */
else
{
Expand Down
3 changes: 3 additions & 0 deletions src/option.h
Expand Up @@ -511,6 +511,9 @@ EXTERN int fuoptions_bgcolor;
argb color. */
#endif
EXTERN int p_gd; /* 'gdefault' */
#ifdef FEAT_TEXT_PROP
EXTERN char_u *p_pvp; // 'previewpopup'
#endif
#ifdef FEAT_PRINTER
EXTERN char_u *p_pdev; /* 'printdevice' */
# ifdef FEAT_POSTSCRIPT
Expand Down

0 comments on commit 486f4fd

Please sign in to comment.