+ /*
+ * Find how many lines from the top of the screen are unchanged.
+ */
+ for (top = 0; top < win->maxy; top++)
+ if (win->lines[top]->flags & __FORCEPAINT ||
+ win->lines[top]->hash != curscr->lines[top]->hash
+ || memcmp(win->lines[top]->line,
+ curscr->lines[top]->line,
+ win->maxx * __LDATASIZE) != 0)
+ break;
+ else
+ win->lines[top]->flags &= ~__ISDIRTY;
+ /*
+ * Find how many lines from bottom of screen are unchanged.
+ */
+ for (bot = win->maxy - 1; bot >= 0; bot--)
+ if (win->lines[bot]->flags & __FORCEPAINT ||
+ win->lines[bot]->hash != curscr->lines[bot]->hash
+ || memcmp(win->lines[bot]->line,
+ curscr->lines[bot]->line,
+ win->maxx * __LDATASIZE) != 0)
+ break;
+ else
+ win->lines[bot]->flags &= ~__ISDIRTY;
+
+#ifdef NO_JERKINESS
+ /*
+ * If we have a bottom unchanged region return. Scrolling the
+ * bottom region up and then back down causes a screen jitter.
+ * This will increase the number of characters sent to the screen
+ * but it looks better.
+ */
+ if (bot < win->maxy - 1)
+ return;
+#endif /* NO_JERKINESS */
+