changeset 17235:2a97167854fc v8.1.1617

patch 8.1.1617: no test for popup window with mask and position fixed commit https://github.com/vim/vim/commit/d529ba58dc7566833546e4beb5c4c50d8b78816a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 2 23:13:53 2019 +0200 patch 8.1.1617: no test for popup window with mask and position fixed Problem: No test for popup window with mask and position fixed. Solution: Add a couple of screenshots. Fix deteced problems.
author Bram Moolenaar <Bram@vim.org>
date Tue, 02 Jul 2019 23:15:06 +0200
parents 7f61c9065eea
children e5656ac2c5e2
files src/popupwin.c src/structs.h src/testdir/dumps/Test_popupwin_mask_1.dump src/testdir/dumps/Test_popupwin_mask_2.dump src/testdir/dumps/Test_popupwin_mask_3.dump src/testdir/dumps/Test_popupwin_mask_4.dump src/testdir/test_popupwin.vim src/version.c
diffstat 8 files changed, 156 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -700,29 +700,6 @@ add_popup_dicts(buf_T *buf, list_T *l)
 }
 
 /*
- * Return the height of popup window "wp", including border and padding.
- */
-    int
-popup_height(win_T *wp)
-{
-    return wp->w_height
-	+ wp->w_popup_padding[0] + wp->w_popup_border[0]
-	+ wp->w_popup_padding[2] + wp->w_popup_border[2];
-}
-
-/*
- * Return the width of popup window "wp", including border and padding.
- */
-    int
-popup_width(win_T *wp)
-{
-    return wp->w_width
-	+ wp->w_popup_padding[3] + wp->w_popup_border[3]
-	+ wp->w_popup_padding[1] + wp->w_popup_border[1]
-	+ wp->w_has_scrollbar;
-}
-
-/*
  * Get the padding plus border at the top, adjusted to 1 if there is a title.
  */
     static int
@@ -736,6 +713,31 @@ popup_top_extra(win_T *wp)
 }
 
 /*
+ * Return the height of popup window "wp", including border and padding.
+ */
+    int
+popup_height(win_T *wp)
+{
+    return wp->w_height
+	+ popup_top_extra(wp)
+	+ wp->w_popup_padding[2] + wp->w_popup_border[2];
+}
+
+/*
+ * Return the width of popup window "wp", including border, padding and
+ * scrollbar.
+ */
+    int
+popup_width(win_T *wp)
+{
+    return wp->w_width + wp->w_leftcol
+	+ wp->w_popup_padding[3] + wp->w_popup_border[3]
+	+ wp->w_popup_padding[1] + wp->w_popup_border[1]
+	+ wp->w_has_scrollbar
+	+ wp->w_popup_rightoff;
+}
+
+/*
  * Adjust the position and size of the popup to fit on the screen.
  */
     void
@@ -744,6 +746,7 @@ popup_adjust_position(win_T *wp)
     linenr_T	lnum;
     int		wrapped = 0;
     int		maxwidth;
+    int		maxspace;
     int		center_vert = FALSE;
     int		center_hor = FALSE;
     int		allow_adjust_left = !wp->w_popup_fixed;
@@ -758,11 +761,14 @@ popup_adjust_position(win_T *wp)
     int		org_width = wp->w_width;
     int		org_height = wp->w_height;
     int		org_leftcol = wp->w_leftcol;
+    int		org_leftoff = wp->w_popup_leftoff;
     int		minwidth;
 
     wp->w_winrow = 0;
     wp->w_wincol = 0;
     wp->w_leftcol = 0;
+    wp->w_popup_leftoff = 0;
+    wp->w_popup_rightoff = 0;
     if (wp->w_popup_pos == POPPOS_CENTER)
     {
 	// center after computing the size
@@ -795,7 +801,8 @@ popup_adjust_position(win_T *wp)
     // When centering or right aligned, use maximum width.
     // When left aligned use the space available, but shift to the left when we
     // hit the right of the screen.
-    maxwidth = Columns - wp->w_wincol - left_extra;
+    maxspace = Columns - wp->w_wincol - left_extra;
+    maxwidth = maxspace;
     if (wp->w_maxwidth > 0 && maxwidth > wp->w_maxwidth)
     {
 	allow_adjust_left = FALSE;
@@ -868,7 +875,12 @@ popup_adjust_position(win_T *wp)
     if (minwidth > 0 && wp->w_width < minwidth)
 	wp->w_width = minwidth;
     if (wp->w_width > maxwidth)
+    {
+	if (wp->w_width > maxspace)
+	    // some columns cut off on the right
+	    wp->w_popup_rightoff = wp->w_width - maxspace;
 	wp->w_width = maxwidth;
+    }
     if (center_hor)
     {
 	wp->w_wincol = (Columns - wp->w_width - extra_width) / 2;
@@ -887,9 +899,12 @@ popup_adjust_position(win_T *wp)
 	else if (wp->w_popup_fixed)
 	{
 	    // "col" specifies the right edge, but popup doesn't fit, skip some
-	    // columns when displaying the window.
-	    wp->w_leftcol = -leftoff;
-	    wp->w_width += leftoff;
+	    // columns when displaying the window, minus left border and
+	    // padding.
+	    if (-leftoff > left_extra)
+		wp->w_leftcol = -leftoff - left_extra;
+	    wp->w_width -= wp->w_leftcol;
+	    wp->w_popup_leftoff = -leftoff;
 	    if (wp->w_width < 0)
 		wp->w_width = 0;
 	}
@@ -928,6 +943,7 @@ popup_adjust_position(win_T *wp)
     if (org_winrow != wp->w_winrow
 	    || org_wincol != wp->w_wincol
 	    || org_leftcol != wp->w_leftcol
+	    || org_leftoff != wp->w_popup_leftoff
 	    || org_width != wp->w_width
 	    || org_height != wp->w_height)
     {
@@ -2066,7 +2082,7 @@ popup_check_cursor_pos()
     static int
 popup_masked(win_T *wp, int screencol, int screenline)
 {
-    int		col = screencol - wp->w_wincol + 1 + wp->w_leftcol;
+    int		col = screencol - wp->w_wincol + 1 + wp->w_popup_leftoff;
     int		line = screenline - wp->w_winrow + 1;
     listitem_T	*lio, *li;
     int		width, height;
@@ -2145,10 +2161,10 @@ update_popup_transparent(win_T *wp, int 
 		linee = height + linee + 1;
 
 	    --cols;
-	    cols -= wp->w_leftcol;
+	    cols -= wp->w_popup_leftoff;
 	    if (cols < 0)
 		cols = 0;
-	    cole -= wp->w_leftcol;
+	    cole -= wp->w_popup_leftoff;
 	    --lines;
 	    if (lines < 0)
 		lines = 0;
@@ -2215,8 +2231,8 @@ may_update_popup_mask(int type)
     popup_reset_handled();
     while ((wp = find_next_popup(TRUE)) != NULL)
     {
-	int height = popup_height(wp);
-	int width = popup_width(wp);
+	int height;
+	int width;
 
 	popup_visible = TRUE;
 
@@ -2225,6 +2241,8 @@ may_update_popup_mask(int type)
 		|| wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer))
 	    popup_adjust_position(wp);
 
+	height = popup_height(wp);
+	width = popup_width(wp) - wp->w_popup_leftoff;
 	for (line = wp->w_winrow;
 		line < wp->w_winrow + height && line < screen_Rows; ++line)
 	    for (col = wp->w_wincol;
@@ -2310,7 +2328,7 @@ update_popups(void (*win_update)(win_T *
 {
     win_T   *wp;
     int	    top_off;
-    int	    left_off;
+    int	    left_extra;
     int	    total_width;
     int	    total_height;
     int	    top_padding;
@@ -2319,6 +2337,8 @@ update_popups(void (*win_update)(win_T *
     int	    border_char[8];
     char_u  buf[MB_MAXBYTES];
     int	    row;
+    int	    padcol = 0;
+    int	    padwidth = 0;
     int	    i;
     int	    sb_thumb_top = 0;
     int	    sb_thumb_height = 0;
@@ -2342,22 +2362,22 @@ update_popups(void (*win_update)(win_T *
 	// adjust w_winrow and w_wincol for border and padding, since
 	// win_update() doesn't handle them.
 	top_off = popup_top_extra(wp);
-	left_off = wp->w_popup_padding[3] + wp->w_popup_border[3];
+	left_extra = wp->w_popup_padding[3] + wp->w_popup_border[3]
+							 - wp->w_popup_leftoff;
+	if (wp->w_wincol + left_extra < 0)
+	    left_extra = -wp->w_wincol;
 	wp->w_winrow += top_off;
-	wp->w_wincol += left_off;
+	wp->w_wincol += left_extra;
 
 	// Draw the popup text, unless it's off screen.
 	if (wp->w_winrow < screen_Rows && wp->w_wincol < screen_Columns)
 	    win_update(wp);
 
 	wp->w_winrow -= top_off;
-	wp->w_wincol -= left_off;
+	wp->w_wincol -= left_extra;
 
-	total_width = wp->w_popup_border[3] + wp->w_popup_padding[3]
-		+ wp->w_width + wp->w_popup_padding[1] + wp->w_popup_border[1]
-		+ wp->w_has_scrollbar;
-	total_height = popup_top_extra(wp)
-		+ wp->w_height + wp->w_popup_padding[2] + wp->w_popup_border[2];
+	total_width = popup_width(wp);
+	total_height = popup_height(wp);
 	popup_attr = get_wcr_attr(wp);
 
 	// We can only use these line drawing characters when 'encoding' is
@@ -2409,14 +2429,22 @@ update_popups(void (*win_update)(win_T *
 	else if (wp->w_popup_padding[0] == 0 && popup_top_extra(wp) > 0)
 	    top_padding = 1;
 
+	if (top_padding > 0 || wp->w_popup_padding[2] > 0)
+	{
+	    padcol = wp->w_wincol - wp->w_popup_leftoff + wp->w_popup_border[3];
+	    padwidth = wp->w_wincol + total_width - wp->w_popup_border[1]
+							 - wp->w_has_scrollbar;
+	    if (padcol < 0)
+	    {
+		padwidth += padcol;
+		padcol = 0;
+	    }
+	}
 	if (top_padding > 0)
 	{
 	    // top padding
 	    row = wp->w_winrow + wp->w_popup_border[0];
-	    screen_fill(row, row + top_padding,
-		    wp->w_wincol + wp->w_popup_border[3],
-		    wp->w_wincol + total_width - wp->w_popup_border[1]
-							- wp->w_has_scrollbar,
+	    screen_fill(row, row + top_padding, padcol, padwidth,
 							 ' ', ' ', popup_attr);
 	}
 
@@ -2450,18 +2478,35 @@ update_popups(void (*win_update)(win_T *
 	for (i = wp->w_popup_border[0];
 				 i < total_height - wp->w_popup_border[2]; ++i)
 	{
+	    int	pad_left;
+	    int col = wp->w_wincol - wp->w_popup_leftoff;
+	    // left and right padding only needed next to the body
+	    int do_padding =
+		    i >= wp->w_popup_border[0] + wp->w_popup_padding[0]
+		    && i < total_height - wp->w_popup_border[2]
+						 - wp->w_popup_padding[2];
+
 	    row = wp->w_winrow + i;
 
 	    // left border
-	    if (wp->w_popup_border[3] > 0)
+	    if (wp->w_popup_border[3] > 0 && col >= 0)
 	    {
 		buf[mb_char2bytes(border_char[3], buf)] = NUL;
-		screen_puts(buf, row, wp->w_wincol, border_attr[3]);
+		screen_puts(buf, row, col, border_attr[3]);
 	    }
-	    // left padding
-	    if (wp->w_popup_padding[3] > 0)
-		screen_puts(get_spaces(wp->w_popup_padding[3]), row,
-			wp->w_wincol + wp->w_popup_border[3], popup_attr);
+	    if (do_padding && wp->w_popup_padding[3] > 0)
+	    {
+		// left padding
+		col += wp->w_popup_border[3];
+		pad_left = wp->w_popup_padding[3];
+		if (col < 0)
+		{
+		    pad_left += col;
+		    col = 0;
+		}
+		if (pad_left > 0)
+		    screen_puts(get_spaces(pad_left), row, col, popup_attr);
+	    }
 	    // scrollbar
 	    if (wp->w_has_scrollbar)
 	    {
@@ -2485,10 +2530,12 @@ update_popups(void (*win_update)(win_T *
 			       wp->w_wincol + total_width - 1, border_attr[1]);
 	    }
 	    // right padding
-	    if (wp->w_popup_padding[1] > 0)
+	    if (do_padding && wp->w_popup_padding[1] > 0)
 		screen_puts(get_spaces(wp->w_popup_padding[1]), row,
-			wp->w_wincol + wp->w_popup_border[3]
-			   + wp->w_popup_padding[3] + wp->w_width, popup_attr);
+			wp->w_wincol - wp->w_popup_leftoff
+			+ wp->w_popup_border[3]
+			+ wp->w_popup_padding[3] + wp->w_width + wp->w_leftcol,
+			popup_attr);
 	}
 
 	if (wp->w_popup_padding[2] > 0)
@@ -2497,9 +2544,7 @@ update_popups(void (*win_update)(win_T *
 	    row = wp->w_winrow + wp->w_popup_border[0]
 				       + wp->w_popup_padding[0] + wp->w_height;
 	    screen_fill(row, row + wp->w_popup_padding[2],
-		    wp->w_wincol + wp->w_popup_border[3],
-		    wp->w_wincol + total_width - wp->w_popup_border[1],
-							 ' ', ' ', popup_attr);
+				       padcol, padwidth, ' ', ' ', popup_attr);
 	}
 
 	if (wp->w_popup_border[2] > 0)
--- a/src/structs.h
+++ b/src/structs.h
@@ -2916,6 +2916,9 @@ struct window_S
     int		w_popup_border[4];  // popup border top/right/bot/left
     char_u	*w_border_highlight[4];  // popup border highlight
     int		w_border_char[8];   // popup border characters
+
+    int		w_popup_leftoff;    // columns left of the screen
+    int		w_popup_rightoff;   // columns right of the screen
     varnumber_T	w_popup_last_changedtick; // b:changedtick when position was
 					  // computed
     callback_T	w_close_cb;	    // popup close callback
@@ -2927,8 +2930,8 @@ struct window_S
     colnr_T	w_popup_maxcol;	    // close popup if cursor after this col
     int		w_popup_drag;	    // allow moving the popup with the mouse
     popclose_T	w_popup_close;	    // allow closing the popup with the mouse
+
     list_T	*w_popup_mask;	    // list of lists for "mask"
-
 # if defined(FEAT_TIMERS)
     timer_T	*w_popup_timer;	    // timer for closing popup window
 # endif
--- a/src/testdir/dumps/Test_popupwin_mask_1.dump
+++ b/src/testdir/dumps/Test_popupwin_mask_1.dump
@@ -1,10 +1,10 @@
->1+0&#ffffff0|2|3|4|5|6|7|8|9|1|0|1@2|2|1|3|1|4|1|5|1|6|1|7|1|8|1|9|2|0|2|1|2@2|3|2|4|2|5|2|6|2|7|2|8|2|9|3|0|3|1|3|2|3@2|4|3|5|3|6|3|7|3|8|3|9|4|0| @3
-|1|2|3|4|5|6|7|8|9|1| +0&#e0e0e08@12|1+0&#ffffff0|7|1|8|1|9|2|0|2|1|2@2|3|2|4|2|5|2|6|2|7|2|8|2|9|3|0|3|1|3|2|3@2|4|3|5|3|6|3|7|3|8|3|9|4|0| @3
-|1|2|3|4|5|6|7|8|9| +0&#e0e0e08|s|o|m|e| |1+0&#ffffff0|3|x+0#0000001#ffd7ff255|t+0#0000000#e0e0e08| @3|x+0#0000001#ffd7ff255@2|8+0#0000000#ffffff0|1|9|2|0|2|1|2@2|3|2|4|2|5|2|6|2|7|2|8|2|9|3|0|3|1|3|2|3@2|4|3|5|3|6|3|7|3|8|3|9|4|0| @3
-|1|2|3|4|5|6|7|8|9| +0&#e0e0e08|0+0&#ffffff0|1@1|t+0&#e0e0e08|h|1+0&#ffffff0|3|y+0#0000001#ffd7ff255|l+0#0000000#e0e0e08|i|n|e| |y+0#0000001#ffd7ff255@2|8+0#0000000#ffffff0|1|9|2|0|2|1|2@2|3|2|4|2|5|2|6|2|7|2|8|2|9|3|0|3|1|3|2|3@2|4|3|5|3|6|3|7|3|8|3|9|4|0| @3
-|1|2|3|4|5|6|7|8|9| +0&#e0e0e08@8|4+0&#ffffff0|1|5|1|6|1|7|1|8|1|9|2|0|2|1|2@2|3|2|4|2|5|2|6|2|7|2|8|2|9|3|0|3|1|3|2|3@2|4|3|5|3|6|3|7|3|8|3|9|4|0| @3
-|1|2|3|4|5|6|7|8|9|1|0|1@2|2|1|3|1|4|1|5|1|6|1|7|1|8|1|9|2|0|2|1|2@2|3|2|4|2|5|2|6|2|7|2|8|2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p|o|p|u|p|_|m|o|v|e|(|w|i|n|i|d|,| |{|'|p|o|s|'|:| |'|t|o|p|r|i|g|h|t|'|,| |'|c|o|l|'|:| |1|2|,| |'|l|1|,|1| @10|T|o|p| 
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -427,7 +427,7 @@ func Test_popup_with_mask()
     throw 'Skipped: cannot make screendumps'
   endif
   let lines =<< trim END
-	call setline(1, repeat([join(range(1, 40), '')], 10))
+	call setline(1, repeat([join(range(1, 42), '')], 10))
 	hi PopupColor ctermbg=lightgrey
 	let winid = popup_create([
 	    \ 'some text',
@@ -435,6 +435,8 @@ func Test_popup_with_mask()
 	    \], {
 	    \ 'line': 2,
 	    \ 'col': 10,
+	    \ 'wrap': 0,
+	    \ 'fixed': 1,
 	    \ 'zindex': 90,
 	    \ 'padding': [],
 	    \ 'highlight': 'PopupColor',
@@ -454,6 +456,12 @@ func Test_popup_with_mask()
   call term_sendkeys(buf, ":call popup_move(winid, {'col': 11, 'line': 3})\<CR>")
   call VerifyScreenDump(buf, 'Test_popupwin_mask_2', {})
 
+  call term_sendkeys(buf, ":call popup_move(winid, {'col': 65, 'line': 3})\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_mask_3', {})
+
+  call term_sendkeys(buf, ":call popup_move(winid, {'pos': 'topright', 'col': 12, 'line': 3})\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_mask_4', {})
+
   " clean up
   call StopVimInTerminal(buf)
   call delete('XtestPopupMask')
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1617,
+/**/
     1616,
 /**/
     1615,