comparison src/popupwin.c @ 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 38324d4f1c94
children fabd80ec9620
comparison
equal deleted inserted replaced
22953:504f63302ca4 22954:7b0aa7e2274f
3690 int border_char[8]; 3690 int border_char[8];
3691 char_u buf[MB_MAXBYTES]; 3691 char_u buf[MB_MAXBYTES];
3692 int row; 3692 int row;
3693 int wincol; 3693 int wincol;
3694 int padcol = 0; 3694 int padcol = 0;
3695 int padwidth = 0; 3695 int padendcol = 0;
3696 int i; 3696 int i;
3697 int sb_thumb_top = 0; 3697 int sb_thumb_top = 0;
3698 int sb_thumb_height = 0; 3698 int sb_thumb_height = 0;
3699 int attr_scroll = 0; 3699 int attr_scroll = 0;
3700 int attr_thumb = 0; 3700 int attr_thumb = 0;
3703 // so that the window with a higher zindex is drawn later, thus goes on 3703 // so that the window with a higher zindex is drawn later, thus goes on
3704 // top. 3704 // top.
3705 popup_reset_handled(POPUP_HANDLED_5); 3705 popup_reset_handled(POPUP_HANDLED_5);
3706 while ((wp = find_next_popup(TRUE, POPUP_HANDLED_5)) != NULL) 3706 while ((wp = find_next_popup(TRUE, POPUP_HANDLED_5)) != NULL)
3707 { 3707 {
3708 int title_len = 0;
3709 int title_wincol;
3710
3708 // This drawing uses the zindex of the popup window, so that it's on 3711 // This drawing uses the zindex of the popup window, so that it's on
3709 // top of the text but doesn't draw when another popup with higher 3712 // top of the text but doesn't draw when another popup with higher
3710 // zindex is on top of the character. 3713 // zindex is on top of the character.
3711 screen_zindex = wp->w_zindex; 3714 screen_zindex = wp->w_zindex;
3712 3715
3796 border_attr[i] = popup_attr; 3799 border_attr[i] = popup_attr;
3797 if (wp->w_border_highlight[i] != NULL) 3800 if (wp->w_border_highlight[i] != NULL)
3798 border_attr[i] = syn_name2attr(wp->w_border_highlight[i]); 3801 border_attr[i] = syn_name2attr(wp->w_border_highlight[i]);
3799 } 3802 }
3800 3803
3804 // Title goes on top of border or padding.
3805 title_wincol = wp->w_wincol + 1;
3806 if (wp->w_popup_title != NULL)
3807 {
3808 char_u *title_text;
3809
3810 title_len = (int)STRLEN(wp->w_popup_title);
3811 title_text = alloc(title_len + 1);
3812 trunc_string(wp->w_popup_title, title_text,
3813 total_width - 2, title_len + 1);
3814 screen_puts(title_text, wp->w_winrow, title_wincol,
3815 wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
3816 vim_free(title_text);
3817 if (title_len > total_width - 2)
3818 title_len = total_width - 2;
3819 }
3820
3801 wincol = wp->w_wincol - wp->w_popup_leftoff; 3821 wincol = wp->w_wincol - wp->w_popup_leftoff;
3802 top_padding = wp->w_popup_padding[0]; 3822 top_padding = wp->w_popup_padding[0];
3803 if (wp->w_popup_border[0] > 0) 3823 if (wp->w_popup_border[0] > 0)
3804 { 3824 {
3805 // top border 3825 // top border; do not draw over the title
3806 screen_fill(wp->w_winrow, wp->w_winrow + 1, 3826 if (title_len > 0)
3807 wincol < 0 ? 0 : wincol, wincol + total_width, 3827 {
3808 wp->w_popup_border[3] != 0 && wp->w_popup_leftoff == 0 3828 screen_fill(wp->w_winrow, wp->w_winrow + 1,
3829 wincol < 0 ? 0 : wincol, title_wincol,
3830 wp->w_popup_border[3] != 0 && wp->w_popup_leftoff == 0
3809 ? border_char[4] : border_char[0], 3831 ? border_char[4] : border_char[0],
3810 border_char[0], border_attr[0]); 3832 border_char[0], border_attr[0]);
3833 screen_fill(wp->w_winrow, wp->w_winrow + 1,
3834 title_wincol + title_len, wincol + total_width,
3835 border_char[0], border_char[0], border_attr[0]);
3836 }
3837 else
3838 {
3839 screen_fill(wp->w_winrow, wp->w_winrow + 1,
3840 wincol < 0 ? 0 : wincol, wincol + total_width,
3841 wp->w_popup_border[3] != 0 && wp->w_popup_leftoff == 0
3842 ? border_char[4] : border_char[0],
3843 border_char[0], border_attr[0]);
3844 }
3811 if (wp->w_popup_border[1] > 0 && wp->w_popup_rightoff == 0) 3845 if (wp->w_popup_border[1] > 0 && wp->w_popup_rightoff == 0)
3812 { 3846 {
3813 buf[mb_char2bytes(border_char[5], buf)] = NUL; 3847 buf[mb_char2bytes(border_char[5], buf)] = NUL;
3814 screen_puts(buf, wp->w_winrow, 3848 screen_puts(buf, wp->w_winrow,
3815 wincol + total_width - 1, border_attr[1]); 3849 wincol + total_width - 1, border_attr[1]);
3819 top_padding = 1; 3853 top_padding = 1;
3820 3854
3821 if (top_padding > 0 || wp->w_popup_padding[2] > 0) 3855 if (top_padding > 0 || wp->w_popup_padding[2] > 0)
3822 { 3856 {
3823 padcol = wincol + wp->w_popup_border[3]; 3857 padcol = wincol + wp->w_popup_border[3];
3824 padwidth = wp->w_wincol + total_width - wp->w_popup_border[1] 3858 padendcol = wp->w_wincol + total_width - wp->w_popup_border[1]
3825 - wp->w_has_scrollbar; 3859 - wp->w_has_scrollbar;
3826 if (padcol < 0) 3860 if (padcol < 0)
3827 { 3861 {
3828 padwidth += padcol; 3862 padendcol += padcol;
3829 padcol = 0; 3863 padcol = 0;
3830 } 3864 }
3831 } 3865 }
3832 if (top_padding > 0) 3866 if (top_padding > 0)
3833 { 3867 {
3834 // top padding 3868 // top padding; do not draw over the title
3835 row = wp->w_winrow + wp->w_popup_border[0]; 3869 row = wp->w_winrow + wp->w_popup_border[0];
3836 screen_fill(row, row + top_padding, padcol, padwidth, 3870 if (title_len > 0)
3871 {
3872 screen_fill(row, row + top_padding, padcol, title_wincol,
3837 ' ', ' ', popup_attr); 3873 ' ', ' ', popup_attr);
3838 } 3874 screen_fill(row, row + top_padding, title_wincol + title_len,
3839 3875 padendcol, ' ', ' ', popup_attr);
3840 // Title goes on top of border or padding. 3876 }
3841 if (wp->w_popup_title != NULL) 3877 else
3842 { 3878 {
3843 int len = (int)STRLEN(wp->w_popup_title) + 1; 3879 screen_fill(row, row + top_padding, padcol, padendcol,
3844 char_u *title = alloc(len); 3880 ' ', ' ', popup_attr);
3845 3881 }
3846 trunc_string(wp->w_popup_title, title, total_width - 2, len);
3847 screen_puts(title, wp->w_winrow, wp->w_wincol + 1,
3848 wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
3849 vim_free(title);
3850 } 3882 }
3851 3883
3852 // Compute scrollbar thumb position and size. 3884 // Compute scrollbar thumb position and size.
3853 if (wp->w_has_scrollbar) 3885 if (wp->w_has_scrollbar)
3854 { 3886 {
3946 { 3978 {
3947 // bottom padding 3979 // bottom padding
3948 row = wp->w_winrow + wp->w_popup_border[0] 3980 row = wp->w_winrow + wp->w_popup_border[0]
3949 + wp->w_popup_padding[0] + wp->w_height; 3981 + wp->w_popup_padding[0] + wp->w_height;
3950 screen_fill(row, row + wp->w_popup_padding[2], 3982 screen_fill(row, row + wp->w_popup_padding[2],
3951 padcol, padwidth, ' ', ' ', popup_attr); 3983 padcol, padendcol, ' ', ' ', popup_attr);
3952 } 3984 }
3953 3985
3954 if (wp->w_popup_border[2] > 0) 3986 if (wp->w_popup_border[2] > 0)
3955 { 3987 {
3956 // bottom border 3988 // bottom border