6. support to backfill text from the buffer when a windows is resized with more
rows
On 03/25/2011 10:25 PM, Ross Mohn wrote:
> I'm going to post a series of 6 patches for dvtm over the next several
> minutes. They all apply to the current HEAD of the dvtm git repository
> (committed 2011-01-07). I think I've teased them all apart pretty well
> so that each one is separate and complete.
>
> 1. support for compiling under AIX
> 2. support the 8 basic highlighted colors, plus a couple of color_hash fixes
> 3. fix a scrolling issue and add in "ESC #" to call interpret_esc_SCS()
> 4. support for "ESC 6 n", get cursor position, which calls a new
> function, send_curs()
> 5. support colorrules[] to match strings against window titles,
> applycolorrules(), and call madtty_set_dflt_colors()
> 6. support to backfill text from the buffer when a windows is resized
> with more rows
>
> Comments, testing, and bugfixes sincerely welcome!
>
> Cheers! -Ross
>
>
Index: madtty.c
===================================================================
--- madtty.c (.../vendor/current) (revision 47)
+++ madtty.c (.../trunk) (revision 47)
@@ -1153,7 +1178,7 @@
if (t->rows != rows) {
if (t->curs_row > lines+rows) {
/* scroll up instead of simply chopping off bottom */
- fill_scroll_buf(t, t->rows - rows);
+ fill_scroll_buf(t, (t->curs_row - t->lines) - rows + 1);
}
while (t->rows > rows) {
free(lines[t->rows - 1].text);
@@ -1190,13 +1215,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, t, 1);
+ 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 +1239,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);
}