… | |
… | |
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 | row_col_t ocur = screen.cur; |
|
|
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
|
|
287 | |
285 | while (p != pend && q > 0) |
288 | while (p != pend && q > 0) |
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_, as this seems to upset |
|
|
335 | // applications/shells/readline least. |
|
|
336 | if (prow == ocur.row) |
|
|
337 | screen.cur.row = qrow - (total_rows - nrow); |
|
|
338 | |
|
|
339 | line_t &pline = old_buf [prow]; |
328 | |
340 | |
329 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
341 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
330 | |
342 | |
331 | assert (len); |
343 | assert (len); |
332 | assert (pline.t); |
344 | assert (pline.t); |