1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Clip the 'lines' parameter to scroll() at the size of the scroll

window. scroll() iterates that many times, so this prevents a tedious
wait if you give a very large parameter to ESC[L or ESC[M, for
example.

A side effect is that very large requests for upward scrolling in a
context that affects the scrollback will not actually wipe out the
whole scrollback: instead they push just the current lines of the
screen into the scrollback, and don't continue on to fill it up with
endless boring blank lines. I think this is likely to be more useful
in general, since it avoids wiping out lots of useful scrollback data
by mistake. I can imagine that people might have been using it
precisely _to_ wipe the scrollback in some situations, but if so then
they should use CSI 3 J instead.

[originally from svn r9677]
This commit is contained in:
Simon Tatham 2012-09-23 15:36:54 +00:00
parent c048389315
commit b2b54bc470

View File

@ -1978,7 +1978,7 @@ static void check_selection(Terminal *term, pos from, pos to)
static void scroll(Terminal *term, int topline, int botline, int lines, int sb)
{
termline *line;
int i, seltop;
int i, seltop, scrollwinsize;
#ifdef OPTIMISE_SCROLL
int olddisptop, shift;
#endif /* OPTIMISE_SCROLL */
@ -1990,8 +1990,14 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb)
olddisptop = term->disptop;
shift = lines;
#endif /* OPTIMISE_SCROLL */
scrollwinsize = botline - topline + 1;
if (lines < 0) {
while (lines < 0) {
lines = -lines;
if (lines > scrollwinsize)
lines = scrollwinsize;
while (lines-- > 0) {
line = delpos234(term->screen, botline);
resizeline(term, line, term->cols);
for (i = 0; i < term->cols; i++)
@ -2013,11 +2019,11 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb)
term->selend.x = 0;
}
}
lines++;
}
} else {
while (lines > 0) {
if (lines > scrollwinsize)
lines = scrollwinsize;
while (lines-- > 0) {
line = delpos234(term->screen, topline);
#ifdef TERM_CC_DIAGS
cc_check(line);
@ -2103,8 +2109,6 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb)
}
}
}
lines--;
}
}
#ifdef OPTIMISE_SCROLL