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.188 by root, Thu Dec 22 00:07:47 2005 UTC vs.
Revision 1.189 by root, Thu Dec 22 15:28:15 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
283 while (p != pend && q > 0) 285 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 { 286 {
294 p = MOD (p - 1, prev_total_rows); 287 p = MOD (p - 1, prev_total_rows);
288#ifdef DEBUG_STRICT
289 assert (old_buf [MOD (p, prev_total_rows)].t);
290#endif
295 291
292 int llen = old_buf [MOD (p, prev_total_rows)].l;
293
294 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
295 {
296 p = MOD (p - 1, prev_total_rows);
297
296 llen += prev_ncol; 298 llen += prev_ncol;
299 }
300
301 int qlines = max (0, (llen - 1) / ncol) + 1;
302
303 // drop partial lines completely
304 if (q < qlines)
305 break;
306
307 q -= qlines;
308
309 int lofs = 0;
310 line_t *qline;
311
312 // re-assemble the full line by destination lines
313 for (int qrow = q; qlines--; qrow++)
314 {
315 qline = row_buf + qrow;
316 lalloc (*qline);
317 qline->set_is_longer ();
318
319 int qcol = 0;
320
321 // fill a single destination line
322 while (lofs < llen && qcol < ncol)
323 {
324 int prow = lofs / prev_ncol;
325 int pcol = lofs % prev_ncol;
326
327 line_t &pline = old_buf [MOD (p + prow, prev_total_rows)];
328
329 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
330
331 assert (len);
332 assert (pline.t);
333
334 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
335 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
336
337 lofs += len;
338 qcol += len;
339 }
340 }
341
342 qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1;
343 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
297 } 344 }
298 345
299 int qlines = max (0, (llen - 1) / ncol) + 1; 346 term_start = total_rows - nrow;
347 view_start = 0;
348 nsaved = term_start - q;
349
350 // make sure all terminal lines exist
351 while (nsaved < 0)
352 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
300 353
301 // drop partial lines completely 354 }
302 if (q < qlines) 355 else
303 break; 356 {
304 357 // if no scrollback exists (yet), wing, instead of wrap
305 q -= qlines; 358
306 359 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 { 360 {
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)]; 361 line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)];
362 line_t &qline = row_buf [row];
326 363
327 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); 364 qline = pline;
328 365 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 } 366 }
339 367
340 qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; 368 for (int row = prev_nrow; row < nrow; row++)
341 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); 369 {
370 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
342 } 371 }
343 372
344 term_start = total_rows - nrow; 373 term_start = 0;
345 view_start = 0; 374 view_start = 0;
346 nsaved = term_start - q; 375 }
347 376
348 // make sure all terminal lines exist 377#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++) 378 for (int i = -nsaved; i < nrow; i++)
353 assert (ROW (i).t);//D 379 assert (ROW (i).t);
380#endif
354 381
355 free (old_buf); 382 free (old_buf);
356 delete old_ta; 383 delete old_ta;
357 delete old_ra; 384 delete old_ra;
358 385
359 min_it (screen.cur.row, nrow - 1); 386 clamp_it (screen.cur.row, 0, nrow - 1);
360 min_it (screen.cur.col, ncol - 1); 387 clamp_it (screen.cur.col, 0, ncol - 1);
361 388
362 if (tabs) 389 if (tabs)
363 free (tabs); 390 free (tabs);
364 } 391 }
365 392

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines