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.195 by root, Mon Dec 26 23:02:34 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);
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 < ncol ? llen : MOD (llen - 1, ncol) + 1;
357 printf ("qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D
343 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); 358 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
344 } 359 }
360 while (p != pend && q > 0);
345 361
346 term_start = total_rows - nrow; 362 term_start = total_rows - nrow;
347 view_start = 0;
348 nsaved = term_start - q; 363 nsaved = term_start - q;
349 364
350 // make sure all terminal lines exist 365 // make sure all terminal lines exist
351 while (nsaved < 0) 366 while (nsaved < 0)
352 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); 367 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
369 { 384 {
370 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); 385 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
371 } 386 }
372 387
373 term_start = 0; 388 term_start = 0;
374 view_start = 0;
375 } 389 }
376 390
377#ifdef DEBUG_STRICT 391#ifdef DEBUG_STRICT //TODO: remove
378 for (int i = -nsaved; i < nrow; i++) 392 for (int i = -nsaved; i < nrow; i++)
379 assert (ROW (i).t); 393 assert (ROW (i).t);
380#endif 394#endif
381 395
382 free (old_buf); 396 free (old_buf);
607 { 621 {
608 selection.beg.row -= count; 622 selection.beg.row -= count;
609 selection.end.row -= count; 623 selection.end.row -= count;
610 selection.mark.row -= count; 624 selection.mark.row -= count;
611 625
612 selection_check (0); 626 if (selection.beg.row < -nsaved
627 || selection.end.row < -nsaved
628 || selection.mark.row < -nsaved)
629 {
630 CLEAR_ALL_SELECTION ();
631 selection.op = SELECTION_CLEAR;
632 }
613 } 633 }
614 634
615 for (int i = count; i--; ) 635 for (int i = count; i--; )
636 {
637 ROW(row2 - i).l = 0;
616 scr_blank_screen_mem (ROW(row2 - i), rstyle); 638 scr_blank_screen_mem (ROW(row2 - i), rstyle);
639 }
617 640
618 if ((options & Opt_scrollWithBuffer) 641 if ((options & Opt_scrollWithBuffer)
619 && view_start != 0 642 && view_start != 0
620 && view_start != saveLines) 643 && view_start != saveLines)
621 scr_page (UP, count); 644 scr_page (UP, count);
622 } 645 }
623 else 646 else
624 { 647 {
625 if (selection.op && current_screen == selection.screen) 648 if (selection.op && current_screen == selection.screen)
626 { 649 {
627 int i = selection.beg.row; 650 if ((selection.beg.row < row1 && selection.end.row > row1)
628 int j = selection.end.row; 651 || (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) 652 || (selection.beg.row - count < row1 && selection.beg.row >= row1)
633 || (i - count > row2 && i <= row2) 653 || (selection.beg.row - count > row2 && selection.beg.row <= row2)
634 || (j - count < row1 && j >= row1) 654 || (selection.end.row - count < row1 && selection.end.row >= row1)
635 || (j - count > row2 && j <= row2)) 655 || (selection.end.row - count > row2 && selection.end.row <= row2))
636 { 656 {
637 CLEAR_ALL_SELECTION (); 657 CLEAR_ALL_SELECTION ();
638 selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ 658 selection.op = SELECTION_CLEAR;
639 } 659 }
640 else if (j >= row1 && j <= row2) 660 else if (selection.end.row >= row1 && selection.end.row <= row2)
641 { 661 {
642 /* move selected region too */ 662 /* move selected region too */
643 selection.beg.row -= count; 663 selection.beg.row -= count;
644 selection.end.row -= count; 664 selection.end.row -= count;
645 selection.mark.row -= count; 665 selection.mark.row -= count;
680 if (len <= 0) /* sanity */ 700 if (len <= 0) /* sanity */
681 return; 701 return;
682 702
683 unsigned char checksel; 703 unsigned char checksel;
684 unicode_t c; 704 unicode_t c;
685 int row, last_col; 705 int last_col;
686 const unicode_t *strend = str + len; 706 const unicode_t *strend = str + len;
687 707
688 want_refresh = 1; 708 want_refresh = 1;
689 ZERO_SCROLLBACK (); 709 ZERO_SCROLLBACK ();
690 last_col = ncol; 710 last_col = ncol;
705#ifdef DEBUG_STRICT 725#ifdef DEBUG_STRICT
706 assert (screen.cur.col < last_col); 726 assert (screen.cur.col < last_col);
707 assert (screen.cur.row < nrow 727 assert (screen.cur.row < nrow
708 && screen.cur.row >= -nsaved); 728 && screen.cur.row >= -nsaved);
709#endif 729#endif
710 row = screen.cur.row; 730 int row = screen.cur.row;
711 731
712 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 732 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
713 733
714 line_t *line = &ROW(row); 734 line_t *line = &ROW(row);
715 735
717 { 737 {
718 c = *str++; 738 c = *str++;
719 739
720 if (c < 0x20) 740 if (c < 0x20)
721 if (c == C0_LF) 741 if (c == C0_LF)
722 { 742 {
723 if (!line->is_longer ()) /* XXX: think about this */ 743 if (!line->is_longer ()) /* XXX: think about this */
724 max_it (line->l, screen.cur.col); 744 max_it (line->l, screen.cur.col);
725 745
726 screen.flags &= ~Screen_WrapNext; 746 screen.flags &= ~Screen_WrapNext;
727 747
972 992
973 if (count == 0) 993 if (count == 0)
974 return; 994 return;
975 else if (count > 0) 995 else if (count > 0)
976 { 996 {
977 int row = screen.cur.row;
978
979 line_t &l = ROW(row); 997 line_t &l = ROW(screen.cur.row);
980 rend_t base_rend = l.r[i]; 998 rend_t base_rend = l.r[i];
981 ht &= l.t[i] == ' '; 999 ht &= l.t[i] == ' ';
982 1000
983 for (; ++i < ncol; ) 1001 for (; ++i < ncol; )
984 if (tabs[i]) 1002 if (tabs[i])
1059 */ 1077 */
1060#if ENABLE_FRILLS 1078#if ENABLE_FRILLS
1061void 1079void
1062rxvt_term::scr_forwardindex () 1080rxvt_term::scr_forwardindex ()
1063{ 1081{
1064 int row;
1065
1066 if (screen.cur.col < ncol - 1) 1082 if (screen.cur.col < ncol - 1)
1067 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1083 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1068 else 1084 else
1069 { 1085 {
1070 row = screen.cur.row;
1071
1072 if (ROW(row).is_longer ()) //TODO//FIXME//LEN 1086 if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN
1073 ROW(row).l = ncol; 1087 ROW(screen.cur.row).l = ncol;
1074 1088
1075 scr_gotorc (0, 0, R_RELATIVE); 1089 scr_gotorc (0, 0, R_RELATIVE);
1076 scr_insdel_chars (1, DELETE); 1090 scr_insdel_chars (1, DELETE);
1077 scr_gotorc (0, ncol - 1, R_RELATIVE); 1091 scr_gotorc (0, ncol - 1, R_RELATIVE);
1078 } 1092 }
1161 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1175 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1162 */ 1176 */
1163void 1177void
1164rxvt_term::scr_erase_line (int mode) 1178rxvt_term::scr_erase_line (int mode)
1165{ 1179{
1166 unsigned int row, col, num; 1180 unsigned int col, num;
1167 1181
1168 want_refresh = 1; 1182 want_refresh = 1;
1169 ZERO_SCROLLBACK (); 1183 ZERO_SCROLLBACK ();
1170 1184
1171 selection_check (1); 1185 selection_check (1);
1172 1186
1173 row = screen.cur.row; 1187 line_t &line = ROW(screen.cur.row);
1174 1188
1175 switch (mode) 1189 switch (mode)
1176 { 1190 {
1177 case 0: /* erase to end of line */ 1191 case 0: /* erase to end of line */
1178 col = screen.cur.col; 1192 col = screen.cur.col;
1179 num = ncol - col; 1193 num = ncol - col;
1180 min_it (ROW(row).l, col); 1194 min_it (line.l, col);
1181 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) 1195 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)
1182 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) 1196 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur))
1183 CLEAR_SELECTION (); 1197 CLEAR_SELECTION ();
1184 break; 1198 break;
1185 case 1: /* erase to beginning of line */ 1199 case 1: /* erase to beginning of line */
1190 CLEAR_SELECTION (); 1204 CLEAR_SELECTION ();
1191 break; 1205 break;
1192 case 2: /* erase whole line */ 1206 case 2: /* erase whole line */
1193 col = 0; 1207 col = 0;
1194 num = ncol; 1208 num = ncol;
1195 ROW(row).l = 0; 1209 line.l = 0;
1196 if (selection.beg.row <= screen.cur.row 1210 if (selection.beg.row <= screen.cur.row
1197 && selection.end.row >= screen.cur.row) 1211 && selection.end.row >= screen.cur.row)
1198 CLEAR_SELECTION (); 1212 CLEAR_SELECTION ();
1199 break; 1213 break;
1200 default: 1214 default:
1201 return; 1215 return;
1202 } 1216 }
1203 1217
1204 scr_blank_line (ROW(row), col, num, rstyle); 1218 scr_blank_line (line, col, num, rstyle);
1205} 1219}
1206 1220
1207/* ------------------------------------------------------------------------- */ 1221/* ------------------------------------------------------------------------- */
1208/* 1222/*
1209 * Erase part of whole of the screen 1223 * Erase part of whole of the screen
1273 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1287 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1274 } 1288 }
1275 1289
1276 for (; num--; row++) 1290 for (; num--; row++)
1277 { 1291 {
1292 ROW (row).l = 0;
1278 scr_blank_screen_mem (ROW (row), rstyle); 1293 scr_blank_screen_mem (ROW (row), rstyle);
1279 ROW (row).l = 0;
1280 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1294 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1281 } 1295 }
1282} 1296}
1283 1297
1284#if ENABLE_FRILLS 1298#if ENABLE_FRILLS
2442 row = selection.beg.row; 2456 row = selection.beg.row;
2443 } 2457 }
2444 else 2458 else
2445 { 2459 {
2446 col = 0; 2460 col = 0;
2447 row = view_start; 2461 row = -view_start;
2448 } 2462 }
2449 2463
2450 for (; row < min (selection.end.row, view_end); row++, col = 0) 2464 for (; row < min (selection.end.row, view_end); row++, col = 0)
2451 for (rend_t *srp = ROW(row).r; col < ncol; col++) 2465 for (rend_t *srp = ROW(row).r; col < ncol; col++)
2452 srp[col] ^= RS_RVid; 2466 srp[col] ^= RS_RVid;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines