ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.187 by root, Wed Dec 21 23:57:12 2005 UTC vs.
Revision 1.191 by root, Thu Dec 22 18:36:55 2005 UTC

271 drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); 271 drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE);
272 } 272 }
273 273
274 line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); 274 line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t));
275 275
276 // re-wrap lines, this is rather ugly, possibly because I am too dumb
277 // to come up with a lean and mean algorithm.
278
279 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row 276 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row
280 int pend = MOD (term_start - nsaved , prev_total_rows); 277 int pend = MOD (term_start - nsaved , prev_total_rows);
281 int q = total_rows; // rewrapped row 278 int q = total_rows; // rewrapped row
282 279
280 if (nsaved)
281 {
282 // re-wrap lines, this is rather ugly, possibly because I am too dumb
283 // to come up with a lean and mean algorithm.
284
285 row_col_t ocur = screen.cur;
286 ocur.row = MOD (term_start + ocur.row, prev_total_rows);
287
283 while (p != pend && q > 0) 288 while (p != pend && q > 0)
284 {
285 p = MOD (p - 1, prev_total_rows);
286#ifdef DEBUG_STRICT
287 assert (old_buf [MOD (p, prev_total_rows)].t);
288#endif
289
290 int llen = old_buf [MOD (p, prev_total_rows)].l;
291
292 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
293 { 289 {
294 p = MOD (p - 1, prev_total_rows); 290 p = MOD (p - 1, prev_total_rows);
291#ifdef DEBUG_STRICT
292 assert (old_buf [MOD (p, prev_total_rows)].t);
293#endif
295 294
295 int plines = 1;
296 int llen = old_buf [MOD (p, prev_total_rows)].l;
297
298 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
299 {
300 p = MOD (p - 1, prev_total_rows);
301
302 plines++;
296 llen += prev_ncol; 303 llen += prev_ncol;
304 }
305
306 int qlines = max (0, (llen - 1) / ncol) + 1;
307
308 // drop partial lines completely
309 if (q < qlines)
310 break;
311
312 q -= qlines;
313
314 int lofs = 0;
315 line_t *qline;
316
317 // re-assemble the full line by destination lines
318 for (int qrow = q; qlines--; qrow++)
319 {
320 qline = row_buf + qrow;
321 lalloc (*qline);
322 qline->set_is_longer ();
323
324 int qcol = 0;
325
326 // fill a single destination line
327 while (lofs < llen && qcol < ncol)
328 {
329 int prow = lofs / prev_ncol;
330 int pcol = lofs % prev_ncol;
331
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];
342
343 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
344
345 assert (len);
346 assert (pline.t);
347
348 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
349 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
350
351 lofs += len;
352 qcol += len;
353 }
354 }
355
356 qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1;
357 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
297 } 358 }
298 359
299 int qlines = max (0, (llen - 1) / ncol) + 1; 360 term_start = total_rows - nrow;
361 view_start = 0;
362 nsaved = term_start - q;
363
364 // make sure all terminal lines exist
365 while (nsaved < 0)
366 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
300 367
301 // drop partial lines completely 368 }
302 if (q < qlines) 369 else
303 break; 370 {
304 371 // if no scrollback exists (yet), wing, instead of wrap
305 q -= qlines; 372
306 373 for (int row = min (nrow, prev_nrow); row--; )
307 int lofs = 0;
308 line_t *qline;
309
310 // re-assemble the full line by destination lines
311 for (int qrow = q; qlines--; qrow++)
312 { 374 {
313 qline = row_buf + qrow;
314 lalloc (*qline);
315 qline->set_is_longer ();
316
317 int qcol = 0;
318
319 // fill a single destination line
320 while (lofs < llen && qcol < ncol)
321 {
322 int prow = lofs / prev_ncol;
323 int pcol = lofs % prev_ncol;
324
325 line_t &pline = old_buf [MOD (p + prow, prev_total_rows)]; 375 line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)];
376 line_t &qline = row_buf [row];
326 377
327 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); 378 qline = pline;
328 379 lresize (qline);
329 assert (len);
330 assert (pline.t);
331
332 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
333 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
334
335 lofs += len;
336 qcol += len;
337 }
338 } 380 }
339 381
340 qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; 382 for (int row = prev_nrow; row < nrow; row++)
341 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); 383 {
384 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
342 } 385 }
343 386
344 term_start = total_rows - nrow; 387 term_start = 0;
345 view_start = 0; 388 view_start = 0;
346 nsaved = term_start - q; 389 }
347 390
348 // make sure all terminal lines exist 391#ifdef DEBUG_STRICT
349 while (nsaved < 0)
350 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
351
352 for (int i = -nsaved; i < nrow; i++) 392 for (int i = -nsaved; i < nrow; i++)
353 assert (ROW (i).t);//D 393 assert (ROW (i).t);
394#endif
354 395
355 free (old_buf); 396 free (old_buf);
356 delete old_ta; 397 delete old_ta;
357 delete old_ra; 398 delete old_ra;
358 399
359 min_it (screen.cur.row, nrow - 1); 400 clamp_it (screen.cur.row, 0, nrow - 1);
360 min_it (screen.cur.col, ncol - 1); 401 clamp_it (screen.cur.col, 0, ncol - 1);
361 402
362 if (tabs) 403 if (tabs)
363 free (tabs); 404 free (tabs);
364 } 405 }
365 406
487#if NSCREENS 528#if NSCREENS
488 if (options & Opt_secondaryScreen) 529 if (options & Opt_secondaryScreen)
489 { 530 {
490 num_scr = 0; 531 num_scr = 0;
491 532
492 for (int i = nrow; i--; ) 533 for (int i = prev_nrow; i--; )
493 ::swap (ROW(i), swap_buf [i]); 534 ::swap (ROW(i), swap_buf [i]);
494 535
495 ::swap (screen.charset, swap.charset); 536 ::swap (screen.charset, swap.charset);
496 ::swap (screen.flags, swap.flags); 537 ::swap (screen.flags, swap.flags);
497 screen.flags |= Screen_VisibleCursor; 538 screen.flags |= Screen_VisibleCursor;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines