diff src/popupwin.c @ 17241:3ada3d207b33 v8.1.1620

patch 8.1.1620: no test for popup window with border and mask commit https://github.com/vim/vim/commit/ba45f1f4fbff1a78ed5786c2608b0f8a76ec53c8 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 3 22:50:41 2019 +0200 patch 8.1.1620: no test for popup window with border and mask Problem: No test for popup window with border and mask. Solution: Add this popup window, fix problems.
author Bram Moolenaar <Bram@vim.org>
date Wed, 03 Jul 2019 23:00:09 +0200
parents 2a97167854fc
children 13a2d3364b3f
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2337,6 +2337,7 @@ update_popups(void (*win_update)(win_T *
     int	    border_char[8];
     char_u  buf[MB_MAXBYTES];
     int	    row;
+    int	    wincol;
     int	    padcol = 0;
     int	    padwidth = 0;
     int	    i;
@@ -2409,21 +2410,21 @@ update_popups(void (*win_update)(win_T *
 		border_attr[i] = syn_name2attr(wp->w_border_highlight[i]);
 	}
 
+	wincol = wp->w_wincol - wp->w_popup_leftoff;
 	top_padding = wp->w_popup_padding[0];
 	if (wp->w_popup_border[0] > 0)
 	{
 	    // top border
 	    screen_fill(wp->w_winrow, wp->w_winrow + 1,
-		    wp->w_wincol,
-		    wp->w_wincol + total_width,
-		    wp->w_popup_border[3] != 0
+		    wincol < 0 ? 0 : wincol, wincol + total_width,
+		    wp->w_popup_border[3] != 0 && wp->w_popup_leftoff == 0
 					     ? border_char[4] : border_char[0],
 		    border_char[0], border_attr[0]);
-	    if (wp->w_popup_border[1] > 0)
+	    if (wp->w_popup_border[1] > 0 && wp->w_popup_rightoff == 0)
 	    {
 		buf[mb_char2bytes(border_char[5], buf)] = NUL;
 		screen_puts(buf, wp->w_winrow,
-			       wp->w_wincol + total_width - 1, border_attr[1]);
+			       wincol + total_width - 1, border_attr[1]);
 	    }
 	}
 	else if (wp->w_popup_padding[0] == 0 && popup_top_extra(wp) > 0)
@@ -2431,7 +2432,7 @@ update_popups(void (*win_update)(win_T *
 
 	if (top_padding > 0 || wp->w_popup_padding[2] > 0)
 	{
-	    padcol = wp->w_wincol - wp->w_popup_leftoff + wp->w_popup_border[3];
+	    padcol = wincol + wp->w_popup_border[3];
 	    padwidth = wp->w_wincol + total_width - wp->w_popup_border[1]
 							 - wp->w_has_scrollbar;
 	    if (padcol < 0)
@@ -2479,7 +2480,6 @@ update_popups(void (*win_update)(win_T *
 				 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]
@@ -2489,15 +2489,16 @@ update_popups(void (*win_update)(win_T *
 	    row = wp->w_winrow + i;
 
 	    // left border
-	    if (wp->w_popup_border[3] > 0 && col >= 0)
+	    if (wp->w_popup_border[3] > 0 && wincol >= 0)
 	    {
 		buf[mb_char2bytes(border_char[3], buf)] = NUL;
-		screen_puts(buf, row, col, border_attr[3]);
+		screen_puts(buf, row, wincol, border_attr[3]);
 	    }
 	    if (do_padding && wp->w_popup_padding[3] > 0)
 	    {
+		int col = wincol + wp->w_popup_border[3];
+
 		// left padding
-		col += wp->w_popup_border[3];
 		pad_left = wp->w_popup_padding[3];
 		if (col < 0)
 		{
@@ -2526,14 +2527,12 @@ update_popups(void (*win_update)(win_T *
 	    if (wp->w_popup_border[1] > 0)
 	    {
 		buf[mb_char2bytes(border_char[1], buf)] = NUL;
-		screen_puts(buf, row,
-			       wp->w_wincol + total_width - 1, border_attr[1]);
+		screen_puts(buf, row, wincol + total_width - 1, border_attr[1]);
 	    }
 	    // right padding
 	    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_leftoff
-			+ wp->w_popup_border[3]
+			wincol + wp->w_popup_border[3]
 			+ wp->w_popup_padding[3] + wp->w_width + wp->w_leftcol,
 			popup_attr);
 	}
@@ -2552,16 +2551,15 @@ update_popups(void (*win_update)(win_T *
 	    // bottom border
 	    row = wp->w_winrow + total_height - 1;
 	    screen_fill(row , row + 1,
-		    wp->w_wincol,
-		    wp->w_wincol + total_width,
-		    wp->w_popup_border[3] != 0
+		    wincol < 0 ? 0 : wincol,
+		    wincol + total_width,
+		    wp->w_popup_border[3] != 0 && wp->w_popup_leftoff == 0
 					     ? border_char[7] : border_char[2],
 		    border_char[2], border_attr[2]);
 	    if (wp->w_popup_border[1] > 0)
 	    {
 		buf[mb_char2bytes(border_char[6], buf)] = NUL;
-		screen_puts(buf, row,
-			       wp->w_wincol + total_width - 1, border_attr[2]);
+		screen_puts(buf, row, wincol + total_width - 1, border_attr[2]);
 	    }
 	}
 
@@ -2569,7 +2567,7 @@ update_popups(void (*win_update)(win_T *
 	{
 	    // close button goes on top of anything at the top-right corner
 	    buf[mb_char2bytes('X', buf)] = NUL;
-	    screen_puts(buf, wp->w_winrow, wp->w_wincol + total_width - 1,
+	    screen_puts(buf, wp->w_winrow, wincol + total_width - 1,
 		      wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
 	}