Patch 8.2.2024
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)
Files: src/popupwin.c
*** ../vim-8.2.2023/src/popupwin.c 2020-11-15 20:32:54.167882094 +0100
--- src/popupwin.c 2020-11-21 12:40:36.204008865 +0100
***************
*** 3692,3698 ****
int row;
int wincol;
int padcol = 0;
! int padwidth = 0;
int i;
int sb_thumb_top = 0;
int sb_thumb_height = 0;
--- 3692,3698 ----
int row;
int wincol;
int padcol = 0;
! int padendcol = 0;
int i;
int sb_thumb_top = 0;
int sb_thumb_height = 0;
***************
*** 3705,3710 ****
--- 3705,3713 ----
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,3813 ****
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,
! 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;
--- 3801,3847 ----
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; 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]);
! }
if (wp->w_popup_border[1] > 0 && wp->w_popup_rightoff == 0)
{
buf[mb_char2bytes(border_char[5], buf)] = NUL;
***************
*** 3821,3852 ****
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]
- 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, padcol, padwidth,
' ', ' ', 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);
}
// Compute scrollbar thumb position and size.
--- 3855,3884 ----
if (top_padding > 0 || wp->w_popup_padding[2] > 0)
{
padcol = wincol + wp->w_popup_border[3];
! padendcol = wp->w_wincol + total_width - wp->w_popup_border[1]
- wp->w_has_scrollbar;
if (padcol < 0)
{
! padendcol += padcol;
padcol = 0;
}
}
if (top_padding > 0)
{
! // top padding; do not draw over the title
row = wp->w_winrow + wp->w_popup_border[0];
! if (title_len > 0)
! {
! screen_fill(row, row + top_padding, padcol, title_wincol,
' ', ' ', popup_attr);
! 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,3954 ****
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);
}
if (wp->w_popup_border[2] > 0)
--- 3980,3986 ----
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, padendcol, ' ', ' ', popup_attr);
}
if (wp->w_popup_border[2] > 0)
*** ../vim-8.2.2023/src/version.c 2020-11-21 11:45:46.221834425 +0100
--- src/version.c 2020-11-21 12:17:02.863523160 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2024,
/**/
--
Facepalm statement #6: "Estland is a fantasy place, just like Middle Earth and
Madagaskar"
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202011211142.0ALBgXcU894084%40masaka.moolenaar.net.