]> granicus.if.org Git - vim/commitdiff
patch 8.2.2024: flicker when redrawing a popup with a title and border v8.2.2024
authorBram Moolenaar <Bram@vim.org>
Sat, 21 Nov 2020 11:42:09 +0000 (12:42 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 21 Nov 2020 11:42:09 +0000 (12:42 +0100)
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)

src/popupwin.c
src/version.c

index 90b107eb5c8c94227e06fd02390eba17e66d171f..61f447ded2818e7f79d881ba61b5eb39e3aa982a 100644 (file)
@@ -3692,7 +3692,7 @@ update_popups(void (*win_update)(win_T *wp))
     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 *wp))
     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 *wp))
                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]);
+               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]);
+                       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 *wp))
        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 *wp))
            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)
index 5996bd67fdade3c89af322ec440c64ae19ac69a3..ca29e34d217c1a1505f5fec050b90e80afb77aee 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2024,
 /**/
     2023,
 /**/