changeset 22954:7b0aa7e2274f v8.2.2024

patch 8.2.2024: flicker when redrawing a popup with a title and border Commit: https://github.com/vim/vim/commit/d91467f830236ae35eb4108d329a1e26a3f1ebc6 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 21 12:42:09 2020 +0100 patch 8.2.2024: flicker when redrawing a popup with a title and border Problem: Flicker when redrawing a popup with a title and border. Solution: Do not redraw the border where the title is displayed. (Naruhiko Nishino, closes #7334)
author Bram Moolenaar <Bram@vim.org>
date Sat, 21 Nov 2020 12:45:03 +0100
parents 504f63302ca4
children 4cb724978552
files src/popupwin.c src/version.c
diffstat 2 files changed, 57 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -3692,7 +3692,7 @@ update_popups(void (*win_update)(win_T *
     int	    row;
     int	    wincol;
     int	    padcol = 0;
-    int	    padwidth = 0;
+    int	    padendcol = 0;
     int	    i;
     int	    sb_thumb_top = 0;
     int	    sb_thumb_height = 0;
@@ -3705,6 +3705,9 @@ update_popups(void (*win_update)(win_T *
     popup_reset_handled(POPUP_HANDLED_5);
     while ((wp = find_next_popup(TRUE, POPUP_HANDLED_5)) != NULL)
     {
+	int	    title_len = 0;
+	int	    title_wincol;
+
 	// This drawing uses the zindex of the popup window, so that it's on
 	// top of the text but doesn't draw when another popup with higher
 	// zindex is on top of the character.
@@ -3798,16 +3801,47 @@ update_popups(void (*win_update)(win_T *
 		border_attr[i] = syn_name2attr(wp->w_border_highlight[i]);
 	}
 
+	// Title goes on top of border or padding.
+	title_wincol = wp->w_wincol + 1;
+	if (wp->w_popup_title != NULL)
+	{
+	    char_u  *title_text;
+
+	    title_len = (int)STRLEN(wp->w_popup_title);
+	    title_text = alloc(title_len + 1);
+	    trunc_string(wp->w_popup_title, title_text,
+					       total_width - 2, title_len + 1);
+	    screen_puts(title_text, wp->w_winrow, title_wincol,
+		      wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
+	    vim_free(title_text);
+	    if (title_len > total_width - 2)
+		title_len = total_width - 2;
+	}
+
 	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,
-		    wincol < 0 ? 0 : wincol, wincol + total_width,
-		    wp->w_popup_border[3] != 0 && wp->w_popup_leftoff == 0
+	    // top border; do not draw over the title
+	    if (title_len > 0)
+	    {
+		screen_fill(wp->w_winrow, wp->w_winrow + 1,
+			wincol < 0 ? 0 : wincol, title_wincol,
+			wp->w_popup_border[3] != 0 && wp->w_popup_leftoff == 0
 					     ? border_char[4] : border_char[0],
-		    border_char[0], border_attr[0]);
+			border_char[0], border_attr[0]);
+		screen_fill(wp->w_winrow, wp->w_winrow + 1,
+			title_wincol + title_len, wincol + total_width,
+			border_char[0], border_char[0], border_attr[0]);
+	    }
+	    else
+	    {
+		screen_fill(wp->w_winrow, wp->w_winrow + 1,
+			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 && wp->w_popup_rightoff == 0)
 	    {
 		buf[mb_char2bytes(border_char[5], buf)] = NUL;
@@ -3821,32 +3855,30 @@ update_popups(void (*win_update)(win_T *
 	if (top_padding > 0 || wp->w_popup_padding[2] > 0)
 	{
 	    padcol = wincol + wp->w_popup_border[3];
-	    padwidth = wp->w_wincol + total_width - wp->w_popup_border[1]
+	    padendcol = wp->w_wincol + total_width - wp->w_popup_border[1]
 							 - wp->w_has_scrollbar;
 	    if (padcol < 0)
 	    {
-		padwidth += padcol;
+		padendcol += padcol;
 		padcol = 0;
 	    }
 	}
 	if (top_padding > 0)
 	{
-	    // top padding
+	    // top padding; do not draw over the title
 	    row = wp->w_winrow + wp->w_popup_border[0];
-	    screen_fill(row, row + top_padding, padcol, padwidth,
+	    if (title_len > 0)
+	    {
+		screen_fill(row, row + top_padding, padcol, title_wincol,
 							 ' ', ' ', popup_attr);
-	}
-
-	// Title goes on top of border or padding.
-	if (wp->w_popup_title != NULL)
-	{
-	    int	    len = (int)STRLEN(wp->w_popup_title) + 1;
-	    char_u  *title = alloc(len);
-
-	    trunc_string(wp->w_popup_title, title, total_width - 2, len);
-	    screen_puts(title, wp->w_winrow, wp->w_wincol + 1,
-		    wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
-	    vim_free(title);
+		screen_fill(row, row + top_padding, title_wincol + title_len,
+					      padendcol, ' ', ' ', popup_attr);
+	    }
+	    else
+	    {
+		screen_fill(row, row + top_padding, padcol, padendcol,
+							 ' ', ' ', popup_attr);
+	    }
 	}
 
 	// Compute scrollbar thumb position and size.
@@ -3948,7 +3980,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],
-				       padcol, padwidth, ' ', ' ', popup_attr);
+				       padcol, padendcol, ' ', ' ', popup_attr);
 	}
 
 	if (wp->w_popup_border[2] > 0)
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2024,
+/**/
     2023,
 /**/
     2022,