… | |
… | |
283 | // to come up with a lean and mean algorithm. |
283 | // to come up with a lean and mean algorithm. |
284 | |
284 | |
285 | row_col_t ocur = screen.cur; |
285 | row_col_t ocur = screen.cur; |
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
287 | |
287 | |
288 | while (p != pend && q > 0) |
288 | do |
289 | { |
289 | { |
290 | p = MOD (p - 1, prev_total_rows); |
290 | p = MOD (p - 1, prev_total_rows); |
291 | #ifdef DEBUG_STRICT |
291 | #ifdef DEBUG_STRICT |
292 | assert (old_buf [MOD (p, prev_total_rows)].t); |
292 | assert (old_buf [MOD (p, prev_total_rows)].t); |
293 | #endif |
293 | #endif |
… | |
… | |
329 | int prow = lofs / prev_ncol; |
329 | int prow = lofs / prev_ncol; |
330 | int pcol = lofs % prev_ncol; |
330 | int pcol = lofs % prev_ncol; |
331 | |
331 | |
332 | prow = MOD (p + prow, prev_total_rows); |
332 | prow = MOD (p + prow, prev_total_rows); |
333 | |
333 | |
334 | // we only adjust the cursor _row_, as this seems to upset |
334 | // we only adjust the cursor _row_ and put it into |
|
|
335 | // the topmost line of "long line" it was in, as |
335 | // applications/shells/readline least. |
336 | // this seems to upset applications/shells/readline |
|
|
337 | // least. |
336 | if (prow == ocur.row) |
338 | if (prow == ocur.row) |
337 | screen.cur.row = qrow - (total_rows - nrow); |
339 | screen.cur.row = q - (total_rows - nrow); |
338 | |
340 | |
339 | line_t &pline = old_buf [prow]; |
341 | line_t &pline = old_buf [prow]; |
340 | |
342 | |
341 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
343 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
342 | |
344 | |
… | |
… | |
352 | } |
354 | } |
353 | |
355 | |
354 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
356 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
355 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
357 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
356 | } |
358 | } |
|
|
359 | while (p != pend && q > 0); |
357 | |
360 | |
358 | term_start = total_rows - nrow; |
361 | term_start = total_rows - nrow; |
359 | view_start = 0; |
|
|
360 | nsaved = term_start - q; |
362 | nsaved = term_start - q; |
361 | |
363 | |
362 | // make sure all terminal lines exist |
364 | // make sure all terminal lines exist |
363 | while (nsaved < 0) |
365 | while (nsaved < 0) |
364 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
366 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
… | |
… | |
381 | { |
383 | { |
382 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
384 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
383 | } |
385 | } |
384 | |
386 | |
385 | term_start = 0; |
387 | term_start = 0; |
386 | view_start = 0; |
|
|
387 | } |
388 | } |
388 | |
389 | |
389 | #ifdef DEBUG_STRICT |
390 | #ifdef DEBUG_STRICT |
390 | for (int i = -nsaved; i < nrow; i++) |
391 | for (int i = -nsaved; i < nrow; i++) |
391 | assert (ROW (i).t); |
392 | assert (ROW (i).t); |