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.199 by root, Tue Dec 27 01:46:06 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)
2428 2448
2429#if ENABLE_FRILLS 2449#if ENABLE_FRILLS
2430 if (selection.rect) 2450 if (selection.rect)
2431 { 2451 {
2432 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) 2452 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++)
2453 {
2454 text_t *stp = ROW(row).t;
2455 rend_t *srp = ROW(row).r;
2456
2433 for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) 2457 for (col = selection.beg.col; col < selection.end.col; col++)
2434 srp[col] ^= RS_RVid; 2458 srp[col] ^= RS_RVid;
2459
2460 while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col])))
2461 srp[col] ^= RS_RVid | RS_Uline;
2462 }
2435 } 2463 }
2436 else 2464 else
2437#endif 2465#endif
2438 { 2466 {
2439 if (selection.beg.row >= -view_start) 2467 if (selection.beg.row >= -view_start)
2442 row = selection.beg.row; 2470 row = selection.beg.row;
2443 } 2471 }
2444 else 2472 else
2445 { 2473 {
2446 col = 0; 2474 col = 0;
2447 row = view_start; 2475 row = -view_start;
2448 } 2476 }
2449 2477
2450 for (; row < min (selection.end.row, view_end); row++, col = 0) 2478 for (; row < min (selection.end.row, view_end); row++, col = 0)
2451 for (rend_t *srp = ROW(row).r; col < ncol; col++) 2479 for (rend_t *srp = ROW(row).r; col < ncol; col++)
2452 srp[col] ^= RS_RVid; 2480 srp[col] ^= RS_RVid;
2867 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN 2895 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN
2868 2896
2869 col = max (col, 0); 2897 col = max (col, 0);
2870 2898
2871 if (row == selection.end.row || selection.rect) 2899 if (row == selection.end.row || selection.rect)
2872 end_col = min (end_col, selection.end.col); 2900 min_it (end_col, selection.end.col);
2873 2901
2874 t = ROW(row).t + col; 2902 t = ROW(row).t + col;
2875 for (; col < end_col; col++) 2903 for (; col < end_col; col++)
2876 { 2904 {
2877 if (*t == NOCHAR) 2905 if (*t == NOCHAR)
2895#endif 2923#endif
2896 else 2924 else
2897 new_selection_text[ofs++] = *t++; 2925 new_selection_text[ofs++] = *t++;
2898 } 2926 }
2899 2927
2928#if ENABLE_FRILLS
2929 if (selection.rect)
2930 {
2931 while (ofs
2932 && new_selection_text[ofs - 1] != C0_LF
2933 && unicode::is_space (new_selection_text[ofs - 1]))
2934 --ofs;
2935
2936 new_selection_text[ofs++] = C0_LF;
2937 }
2938 else
2939#endif
2900 if (!ROW(row).is_longer () && row != selection.end.row) 2940 if (!ROW(row).is_longer () && row != selection.end.row)
2901 new_selection_text[ofs++] = C0_LF; 2941 new_selection_text[ofs++] = C0_LF;
2902 } 2942 }
2903 2943
2904 if (end_col != selection.end.col) 2944 if (end_col != selection.end.col)
2905 new_selection_text[ofs++] = C0_LF; 2945 new_selection_text[ofs++] = C0_LF;
2906 2946
3328 { 3368 {
3329 stp = ROW(end_row).t; 3369 stp = ROW(end_row).t;
3330 3370
3331 while (--end_col >= 0) 3371 while (--end_col >= 0)
3332 { 3372 {
3333 if (stp[end_col] != ' ' 3373 if (stp[end_col] != NOCHAR
3334 && stp[end_col] != '\t' 3374 && !unicode::is_space (stp[end_col]))
3335 && stp[end_col] != NOCHAR)
3336 break; 3375 break;
3337 } 3376 }
3338 3377
3339 if (end_col >= 0 3378 if (end_col >= 0
3340 || !ROW(end_row - 1).is_longer ()) 3379 || !ROW(end_row - 1).is_longer ())
3656 for (int y = ov_h; y--; ) 3695 for (int y = ov_h; y--; )
3657 { 3696 {
3658 text_t *t1 = ov_text[y]; 3697 text_t *t1 = ov_text[y];
3659 rend_t *r1 = ov_rend[y]; 3698 rend_t *r1 = ov_rend[y];
3660 3699
3661 text_t *t2 = ROW(y - view_start).t + ov_x; 3700 text_t *t2 = ROW(y + ov_y - view_start).t + ov_x;
3662 rend_t *r2 = ROW(y - view_start).r + ov_x; 3701 rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x;
3663 3702
3664 for (int x = ov_w; x--; ) 3703 for (int x = ov_w; x--; )
3665 { 3704 {
3666 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3705 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3667 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); 3706 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