… | |
… | |
280 | if (nsaved) |
280 | if (nsaved) |
281 | { |
281 | { |
282 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
282 | // re-wrap lines, this is rather ugly, possibly because I am too dumb |
283 | // to come up with a lean and mean algorithm. |
283 | // to come up with a lean and mean algorithm. |
284 | |
284 | |
285 | while (p != pend && q > 0) |
285 | row_col_t ocur = screen.cur; |
|
|
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
|
|
287 | |
|
|
288 | do |
286 | { |
289 | { |
287 | p = MOD (p - 1, prev_total_rows); |
290 | p = MOD (p - 1, prev_total_rows); |
288 | #ifdef DEBUG_STRICT |
291 | #ifdef DEBUG_STRICT |
289 | assert (old_buf [MOD (p, prev_total_rows)].t); |
292 | assert (old_buf [MOD (p, prev_total_rows)].t); |
290 | #endif |
293 | #endif |
291 | |
294 | |
|
|
295 | int plines = 1; |
292 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
296 | int llen = old_buf [MOD (p, prev_total_rows)].l; |
293 | |
297 | |
294 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
298 | while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) |
295 | { |
299 | { |
296 | p = MOD (p - 1, prev_total_rows); |
300 | p = MOD (p - 1, prev_total_rows); |
297 | |
301 | |
|
|
302 | plines++; |
298 | llen += prev_ncol; |
303 | llen += prev_ncol; |
299 | } |
304 | } |
300 | |
305 | |
301 | int qlines = max (0, (llen - 1) / ncol) + 1; |
306 | int qlines = max (0, (llen - 1) / ncol) + 1; |
302 | |
307 | |
… | |
… | |
322 | while (lofs < llen && qcol < ncol) |
327 | while (lofs < llen && qcol < ncol) |
323 | { |
328 | { |
324 | int prow = lofs / prev_ncol; |
329 | int prow = lofs / prev_ncol; |
325 | int pcol = lofs % prev_ncol; |
330 | int pcol = lofs % prev_ncol; |
326 | |
331 | |
327 | line_t &pline = old_buf [MOD (p + prow, prev_total_rows)]; |
332 | prow = MOD (p + prow, prev_total_rows); |
|
|
333 | |
|
|
334 | // we only adjust the cursor _row_ and put it into |
|
|
335 | // the topmost line of "long line" it was in, as |
|
|
336 | // this seems to upset applications/shells/readline |
|
|
337 | // least. |
|
|
338 | if (prow == ocur.row) |
|
|
339 | screen.cur.row = q - (total_rows - nrow); |
|
|
340 | |
|
|
341 | line_t &pline = old_buf [prow]; |
328 | |
342 | |
329 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
343 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
330 | |
344 | |
331 | assert (len); |
345 | assert (len); |
332 | assert (pline.t); |
346 | assert (pline.t); |
… | |
… | |
340 | } |
354 | } |
341 | |
355 | |
342 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
356 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
343 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
357 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
344 | } |
358 | } |
|
|
359 | while (p != pend && q > 0); |
345 | |
360 | |
346 | term_start = total_rows - nrow; |
361 | term_start = total_rows - nrow; |
347 | view_start = 0; |
|
|
348 | nsaved = term_start - q; |
362 | nsaved = term_start - q; |
349 | |
363 | |
350 | // make sure all terminal lines exist |
364 | // make sure all terminal lines exist |
351 | while (nsaved < 0) |
365 | while (nsaved < 0) |
352 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
366 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
… | |
… | |
369 | { |
383 | { |
370 | 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); |
371 | } |
385 | } |
372 | |
386 | |
373 | term_start = 0; |
387 | term_start = 0; |
374 | view_start = 0; |
|
|
375 | } |
388 | } |
376 | |
389 | |
377 | #ifdef DEBUG_STRICT |
390 | #ifdef DEBUG_STRICT |
378 | for (int i = -nsaved; i < nrow; i++) |
391 | for (int i = -nsaved; i < nrow; i++) |
379 | assert (ROW (i).t); |
392 | assert (ROW (i).t); |