… | |
… | |
291 | * add or delete rows as appropriate |
291 | * add or delete rows as appropriate |
292 | */ |
292 | */ |
293 | |
293 | |
294 | int common_col = min (prev_ncol, ncol); |
294 | int common_col = min (prev_ncol, ncol); |
295 | |
295 | |
|
|
296 | // resize swap_buf, blank drawn_buf |
296 | for (int row = min (nrow, prev_nrow); row--; ) |
297 | for (int row = min (nrow, prev_nrow); row--; ) |
297 | { |
298 | { |
298 | scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); |
299 | scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); |
299 | memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col); |
300 | memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col); |
300 | memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col); |
301 | memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col); |
… | |
… | |
304 | |
305 | |
305 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
306 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
306 | int pend = MOD (term_start + top_row , prev_total_rows); |
307 | int pend = MOD (term_start + top_row , prev_total_rows); |
307 | int q = total_rows; // rewrapped row |
308 | int q = total_rows; // rewrapped row |
308 | |
309 | |
|
|
310 | #if ENABLE_FRILLS |
309 | if ((rewrap_always || top_row) && !rewrap_never) |
311 | if ((rewrap_always || top_row) && !rewrap_never) |
310 | { |
312 | { |
311 | // Re-wrap lines. This is rather ugly, possibly because I am too dumb |
313 | // Re-wrap lines. This is rather ugly, possibly because I am too dumb |
312 | // to come up with a lean and mean algorithm. |
314 | // to come up with a lean and mean algorithm. |
313 | // TODO: maybe optimise when width didn't change |
315 | // TODO: maybe optimise when width didn't change |
… | |
… | |
330 | llen += prev_ncol; |
332 | llen += prev_ncol; |
331 | } |
333 | } |
332 | |
334 | |
333 | int qlines = max (0, (llen - 1) / ncol) + 1; |
335 | int qlines = max (0, (llen - 1) / ncol) + 1; |
334 | |
336 | |
|
|
337 | q -= qlines; |
|
|
338 | |
335 | // drop partial lines completely |
339 | // drop partial lines completely |
336 | if (q < qlines) |
340 | if (q < 0) |
337 | break; |
341 | break; |
338 | |
|
|
339 | q -= qlines; |
|
|
340 | |
342 | |
341 | int lofs = 0; |
343 | int lofs = 0; |
342 | line_t *qline; |
344 | line_t *qline; |
343 | |
345 | |
344 | // re-assemble the full line by destination lines |
346 | // re-assemble the full line by destination lines |
… | |
… | |
385 | qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; |
387 | qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; |
386 | qline->is_longer (0); |
388 | qline->is_longer (0); |
387 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
389 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
388 | } |
390 | } |
389 | while (p != pend && q > 0); |
391 | while (p != pend && q > 0); |
390 | |
|
|
391 | term_start = total_rows - nrow; |
|
|
392 | top_row = q - term_start; |
|
|
393 | |
|
|
394 | // make sure all terminal lines exist |
|
|
395 | while (top_row > 0) |
|
|
396 | scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); |
|
|
397 | } |
392 | } |
398 | else |
393 | else |
|
|
394 | #endif |
|
|
395 | { |
|
|
396 | // wing, instead of wrap |
399 | { |
397 | do |
400 | // if no scrollback exists (yet), wing, instead of wrap |
|
|
401 | |
|
|
402 | for (int row = min (nrow, prev_nrow); row--; ) |
|
|
403 | { |
398 | { |
404 | line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)]; |
399 | p = MOD (p - 1, prev_total_rows); |
405 | line_t &dst = row_buf [row]; |
400 | q--; |
406 | |
401 | |
407 | copy_line (dst, src); |
402 | copy_line (row_buf [q], prev_row_buf [p]); |
408 | } |
403 | } |
|
|
404 | while (p != pend); |
|
|
405 | } |
409 | |
406 | |
410 | for (int row = prev_nrow; row < nrow; row++) |
407 | term_start = total_rows - nrow; |
|
|
408 | top_row = q - term_start; |
|
|
409 | |
|
|
410 | // make sure all terminal lines exist |
|
|
411 | while (top_row > 0) |
411 | scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
412 | scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); |
412 | |
|
|
413 | term_start = 0; |
|
|
414 | } |
|
|
415 | |
413 | |
416 | clamp_it (screen.cur.row, 0, nrow - 1); |
414 | clamp_it (screen.cur.row, 0, nrow - 1); |
417 | clamp_it (screen.cur.col, 0, ncol - 1); |
415 | clamp_it (screen.cur.col, 0, ncol - 1); |
418 | } |
416 | } |
419 | |
417 | |