Skip to content

Commit f9c85f5

Browse files
committed
patch 8.1.1608: the evalfunc.c file is too big
Problem: The evalfunc.c file is too big. Solution: Move sign functionality to sign.c.
1 parent 548be7f commit f9c85f5

10 files changed

Lines changed: 130 additions & 22 deletions

File tree

runtime/doc/popup.txt

Lines changed: 29 additions & 4 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 22
1+
*popup.txt* For Vim version 8.1. Last change: 2019 Jun 29
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -86,9 +86,12 @@ that it is in.
8686

8787

8888
TODO:
89-
- click near top of scrollbar scrolls down, clear near bottom scrolls up.
90-
- Allow for setting scrollbar color: scrollbarhighlight,
91-
scrollbarthumbhighlight ?
89+
- Currently 'buftype' is set to "popup", but all the specifics are on the
90+
window. Can we use a "normal" buffer and put the type on the window? (#4595)
91+
What if it's modified and the window closes?
92+
- Add test for when popup with mask is off the left and off the right of the
93+
screen.
94+
- check padding/border when popup is off the left and right of the screen.
9295
- Have a way to scroll to the bottom? (#4577)
9396
- Why does 'nrformats' leak from the popup window buffer???
9497
- Disable commands, feedkeys(), CTRL-W, etc. in a popup window.
@@ -256,6 +259,8 @@ popup_getoptions({id}) *popup_getoptions()*
256259
zero. When all values are one then an empty list is included.
257260

258261
"borderhighlight" is not included when all values are empty.
262+
"scrollbarhighlight" and "thumbhighlight" are onlu included
263+
when set.
259264

260265
"tabpage" will be -1 for a global popup, zero for a popup on
261266
the current tabpage and a positive number for a popup on
@@ -377,6 +382,8 @@ popup_setoptions({id}, {options}) *popup_setoptions()*
377382
borderhighlight
378383
borderchars
379384
scrollbar
385+
scrollbarhighlight
386+
thumbhighlight
380387
zindex
381388
mask
382389
time
@@ -534,6 +541,13 @@ The second argument of |popup_create()| is a dictionary with options:
534541
otherwise ASCII characters are used.
535542
scrollbar non-zero: show a scrollbar when the text doesn't fit.
536543
zero: do not show a scrollbar. Default is non-zero.
544+
Also see |popup-scrollbar|.
545+
scrollbarhighlight Highlight group name for the scrollbar. The
546+
background color is what matters. When not given then
547+
PmenuSbar is used.
548+
thumbhighlight Highlight group name for the scrollbar thumb. The
549+
background color is what matters. When not given then
550+
PmenuThumb is used.
537551
zindex Priority for the popup, default 50. Minimum value is
538552
1, maximum value is 32000.
539553
mask A list of lists with coordinates, defining parts of
@@ -639,6 +653,17 @@ If the popup is force-closed, e.g. because the cursor moved or CTRL-C was
639653
pressed, the number -1 is passed to the callback.
640654

641655

656+
POPUP SCROLLBAR *popup-scrollbar*
657+
658+
If the text does not fit in the popup a scrollbar is displayed on the right of
659+
the window. This can be disabled by setting the "scrollbar" option to zero.
660+
When the scrollbar is displayed mouse scroll events, while the mouse pointer
661+
is on the popup, will cause the text to scroll up or down as you would expect.
662+
A click in the upper halve of the scrollbar will scroll the text one line
663+
down. A click in the lower halve wil scroll the text one line up. However,
664+
this is limited so that the popup does not get smaller.
665+
666+
642667
POPUP MASK *popup-mask*
643668

644669
To minimize the text that the popup covers, parts of it can be made

src/normal.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4561,20 +4561,7 @@ nv_mousescroll(cmdarg_T *cap)
45614561
}
45624562
#ifdef FEAT_TEXT_PROP
45634563
if (bt_popup(curwin->w_buffer))
4564-
{
4565-
int height = curwin->w_height;
4566-
4567-
curwin->w_firstline = curwin->w_topline;
4568-
popup_adjust_position(curwin);
4569-
4570-
// we don't want the popup to get smaller, decrement the first line
4571-
// until it doesn't
4572-
while (curwin->w_firstline > 1 && curwin->w_height < height)
4573-
{
4574-
--curwin->w_firstline;
4575-
popup_adjust_position(curwin);
4576-
}
4577-
}
4564+
popup_set_firstline(curwin);
45784565
#endif
45794566
}
45804567
# ifdef FEAT_GUI

src/popupwin.c

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,58 @@ popup_drag(win_T *wp)
234234
popup_adjust_position(wp);
235235
}
236236

237+
/*
238+
* Set w_firstline to match the current "wp->w_topline".
239+
*/
240+
void
241+
popup_set_firstline(win_T *wp)
242+
{
243+
int height = wp->w_height;
244+
245+
wp->w_firstline = wp->w_topline;
246+
popup_adjust_position(wp);
247+
248+
// we don't want the popup to get smaller, decrement the first line
249+
// until it doesn't
250+
while (wp->w_firstline > 1 && wp->w_height < height)
251+
{
252+
--wp->w_firstline;
253+
popup_adjust_position(wp);
254+
}
255+
}
256+
257+
/*
258+
* Handle a click in a popup window, if it is in the scrollbar.
259+
*/
260+
void
261+
popup_handle_scrollbar_click(win_T *wp, int row, int col)
262+
{
263+
int height = popup_height(wp);
264+
int old_topline = wp->w_topline;
265+
266+
if (wp->w_has_scrollbar == 0)
267+
return;
268+
if (row >= wp->w_popup_border[0]
269+
&& row < height - wp->w_popup_border[2]
270+
&& col == popup_width(wp) - 1)
271+
{
272+
if (row >= height / 2)
273+
{
274+
// Click in lower half, scroll down.
275+
if (wp->w_topline < wp->w_buffer->b_ml.ml_line_count)
276+
++wp->w_topline;
277+
}
278+
else if (wp->w_topline > 1)
279+
// click on upper half, scroll up.
280+
--wp->w_topline;
281+
if (wp->w_topline != old_topline)
282+
{
283+
popup_set_firstline(wp);
284+
redraw_win_later(wp, NOT_VALID);
285+
}
286+
}
287+
}
288+
237289
#if defined(FEAT_TIMERS)
238290
static void
239291
popup_add_timeout(win_T *wp, int time)
@@ -631,7 +683,8 @@ popup_width(win_T *wp)
631683
{
632684
return wp->w_width
633685
+ wp->w_popup_padding[3] + wp->w_popup_border[3]
634-
+ wp->w_popup_padding[1] + wp->w_popup_border[1];
686+
+ wp->w_popup_padding[1] + wp->w_popup_border[1]
687+
+ wp->w_has_scrollbar;
635688
}
636689

637690
/*

src/proto/popupwin.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
int popup_on_border(win_T *wp, int row, int col);
33
void popup_start_drag(win_T *wp);
44
void popup_drag(win_T *wp);
5+
void popup_set_firstline(win_T *wp);
6+
void popup_handle_scrollbar_click(win_T *wp, int row, int col);
57
int popup_height(win_T *wp);
68
int popup_width(win_T *wp);
79
void popup_adjust_position(win_T *wp);

src/structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2903,7 +2903,7 @@ struct window_S
29032903
int w_wantcol; // "col" for popup window
29042904
int w_firstline; // "firstline" for popup window
29052905
int w_want_scrollbar; // when zero don't use a scrollbar
2906-
int w_has_scrollbar; // scrollbar displayed
2906+
int w_has_scrollbar; // 1 if scrollbar displayed, 0 otherwise
29072907
char_u *w_scrollbar_highlight; // "scrollbarhighlight"
29082908
char_u *w_thumb_highlight; // "thumbhighlight"
29092909
int w_popup_padding[4]; // popup padding top/right/bot/left
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
>1+0&#ffffff0| @73
2+
|2| @73
3+
|3| @73
4+
|4| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#ff404010| +0&#ffffff0@32
5+
|5| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#4040ff13| +0&#ffffff0@32
6+
|6| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#4040ff13| +0&#ffffff0@32
7+
|7| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#ff404010| +0&#ffffff0@32
8+
|8| @73
9+
|9| @73
10+
|:|c|a|l@1| |C|l|i|c|k|T|o|p|(|)| @40|1|,|1| @10|T|o|p|
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
>1+0&#ffffff0| @73
2+
|2| @73
3+
|3| @73
4+
|4| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#ff404010| +0&#ffffff0@32
5+
|5| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#ff404010| +0&#ffffff0@32
6+
|6| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#4040ff13| +0&#ffffff0@32
7+
|7| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#4040ff13| +0&#ffffff0@32
8+
|8| @73
9+
|9| @73
10+
|:|c|a|l@1| |C|l|i|c|k|B|o|t|(|)| @40|1|,|1| @10|T|o|p|

src/testdir/test_popupwin.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,15 @@ func Test_popup_scrollbar()
14361436
func ScrollDown()
14371437
call feedkeys("\<F3>\<ScrollWheelDown>", "xt")
14381438
endfunc
1439+
func ClickTop()
1440+
call feedkeys("\<F4>\<LeftMouse>", "xt")
1441+
endfunc
1442+
func ClickBot()
1443+
call feedkeys("\<F5>\<LeftMouse>", "xt")
1444+
endfunc
14391445
map <silent> <F3> :call test_setmouse(5, 36)<CR>
1446+
map <silent> <F4> :call test_setmouse(4, 42)<CR>
1447+
map <silent> <F5> :call test_setmouse(7, 42)<CR>
14401448
END
14411449
call writefile(lines, 'XtestPopupScroll')
14421450
let buf = RunVimInTerminal('-S XtestPopupScroll', {'rows': 10})
@@ -1464,6 +1472,14 @@ func Test_popup_scrollbar()
14641472
call term_sendkeys(buf, ":call ScrollDown()\<CR>")
14651473
call VerifyScreenDump(buf, 'Test_popupwin_scroll_7', {})
14661474

1475+
call term_sendkeys(buf, ":call ClickTop()\<CR>")
1476+
sleep 100m
1477+
call term_sendkeys(buf, ":call ClickTop()\<CR>")
1478+
call VerifyScreenDump(buf, 'Test_popupwin_scroll_8', {})
1479+
1480+
call term_sendkeys(buf, ":call ClickBot()\<CR>")
1481+
call VerifyScreenDump(buf, 'Test_popupwin_scroll_9', {})
1482+
14671483
" clean up
14681484
call StopVimInTerminal(buf)
14691485
call delete('XtestPopupScroll')

src/ui.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,7 +2998,7 @@ jump_to_mouse(
29982998
return IN_OTHER_WIN;
29992999
#endif
30003000
#ifdef FEAT_TEXT_PROP
3001-
// Continue a modeless selection in a popup window.
3001+
// Continue a modeless selection in a popup window or dragging it.
30023002
if (in_popup_win)
30033003
{
30043004
if (popup_dragwin != NULL)
@@ -3056,6 +3056,9 @@ jump_to_mouse(
30563056
popup_start_drag(wp);
30573057
return IN_UNKNOWN;
30583058
}
3059+
if (which_button == MOUSE_LEFT)
3060+
// If the click is in the scrollbar, may scroll up/down.
3061+
popup_handle_scrollbar_click(wp, row, col);
30593062
# ifdef FEAT_CLIPBOARD
30603063
return IN_OTHER_WIN;
30613064
# else
@@ -3517,7 +3520,7 @@ mouse_find_win(int *rowp, int *colp, mouse_find_T popup UNUSED)
35173520
{
35183521
if (*rowp >= wp->w_winrow && *rowp < wp->w_winrow + popup_height(wp)
35193522
&& *colp >= wp->w_wincol
3520-
&& *colp < wp->w_wincol + popup_width(wp))
3523+
&& *colp < wp->w_wincol + popup_width(wp))
35213524
pwp = wp;
35223525
}
35233526
if (pwp != NULL)

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+
1607,
780782
/**/
781783
1606,
782784
/**/

0 commit comments

Comments
 (0)