From 19e1c157614170be1849d00312e6da81742554c5 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sat, 23 Nov 2002 21:42:46 +0000 Subject: [PATCH] Fix a bug in scroll_display(): when the scrolled region contains the cursor we need to update dispcurs as well as disptext. Add scroll optimisation to scroll(). This makes it rather obvious that scroll optimisation is breaking with PuTTY's usual policy of lazy updates, since scrolling is done eagerly. Fixing this so that all the scrolling is saved up for do_paint would be nice, but non-trivial. [originally from svn r2252] --- terminal.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/terminal.c b/terminal.c index 8b48a3c5..06d6ee6b 100644 --- a/terminal.c +++ b/terminal.c @@ -592,11 +592,13 @@ static void check_selection(Terminal *term, pos from, pos to) static void scroll(Terminal *term, int topline, int botline, int lines, int sb) { unsigned long *line, *line2; - int i, seltop; + int i, seltop, olddisptop, shift; if (topline != 0 || term->alt_which != 0) sb = FALSE; + olddisptop = term->disptop; + shift = lines; if (lines < 0) { while (lines < 0) { line = delpos234(term->screen, botline); @@ -705,6 +707,11 @@ static void scroll(Terminal *term, int topline, int botline, int lines, int sb) lines--; } } +#ifdef OPTIMISE_SCROLL + shift += term->disptop - olddisptop; + if (shift < term->rows && shift > -term->rows && shift != 0) + scroll_display(term, topline, botline, shift); +#endif /* OPTIMISE_SCROLL */ } #ifdef OPTIMISE_SCROLL @@ -722,10 +729,15 @@ static void scroll_display(Terminal *term, int topline, int botline, int lines) size = end - start - distance; if (lines > 0) { memmove(start, start + distance, size * TSIZE); + if (term->dispcurs >= start + distance && + term->dispcurs <= start + distance + size) + term->dispcurs -= distance; for (i = 0; i < distance; i++) (start + size)[i] |= ATTR_INVALID; } else { memmove(start + distance, start, size * TSIZE); + if (term->dispcurs >= start && term->dispcurs <= start + size) + term->dispcurs += distance; for (i = 0; i < distance; i++) start[i] |= ATTR_INVALID; }