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.189 by root, Thu Dec 22 15:28:15 2005 UTC vs.
Revision 1.198 by root, Tue Dec 27 01:25:42 2005 UTC

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);
337 lofs += len; 351 lofs += len;
338 qcol += len; 352 qcol += len;
339 } 353 }
340 } 354 }
341 355
342 qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; 356 qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0;
357#ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY
358 if (qline->l < 0)
359 {
360 fprintf (stderr, "ERROR, PLEASE REPORT to rxvt-unicode@plan9.de: qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D
361 qline->l = 0;
362 }
363#endif
343 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); 364 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
344 } 365 }
366 while (p != pend && q > 0);
345 367
346 term_start = total_rows - nrow; 368 term_start = total_rows - nrow;
347 view_start = 0;
348 nsaved = term_start - q; 369 nsaved = term_start - q;
349 370
350 // make sure all terminal lines exist 371 // make sure all terminal lines exist
351 while (nsaved < 0) 372 while (nsaved < 0)
352 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); 373 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
369 { 390 {
370 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); 391 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
371 } 392 }
372 393
373 term_start = 0; 394 term_start = 0;
374 view_start = 0;
375 } 395 }
376 396
377#ifdef DEBUG_STRICT 397#ifdef DEBUG_STRICT //TODO: remove
378 for (int i = -nsaved; i < nrow; i++) 398 for (int i = -nsaved; i < nrow; i++)
379 assert (ROW (i).t); 399 assert (ROW (i).t);
380#endif 400#endif
381 401
382 free (old_buf); 402 free (old_buf);
607 { 627 {
608 selection.beg.row -= count; 628 selection.beg.row -= count;
609 selection.end.row -= count; 629 selection.end.row -= count;
610 selection.mark.row -= count; 630 selection.mark.row -= count;
611 631
612 selection_check (0); 632 if (selection.beg.row < -nsaved
633 || selection.end.row < -nsaved
634 || selection.mark.row < -nsaved)
635 {
636 CLEAR_ALL_SELECTION ();
637 selection.op = SELECTION_CLEAR;
638 }
613 } 639 }
614 640
615 for (int i = count; i--; ) 641 for (int i = count; i--; )
642 {
643 ROW(row2 - i).l = 0;
616 scr_blank_screen_mem (ROW(row2 - i), rstyle); 644 scr_blank_screen_mem (ROW(row2 - i), rstyle);
645 }
617 646
618 if ((options & Opt_scrollWithBuffer) 647 if ((options & Opt_scrollWithBuffer)
619 && view_start != 0 648 && view_start != 0
620 && view_start != saveLines) 649 && view_start != saveLines)
621 scr_page (UP, count); 650 scr_page (UP, count);
622 } 651 }
623 else 652 else
624 { 653 {
625 if (selection.op && current_screen == selection.screen) 654 if (selection.op && current_screen == selection.screen)
626 { 655 {
627 int i = selection.beg.row; 656 if ((selection.beg.row < row1 && selection.end.row > row1)
628 int j = selection.end.row; 657 || (selection.beg.row < row2 && selection.end.row > row2)
629
630 if ((i < row1 && j > row1)
631 || (i < row2 && j > row2)
632 || (i - count < row1 && i >= row1) 658 || (selection.beg.row - count < row1 && selection.beg.row >= row1)
633 || (i - count > row2 && i <= row2) 659 || (selection.beg.row - count > row2 && selection.beg.row <= row2)
634 || (j - count < row1 && j >= row1) 660 || (selection.end.row - count < row1 && selection.end.row >= row1)
635 || (j - count > row2 && j <= row2)) 661 || (selection.end.row - count > row2 && selection.end.row <= row2))
636 { 662 {
637 CLEAR_ALL_SELECTION (); 663 CLEAR_ALL_SELECTION ();
638 selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ 664 selection.op = SELECTION_CLEAR;
639 } 665 }
640 else if (j >= row1 && j <= row2) 666 else if (selection.end.row >= row1 && selection.end.row <= row2)
641 { 667 {
642 /* move selected region too */ 668 /* move selected region too */
643 selection.beg.row -= count; 669 selection.beg.row -= count;
644 selection.end.row -= count; 670 selection.end.row -= count;
645 selection.mark.row -= count; 671 selection.mark.row -= count;
680 if (len <= 0) /* sanity */ 706 if (len <= 0) /* sanity */
681 return; 707 return;
682 708
683 unsigned char checksel; 709 unsigned char checksel;
684 unicode_t c; 710 unicode_t c;
685 int row, last_col; 711 int last_col;
686 const unicode_t *strend = str + len; 712 const unicode_t *strend = str + len;
687 713
688 want_refresh = 1; 714 want_refresh = 1;
689 ZERO_SCROLLBACK (); 715 ZERO_SCROLLBACK ();
690 last_col = ncol; 716 last_col = ncol;
705#ifdef DEBUG_STRICT 731#ifdef DEBUG_STRICT
706 assert (screen.cur.col < last_col); 732 assert (screen.cur.col < last_col);
707 assert (screen.cur.row < nrow 733 assert (screen.cur.row < nrow
708 && screen.cur.row >= -nsaved); 734 && screen.cur.row >= -nsaved);
709#endif 735#endif
710 row = screen.cur.row; 736 int row = screen.cur.row;
711 737
712 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 738 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
713 739
714 line_t *line = &ROW(row); 740 line_t *line = &ROW(row);
715 741
717 { 743 {
718 c = *str++; 744 c = *str++;
719 745
720 if (c < 0x20) 746 if (c < 0x20)
721 if (c == C0_LF) 747 if (c == C0_LF)
722 { 748 {
723 if (!line->is_longer ()) /* XXX: think about this */ 749 if (!line->is_longer ()) /* XXX: think about this */
724 max_it (line->l, screen.cur.col); 750 max_it (line->l, screen.cur.col);
725 751
726 screen.flags &= ~Screen_WrapNext; 752 screen.flags &= ~Screen_WrapNext;
727 753
972 998
973 if (count == 0) 999 if (count == 0)
974 return; 1000 return;
975 else if (count > 0) 1001 else if (count > 0)
976 { 1002 {
977 int row = screen.cur.row;
978
979 line_t &l = ROW(row); 1003 line_t &l = ROW(screen.cur.row);
980 rend_t base_rend = l.r[i]; 1004 rend_t base_rend = l.r[i];
981 ht &= l.t[i] == ' '; 1005 ht &= l.t[i] == ' ';
982 1006
983 for (; ++i < ncol; ) 1007 for (; ++i < ncol; )
984 if (tabs[i]) 1008 if (tabs[i])
1059 */ 1083 */
1060#if ENABLE_FRILLS 1084#if ENABLE_FRILLS
1061void 1085void
1062rxvt_term::scr_forwardindex () 1086rxvt_term::scr_forwardindex ()
1063{ 1087{
1064 int row;
1065
1066 if (screen.cur.col < ncol - 1) 1088 if (screen.cur.col < ncol - 1)
1067 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1089 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1068 else 1090 else
1069 { 1091 {
1070 row = screen.cur.row;
1071
1072 if (ROW(row).is_longer ()) //TODO//FIXME//LEN 1092 if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN
1073 ROW(row).l = ncol; 1093 ROW(screen.cur.row).l = ncol;
1074 1094
1075 scr_gotorc (0, 0, R_RELATIVE); 1095 scr_gotorc (0, 0, R_RELATIVE);
1076 scr_insdel_chars (1, DELETE); 1096 scr_insdel_chars (1, DELETE);
1077 scr_gotorc (0, ncol - 1, R_RELATIVE); 1097 scr_gotorc (0, ncol - 1, R_RELATIVE);
1078 } 1098 }
1161 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1181 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1162 */ 1182 */
1163void 1183void
1164rxvt_term::scr_erase_line (int mode) 1184rxvt_term::scr_erase_line (int mode)
1165{ 1185{
1166 unsigned int row, col, num; 1186 unsigned int col, num;
1167 1187
1168 want_refresh = 1; 1188 want_refresh = 1;
1169 ZERO_SCROLLBACK (); 1189 ZERO_SCROLLBACK ();
1170 1190
1171 selection_check (1); 1191 selection_check (1);
1172 1192
1173 row = screen.cur.row; 1193 line_t &line = ROW(screen.cur.row);
1174 1194
1175 switch (mode) 1195 switch (mode)
1176 { 1196 {
1177 case 0: /* erase to end of line */ 1197 case 0: /* erase to end of line */
1178 col = screen.cur.col; 1198 col = screen.cur.col;
1179 num = ncol - col; 1199 num = ncol - col;
1180 min_it (ROW(row).l, col); 1200 min_it (line.l, col);
1181 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) 1201 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)
1182 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) 1202 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur))
1183 CLEAR_SELECTION (); 1203 CLEAR_SELECTION ();
1184 break; 1204 break;
1185 case 1: /* erase to beginning of line */ 1205 case 1: /* erase to beginning of line */
1190 CLEAR_SELECTION (); 1210 CLEAR_SELECTION ();
1191 break; 1211 break;
1192 case 2: /* erase whole line */ 1212 case 2: /* erase whole line */
1193 col = 0; 1213 col = 0;
1194 num = ncol; 1214 num = ncol;
1195 ROW(row).l = 0; 1215 line.l = 0;
1196 if (selection.beg.row <= screen.cur.row 1216 if (selection.beg.row <= screen.cur.row
1197 && selection.end.row >= screen.cur.row) 1217 && selection.end.row >= screen.cur.row)
1198 CLEAR_SELECTION (); 1218 CLEAR_SELECTION ();
1199 break; 1219 break;
1200 default: 1220 default:
1201 return; 1221 return;
1202 } 1222 }
1203 1223
1204 scr_blank_line (ROW(row), col, num, rstyle); 1224 scr_blank_line (line, col, num, rstyle);
1205} 1225}
1206 1226
1207/* ------------------------------------------------------------------------- */ 1227/* ------------------------------------------------------------------------- */
1208/* 1228/*
1209 * Erase part of whole of the screen 1229 * Erase part of whole of the screen
1273 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1293 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1274 } 1294 }
1275 1295
1276 for (; num--; row++) 1296 for (; num--; row++)
1277 { 1297 {
1298 ROW (row).l = 0;
1278 scr_blank_screen_mem (ROW (row), rstyle); 1299 scr_blank_screen_mem (ROW (row), rstyle);
1279 ROW (row).l = 0;
1280 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1300 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1281 } 1301 }
1282} 1302}
1283 1303
1284#if ENABLE_FRILLS 1304#if ENABLE_FRILLS
2170 * Determine the attributes for the string 2190 * Determine the attributes for the string
2171 */ 2191 */
2172 int fore = GET_FGCOLOR (rend); // desired foreground 2192 int fore = GET_FGCOLOR (rend); // desired foreground
2173 int back = GET_BGCOLOR (rend); // desired background 2193 int back = GET_BGCOLOR (rend); // desired background
2174 2194
2175 // only do special processing if any attributes are set, which is rare 2195 // only do special processing if any attributes are set, which is unlikely
2176 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2196 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))
2177 { 2197 {
2178#if ENABLE_STYLES 2198#if ENABLE_STYLES
2179 // force redraw after "careful" characters to avoid pixel droppings 2199 // force redraw after "careful" characters to avoid pixel droppings
2180 if (srp[col] & RS_Careful && col < ncol - 1 && 0) 2200 if (srp[col] & RS_Careful && col < ncol - 1 && 0)
2442 row = selection.beg.row; 2462 row = selection.beg.row;
2443 } 2463 }
2444 else 2464 else
2445 { 2465 {
2446 col = 0; 2466 col = 0;
2447 row = view_start; 2467 row = -view_start;
2448 } 2468 }
2449 2469
2450 for (; row < min (selection.end.row, view_end); row++, col = 0) 2470 for (; row < min (selection.end.row, view_end); row++, col = 0)
2451 for (rend_t *srp = ROW(row).r; col < ncol; col++) 2471 for (rend_t *srp = ROW(row).r; col < ncol; col++)
2452 srp[col] ^= RS_RVid; 2472 srp[col] ^= RS_RVid;
3656 for (int y = ov_h; y--; ) 3676 for (int y = ov_h; y--; )
3657 { 3677 {
3658 text_t *t1 = ov_text[y]; 3678 text_t *t1 = ov_text[y];
3659 rend_t *r1 = ov_rend[y]; 3679 rend_t *r1 = ov_rend[y];
3660 3680
3661 text_t *t2 = ROW(y - view_start).t + ov_x; 3681 text_t *t2 = ROW(y + ov_y - view_start).t + ov_x;
3662 rend_t *r2 = ROW(y - view_start).r + ov_x; 3682 rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x;
3663 3683
3664 for (int x = ov_w; x--; ) 3684 for (int x = ov_w; x--; )
3665 { 3685 {
3666 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3686 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3667 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); 3687 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines