Make the max number of unscrolled lines implementation defined

This commit is contained in:
Kovid Goyal 2021-05-11 14:55:14 +05:30
parent 7c5706ead9
commit cc2afef390
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 5 additions and 4 deletions

View File

@ -179,9 +179,7 @@ screen. This escape code allows that text to be restored.
If the scrollback buffer is empty or there is no scrollback buffer, such as for
the alternate screen, then the newly inserted lines must be empty, just as with
the original ``SD`` escape code. The maximum number of lines that can be
scrolled down is the height of the screen, i.e. the number of lines on the screen.
If the escape code requests more than that number of lines, the terminal *must*
clip the request to the current screen size.
scrolled down is implementation defined, but must be at least one screen worth.
The syntax of the escape code is identical to that of ``SD`` except that it has
a trailing ``+`` modifier. This is legal under the `ECMA 48 standard

View File

@ -1140,9 +1140,12 @@ screen_reverse_index(Screen *self) {
static void
_reverse_scroll(Screen *self, unsigned int count, bool fill_from_scrollback) {
// Scroll the screen down by count lines, not moving the cursor
count = MIN(self->lines, count);
unsigned int top = self->margin_top, bottom = self->margin_bottom;
fill_from_scrollback = fill_from_scrollback && self->linebuf == self->main_linebuf;
if (fill_from_scrollback) {
unsigned limit = MAX(self->lines, self->historybuf->count);
count = MIN(limit, count);
} else count = MIN(self->lines, count);
while (count-- > 0) {
bool copied = false;
if (fill_from_scrollback) copied = historybuf_pop_line(self->historybuf, self->alt_linebuf->line);