- ldata = lineptr(start.y);
- while (poslt(start, end)) {
- if (start.x == term->cols) {
- if (!erase_lattr)
- ldata[start.x] &= ~(LATTR_WRAPPED | LATTR_WRAPPED2);
- else
- ldata[start.x] = LATTR_NORM;
- } else {
- ldata[start.x] = term->erase_char;
- }
- if (incpos(start) && start.y < term->rows)
- ldata = lineptr(start.y);
+ if (term->cfg.erase_to_scrollback &&
+ start.y == 0 && start.x == 0 && end.x == 0 && erase_lattr) {
+ /* If it's a whole number of lines, starting at the top, and
+ * we're fully erasing them, erase by scrolling and keep the
+ * lines in the scrollback. */
+ int scrolllines = end.y;
+ if (end.y == term->rows) {
+ /* Shrink until we find a non-empty row.*/
+ scrolllines = find_last_nonempty_line(term, term->screen) + 1;
+ }
+ if (scrolllines > 0)
+ scroll(term, 0, scrolllines - 1, scrolllines, TRUE);
+ fix_cpos;
+ } else {
+ unsigned long *ldata = lineptr(start.y);
+ while (poslt(start, end)) {
+ if (start.x == term->cols) {
+ if (!erase_lattr)
+ ldata[start.x] &= ~(LATTR_WRAPPED | LATTR_WRAPPED2);
+ else
+ ldata[start.x] = LATTR_NORM;
+ } else {
+ ldata[start.x] = term->erase_char;
+ }
+ if (incpos(start) && start.y < term->rows)
+ ldata = lineptr(start.y);
+ }