Skip to content

Commit cfce717

Browse files
committed
patch 8.0.0956: scrolling in a terminal window has flicker
Problem: Scrolling in a terminal hwindow as flicker when the Normal background differs from the terminal window background. Solution: Set the attribute to clear with.
1 parent 82de3c2 commit cfce717

6 files changed

Lines changed: 227 additions & 198 deletions

File tree

src/message.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@ msg_scroll_up(void)
23132313
gui_undraw_cursor();
23142314
#endif
23152315
/* scrolling up always works */
2316-
screen_del_lines(0, 0, 1, (int)Rows, TRUE, NULL);
2316+
screen_del_lines(0, 0, 1, (int)Rows, TRUE, 0, NULL);
23172317

23182318
if (!can_clear((char_u *)" "))
23192319
{
@@ -2905,7 +2905,7 @@ do_more_prompt(int typed_char)
29052905
}
29062906

29072907
if (toscroll == -1 && screen_ins_lines(0, 0, 1,
2908-
(int)Rows, NULL) == OK)
2908+
(int)Rows, 0, NULL) == OK)
29092909
{
29102910
/* display line at top */
29112911
(void)disp_sb_line(0, mp);

src/move.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ curs_columns(
11631163
if (extra > 0)
11641164
win_ins_lines(curwin, 0, extra, FALSE, FALSE);
11651165
else if (extra < 0)
1166-
win_del_lines(curwin, 0, -extra, FALSE, FALSE);
1166+
win_del_lines(curwin, 0, -extra, FALSE, FALSE, 0);
11671167
}
11681168
else
11691169
curwin->w_skipcol = 0;

src/proto/screen.pro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ void screen_start(void);
4545
void windgoto(int row, int col);
4646
void setcursor(void);
4747
int win_ins_lines(win_T *wp, int row, int line_count, int invalid, int mayclear);
48-
int win_del_lines(win_T *wp, int row, int line_count, int invalid, int mayclear);
49-
int screen_ins_lines(int off, int row, int line_count, int end, win_T *wp);
50-
int screen_del_lines(int off, int row, int line_count, int end, int force, win_T *wp);
48+
int win_del_lines(win_T *wp, int row, int line_count, int invalid, int mayclear, int clear_attr);
49+
int screen_ins_lines(int off, int row, int line_count, int end, int clear_attr, win_T *wp);
50+
int screen_del_lines(int off, int row, int line_count, int end, int force, int attr, win_T *wp);
5151
int showmode(void);
5252
void unshowmode(int force);
5353
void clearmode(void);

src/screen.c

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ static void screen_char(unsigned off, int row, int col);
151151
static void screen_char_2(unsigned off, int row, int col);
152152
#endif
153153
static void screenclear2(void);
154-
static void lineclear(unsigned off, int width);
154+
static void lineclear(unsigned off, int width, int attr);
155155
static void lineinvalid(unsigned off, int width);
156156
#ifdef FEAT_WINDOWS
157157
static void linecopy(int to, int from, win_T *wp);
158158
static void redraw_block(int row, int end, win_T *wp);
159159
#endif
160-
static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int del);
160+
static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int del, int clear_attr);
161161
static void win_rest_invalid(win_T *wp);
162162
static void msg_pos_mode(void);
163163
static void recording_mode(int attr);
@@ -609,7 +609,8 @@ update_screen(int type_arg)
609609
else if (type != CLEAR)
610610
{
611611
check_for_delay(FALSE);
612-
if (screen_ins_lines(0, 0, msg_scrolled, (int)Rows, NULL) == FAIL)
612+
if (screen_ins_lines(0, 0, msg_scrolled, (int)Rows, 0, NULL)
613+
== FAIL)
613614
type = CLEAR;
614615
FOR_ALL_WINDOWS(wp)
615616
{
@@ -1537,7 +1538,8 @@ win_update(win_T *wp)
15371538
if (row > 0)
15381539
{
15391540
check_for_delay(FALSE);
1540-
if (win_del_lines(wp, 0, row, FALSE, wp == firstwin) == OK)
1541+
if (win_del_lines(wp, 0, row, FALSE, wp == firstwin, 0)
1542+
== OK)
15411543
bot_start = wp->w_height - row;
15421544
else
15431545
mid_start = 0; /* redraw all lines */
@@ -2003,7 +2005,7 @@ win_update(win_T *wp)
20032005
{
20042006
check_for_delay(FALSE);
20052007
if (win_del_lines(wp, row,
2006-
-xtra_rows, FALSE, FALSE) == FAIL)
2008+
-xtra_rows, FALSE, FALSE, 0) == FAIL)
20072009
mod_bot = MAXLNUM;
20082010
else
20092011
bot_start = wp->w_height + xtra_rows;
@@ -6773,7 +6775,7 @@ win_redr_status_matches(
67736775
* no room, scroll the screen one line up. */
67746776
if (cmdline_row == Rows - 1)
67756777
{
6776-
screen_del_lines(0, 0, 1, (int)Rows, TRUE, NULL);
6778+
screen_del_lines(0, 0, 1, (int)Rows, TRUE, 0, NULL);
67776779
++msg_scrolled;
67786780
}
67796781
else
@@ -9074,7 +9076,7 @@ screenclear2(void)
90749076
/* blank out ScreenLines */
90759077
for (i = 0; i < Rows; ++i)
90769078
{
9077-
lineclear(LineOffset[i], (int)Columns);
9079+
lineclear(LineOffset[i], (int)Columns, 0);
90789080
LineWraps[i] = FALSE;
90799081
}
90809082

@@ -9114,15 +9116,15 @@ screenclear2(void)
91149116
* Clear one line in ScreenLines.
91159117
*/
91169118
static void
9117-
lineclear(unsigned off, int width)
9119+
lineclear(unsigned off, int width, int attr)
91189120
{
91199121
(void)vim_memset(ScreenLines + off, ' ', (size_t)width * sizeof(schar_T));
91209122
#ifdef FEAT_MBYTE
91219123
if (enc_utf8)
91229124
(void)vim_memset(ScreenLinesUC + off, 0,
91239125
(size_t)width * sizeof(u8char_T));
91249126
#endif
9125-
(void)vim_memset(ScreenAttrs + off, 0, (size_t)width * sizeof(sattr_T));
9127+
(void)vim_memset(ScreenAttrs + off, attr, (size_t)width * sizeof(sattr_T));
91269128
}
91279129

91289130
/*
@@ -9508,7 +9510,7 @@ win_ins_lines(
95089510
if (line_count > wp->w_height - row)
95099511
line_count = wp->w_height - row;
95109512

9511-
retval = win_do_lines(wp, row, line_count, mayclear, FALSE);
9513+
retval = win_do_lines(wp, row, line_count, mayclear, FALSE, 0);
95129514
if (retval != MAYBE)
95139515
return retval;
95149516

@@ -9523,7 +9525,7 @@ win_ins_lines(
95239525
if (wp->w_next != NULL || wp->w_status_height)
95249526
{
95259527
if (screen_del_lines(0, W_WINROW(wp) + wp->w_height - line_count,
9526-
line_count, (int)Rows, FALSE, NULL) == OK)
9528+
line_count, (int)Rows, FALSE, 0, NULL) == OK)
95279529
did_delete = TRUE;
95289530
else if (wp->w_next)
95299531
return FAIL;
@@ -9547,7 +9549,7 @@ win_ins_lines(
95479549
' ', ' ', 0);
95489550
}
95499551

9550-
if (screen_ins_lines(0, W_WINROW(wp) + row, line_count, (int)Rows, NULL)
9552+
if (screen_ins_lines(0, W_WINROW(wp) + row, line_count, (int)Rows, 0, NULL)
95519553
== FAIL)
95529554
{
95539555
/* deletion will have messed up other windows */
@@ -9577,7 +9579,8 @@ win_del_lines(
95779579
int row,
95789580
int line_count,
95799581
int invalid,
9580-
int mayclear)
9582+
int mayclear,
9583+
int clear_attr) /* for clearing lines */
95819584
{
95829585
int retval;
95839586

@@ -9587,12 +9590,12 @@ win_del_lines(
95879590
if (line_count > wp->w_height - row)
95889591
line_count = wp->w_height - row;
95899592

9590-
retval = win_do_lines(wp, row, line_count, mayclear, TRUE);
9593+
retval = win_do_lines(wp, row, line_count, mayclear, TRUE, clear_attr);
95919594
if (retval != MAYBE)
95929595
return retval;
95939596

95949597
if (screen_del_lines(0, W_WINROW(wp) + row, line_count,
9595-
(int)Rows, FALSE, NULL) == FAIL)
9598+
(int)Rows, FALSE, clear_attr, NULL) == FAIL)
95969599
return FAIL;
95979600

95989601
#ifdef FEAT_WINDOWS
@@ -9603,7 +9606,7 @@ win_del_lines(
96039606
if (wp->w_next || wp->w_status_height || cmdline_row < Rows - 1)
96049607
{
96059608
if (screen_ins_lines(0, W_WINROW(wp) + wp->w_height - line_count,
9606-
line_count, (int)Rows, NULL) == FAIL)
9609+
line_count, (int)Rows, clear_attr, NULL) == FAIL)
96079610
{
96089611
wp->w_redr_status = TRUE;
96099612
win_rest_invalid(wp->w_next);
@@ -9630,7 +9633,8 @@ win_do_lines(
96309633
int row,
96319634
int line_count,
96329635
int mayclear,
9633-
int del)
9636+
int del,
9637+
int clear_attr)
96349638
{
96359639
int retval;
96369640

@@ -9694,10 +9698,10 @@ win_do_lines(
96949698
scroll_region_set(wp, row);
96959699
if (del)
96969700
retval = screen_del_lines(W_WINROW(wp) + row, 0, line_count,
9697-
wp->w_height - row, FALSE, wp);
9701+
wp->w_height - row, FALSE, clear_attr, wp);
96989702
else
96999703
retval = screen_ins_lines(W_WINROW(wp) + row, 0, line_count,
9700-
wp->w_height - row, wp);
9704+
wp->w_height - row, clear_attr, wp);
97019705
#ifdef FEAT_WINDOWS
97029706
if (scroll_region && (wp->w_width == Columns || *T_CSV != NUL))
97039707
#endif
@@ -9771,6 +9775,7 @@ screen_ins_lines(
97719775
int row,
97729776
int line_count,
97739777
int end,
9778+
int clear_attr,
97749779
win_T *wp) /* NULL or window to use width from */
97759780
{
97769781
int i;
@@ -9851,15 +9856,15 @@ screen_ins_lines(
98519856
*/
98529857
if (type == USE_T_CD || type == USE_T_CDL ||
98539858
type == USE_T_CE || type == USE_T_DL)
9854-
return screen_del_lines(off, row, line_count, end, FALSE, wp);
9859+
return screen_del_lines(off, row, line_count, end, FALSE, 0, wp);
98559860

98569861
/*
98579862
* If text is retained below the screen, first clear or delete as many
98589863
* lines at the bottom of the window as are about to be inserted so that
98599864
* the deleted lines won't later surface during a screen_del_lines.
98609865
*/
98619866
if (*T_DB)
9862-
screen_del_lines(off, end - line_count, line_count, end, FALSE, wp);
9867+
screen_del_lines(off, end - line_count, line_count, end, FALSE, 0, wp);
98639868

98649869
#ifdef FEAT_CLIPBOARD
98659870
/* Remove a modeless selection when inserting lines halfway the screen
@@ -9902,7 +9907,8 @@ screen_ins_lines(
99029907
linecopy(j + line_count, j, wp);
99039908
j += line_count;
99049909
if (can_clear((char_u *)" "))
9905-
lineclear(LineOffset[j] + wp->w_wincol, wp->w_width);
9910+
lineclear(LineOffset[j] + wp->w_wincol, wp->w_width,
9911+
clear_attr);
99069912
else
99079913
lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
99089914
LineWraps[j] = FALSE;
@@ -9920,14 +9926,16 @@ screen_ins_lines(
99209926
LineOffset[j + line_count] = temp;
99219927
LineWraps[j + line_count] = FALSE;
99229928
if (can_clear((char_u *)" "))
9923-
lineclear(temp, (int)Columns);
9929+
lineclear(temp, (int)Columns, clear_attr);
99249930
else
99259931
lineinvalid(temp, (int)Columns);
99269932
}
99279933
}
99289934

99299935
screen_stop_highlight();
99309936
windgoto(cursor_row, 0);
9937+
if (clear_attr != 0)
9938+
screen_start_highlight(clear_attr);
99319939

99329940
#ifdef FEAT_WINDOWS
99339941
/* redraw the characters */
@@ -9993,6 +10001,7 @@ screen_del_lines(
999310001
int line_count,
999410002
int end,
999510003
int force, /* even when line_count > p_ttyscroll */
10004+
int clear_attr, /* used for clearing lines */
999610005
win_T *wp UNUSED) /* NULL or window to use width from */
999710006
{
999810007
int j;
@@ -10136,7 +10145,8 @@ screen_del_lines(
1013610145
linecopy(j - line_count, j, wp);
1013710146
j -= line_count;
1013810147
if (can_clear((char_u *)" "))
10139-
lineclear(LineOffset[j] + wp->w_wincol, wp->w_width);
10148+
lineclear(LineOffset[j] + wp->w_wincol, wp->w_width,
10149+
clear_attr);
1014010150
else
1014110151
lineinvalid(LineOffset[j] + wp->w_wincol, wp->w_width);
1014210152
LineWraps[j] = FALSE;
@@ -10155,13 +10165,16 @@ screen_del_lines(
1015510165
LineOffset[j - line_count] = temp;
1015610166
LineWraps[j - line_count] = FALSE;
1015710167
if (can_clear((char_u *)" "))
10158-
lineclear(temp, (int)Columns);
10168+
lineclear(temp, (int)Columns, clear_attr);
1015910169
else
1016010170
lineinvalid(temp, (int)Columns);
1016110171
}
1016210172
}
1016310173

10164-
screen_stop_highlight();
10174+
if (screen_attr != clear_attr)
10175+
screen_stop_highlight();
10176+
if (clear_attr != 0)
10177+
screen_start_highlight(clear_attr);
1016510178

1016610179
#ifdef FEAT_WINDOWS
1016710180
/* redraw the characters */

0 commit comments

Comments
 (0)