Attached is another patch for madtty.c at the head of dvtm. This one adds support for backfilling text from the buffer when a window is resized with more rows. As an example, let's say you have a window filled with 70 rows of text, then you resize it to 34 rows. The new window will push the top 36 rows to the buffer and display just the bottom 34 rows. Now if you resize it back to 70 rows this patch will pop 36 rows of data out of the buffer and display 70 rows of text again.
Cheers! -Ross
Index: madtty.c =================================================================== --- madtty.c (.../vendor/dvtm/current/madtty.c) (revision 20) +++ madtty.c (.../trunk/dvtm/madtty.c) (revision 20) @@ -1190,13 +1201,23 @@ t->cols = cols; } - while (t->rows < rows) { - lines[t->rows].text = (wchar_t *)calloc(sizeof(wchar_t), t->maxcols); - lines[t->rows].attr = (uint16_t *)calloc(sizeof(uint16_t), t->maxcols); - lines[t->rows].fg = calloc(sizeof(short), t->maxcols); - lines[t->rows].bg = calloc(sizeof(short), t->maxcols); - t_row_set(lines + t->rows, 0, t->maxcols, 0); - t->rows++; + int deltarows = 0; + if (t->rows < rows) { + while (t->rows < rows) { + lines[t->rows].text = (wchar_t *)calloc(sizeof(wchar_t), t->maxcols); + lines[t->rows].attr = (uint16_t *)calloc(sizeof(uint16_t), t->maxcols); + lines[t->rows].fg = calloc(sizeof(short), t->maxcols); + lines[t->rows].bg = calloc(sizeof(short), t->maxcols); + t_row_set(lines + t->rows, 0, t->maxcols, 0); + t->rows++; + } + + /* Prepare for backfill */ + if (t->curs_row >= t->scroll_bot - 1) { + deltarows = t->lines + rows - t->curs_row - 1; + if (deltarows > t->scroll_buf_len) + deltarows = t->scroll_buf_len; + } } t->curs_row += lines - t->lines; @@ -1204,6 +1225,13 @@ t->scroll_bot = lines + rows; t->lines = lines; clamp_cursor_to_bounds(t); + + /* Perform backfill */ + if (deltarows > 0) { + fill_scroll_buf(t, -deltarows); + t->curs_row += deltarows; + } + ioctl(t->pty, TIOCSWINSZ, &ws); kill(-t->childpid, SIGWINCH); }