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.175 by root, Tue Dec 20 19:30:59 2005 UTC vs.
Revision 1.182 by root, Wed Dec 21 10:35:47 2005 UTC

83#define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ 83#define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \
84 ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) 84 ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col)
85#define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ 85#define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \
86 ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) 86 ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col)
87 87
88#define LINENO(n) (((n) + term_start + total_rows) % total_rows)
89#define ROW(n) (save [LINENO (n)])
90
91/* 88/*
92 * CLEAR_ROWS : clear <num> rows starting from row <row> 89 * CLEAR_ROWS : clear <num> rows starting from row <row>
93 * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> 90 * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y>
94 * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour 91 * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour
95 */ 92 */
251 if (nrow < prev_nrow) 248 if (nrow < prev_nrow)
252 { 249 {
253 /* delete rows */ 250 /* delete rows */
254 k = min (nsaved, prev_nrow - nrow); 251 k = min (nsaved, prev_nrow - nrow);
255 // k = max (0, - ( (nrow - 1) - r->screen.cur.row)); // mmc's http://maruska.dyndns.org/wiki/scrolling-bug //make configurable? //D TODO 252 // k = max (0, - ( (nrow - 1) - r->screen.cur.row)); // mmc's http://maruska.dyndns.org/wiki/scrolling-bug //make configurable? //D TODO
256 scr_scroll_text (0, (int)prev_nrow - 1, k, 1); 253 scr_scroll_text (0, (int)prev_nrow - 1, k);
257 254
258 for (p = nrow; p < prev_nrow; p++) 255 for (p = nrow; p < prev_nrow; p++)
259 { 256 {
260 lfree (ROW(p)); 257 lfree (ROW(p));
261 lfree (swap_save[p]); 258 lfree (swap_save[p]);
289 drawn[p].clear (); scr_blank_screen_mem (drawn[p], DEFAULT_RSTYLE); 286 drawn[p].clear (); scr_blank_screen_mem (drawn[p], DEFAULT_RSTYLE);
290 } 287 }
291 288
292 if (k > 0) 289 if (k > 0)
293 { 290 {
294 scr_scroll_text (0, (int)nrow - 1, -k, 1); 291 scr_scroll_text (0, (int)nrow - 1, -k);
295 screen.cur.row += k; 292 screen.cur.row += k;
296 screen.s_cur.row += k; 293 screen.s_cur.row += k;
297 nsaved -= k; 294 nsaved -= k;
298 } 295 }
299 296
538 * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l 535 * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l
539 */ 536 */
540int 537int
541rxvt_term::scr_change_screen (int scrn) 538rxvt_term::scr_change_screen (int scrn)
542{ 539{
543 int i;
544#if NSCREENS
545 int offset;
546#endif
547
548 want_refresh = 1; 540 want_refresh = 1;
549
550 view_start = 0; 541 view_start = 0;
551 542
552 if (current_screen == scrn) 543 if (current_screen == scrn)
553 return scrn; 544 return scrn;
554 545
555 selection_check (2); /* check for boundary cross */ 546 selection_check (2); /* check for boundary cross */
556 547
557 i = current_screen; current_screen = scrn; scrn = i; 548 int i = current_screen; current_screen = scrn; scrn = i;
558 549
559 SWAP_IT (screen.cur.row, swap.cur.row, int16_t); 550 ::swap (screen.cur.row, swap.cur.row);
560 SWAP_IT (screen.cur.col, swap.cur.col, int16_t); 551 ::swap (screen.cur.col, swap.cur.col);
561 MAX_IT (screen.cur.row, 0); 552
562 MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); 553 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
563 MAX_IT (screen.cur.col, 0); 554 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
564 MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1);
565 555
566#if NSCREENS 556#if NSCREENS
567 if (options & Opt_secondaryScreen) 557 if (options & Opt_secondaryScreen)
568 { 558 {
569 num_scr = 0; 559 num_scr = 0;
570 offset = saveLines;
571 560
572 for (i = prev_nrow; i--;) 561 for (int i = nrow; i--; )
573 SWAP_IT (ROW(i), swap_save[i], line_t); 562 ::swap (ROW(i), swap_save[i]);
574 563
575 SWAP_IT (screen.charset, swap.charset, int16_t); 564 ::swap (screen.charset, swap.charset);
576 SWAP_IT (screen.flags, swap.flags, int); 565 ::swap (screen.flags, swap.flags);
577 screen.flags |= Screen_VisibleCursor; 566 screen.flags |= Screen_VisibleCursor;
578 swap.flags |= Screen_VisibleCursor; 567 swap.flags |= Screen_VisibleCursor;
579 } 568 }
580 else 569 else
581#endif 570#endif
582 if (options & Opt_secondaryScroll) 571 if (options & Opt_secondaryScroll)
583 scr_scroll_text (0, prev_nrow - 1, prev_nrow, 0); 572 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
584 573
585 return scrn; 574 return scrn;
586} 575}
587 576
588// clear WrapNext indicator, solidifying position on next line 577// clear WrapNext indicator, solidifying position on next line
595 screen.flags &= ~Screen_WrapNext; 584 screen.flags &= ~Screen_WrapNext;
596 585
597 screen.cur.col = 0; 586 screen.cur.col = 0;
598 587
599 if (screen.cur.row == screen.bscroll) 588 if (screen.cur.row == screen.bscroll)
600 scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); 589 scr_scroll_text (screen.tscroll, screen.bscroll, 1);
601 else if (screen.cur.row < nrow - 1) 590 else if (screen.cur.row < nrow - 1)
602 screen.cur.row++; 591 screen.cur.row++;
603} 592}
604 593
605/* ------------------------------------------------------------------------- */ 594/* ------------------------------------------------------------------------- */
636/* ------------------------------------------------------------------------- */ 625/* ------------------------------------------------------------------------- */
637/* 626/*
638 * Scroll text between <row1> and <row2> inclusive, by <count> lines 627 * Scroll text between <row1> and <row2> inclusive, by <count> lines
639 * count positive ==> scroll up 628 * count positive ==> scroll up
640 * count negative ==> scroll down 629 * count negative ==> scroll down
641 * spec == 0 for normal routines
642 */ 630 */
643int 631int
644rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) 632rxvt_term::scr_scroll_text (int row1, int row2, int count)
645{ 633{
646 int i, j;
647
648 if (count == 0 || (row1 > row2)) 634 if (count == 0 || (row1 > row2))
649 return 0; 635 return 0;
650 636
651 want_refresh = 1; 637 want_refresh = 1;
638 num_scr += count;
652 639
653 if (row1 == 0 && count > 0 640 if (count > 0
641 && row1 == 0
642 && row2 == nrow - 1
654 && (current_screen == PRIMARY || options & Opt_secondaryScroll)) 643 && (current_screen == PRIMARY || options & Opt_secondaryScroll))
655 { 644 {
656 nsaved = min (nsaved + count, saveLines); 645 nsaved = min (nsaved + count, saveLines);
657 term_start = (term_start + count) % total_rows; 646 term_start = (term_start + count) % total_rows;
658 647
659 if (selection.op && current_screen == selection.screen) 648 if (selection.op && current_screen == selection.screen)
660 { 649 {
661 selection.beg.row -= count; 650 selection.beg.row -= count;
662 selection.end.row -= count; 651 selection.end.row -= count;
663 selection.mark.row -= count; 652 selection.mark.row -= count;
653
654 selection_check (0);
664 } 655 }
665 656
666 for (int i = count; i--; ) 657 for (int i = count; i--; )
667 scr_blank_screen_mem (ROW(row2 - i), rstyle); 658 scr_blank_screen_mem (ROW(row2 - i), rstyle);
668 659
671 && view_start != saveLines) 662 && view_start != saveLines)
672 scr_page (UP, count); 663 scr_page (UP, count);
673 } 664 }
674 else 665 else
675 { 666 {
676 if (!spec)
677 row1 += saveLines;
678
679 row2 += saveLines;
680
681 if (selection.op && current_screen == selection.screen) 667 if (selection.op && current_screen == selection.screen)
682 { 668 {
683 i = selection.beg.row + saveLines; 669 int i = selection.beg.row;
684 j = selection.end.row + saveLines; 670 int j = selection.end.row;
685 671
686 if ((i < row1 && j > row1) 672 if ((i < row1 && j > row1)
687 || (i < row2 && j > row2) 673 || (i < row2 && j > row2)
688 || (i - count < row1 && i >= row1) 674 || (i - count < row1 && i >= row1)
689 || (i - count > row2 && i <= row2) 675 || (i - count > row2 && i <= row2)
697 { 683 {
698 /* move selected region too */ 684 /* move selected region too */
699 selection.beg.row -= count; 685 selection.beg.row -= count;
700 selection.end.row -= count; 686 selection.end.row -= count;
701 selection.mark.row -= count; 687 selection.mark.row -= count;
688
689 selection_check (0);
702 } 690 }
703 } 691 }
704 692
705 selection_check (0); /* _after_ nsaved update */ 693 // use a simple and robust scrolling algorithm, this
694 // part of scr_scroll_text is not time-critical.
706 695
707 num_scr += count;
708 j = count;
709
710 if (count < 0)
711 count = -count;
712
713 i = row2 - row1 + 1; 696 int rows = row2 - row1 + 1;
714 MIN_IT (count, i);
715 697
716 if (j > 0) 698 for (int row = 0; row < rows; row++)
717 {
718 /* scroll up */
719
720 /* Copy lines that will get clobbered by the rotation */
721 memcpy (buf, save + row1, count * sizeof (line_t));
722
723 /* Rotate lines */
724 i = row2 - row1 - count + 1;
725 memmove (save + row1, save + row1 + count, i * sizeof (line_t));
726
727 j = row2 - count + 1, i = count;
728 } 699 {
729 else /* if (j < 0) */ 700 buf [row] = ROW(row1 + (row + count + rows) % rows);
701
702 if (!IN_RANGE_EXC (row + count, 0, rows))
703 scr_blank_screen_mem (buf [row], rstyle);
730 { 704 }
731 /* scroll down */
732 705
733 /* Copy lines that will get clobbered by the rotation */ 706 for (int row = 0; row < rows; row++)
734 for (i = 0, j = row2; i < count; i++, j--) 707 ROW(row1 + row) = buf [row];
735 buf[i] = save[j];
736
737 /* Rotate lines */
738 for (j = row2, i = j - count; i >= row1; i--, j--)
739 save[j] = save[i];
740
741 j = row1, i = count;
742 count = -count;
743 }
744
745 /* Resurrect lines */
746 memcpy (save + j, buf, i * sizeof (line_t));
747
748 if (!spec) /* line length may not equal ncol */
749 for (; i--; j++)
750 scr_blank_screen_mem (save[j], rstyle);
751 } 708 }
752 709
753 return count; 710 return count;
754} 711}
755 712
778 if ((nlines > 0) 735 if ((nlines > 0)
779 && (screen.tscroll == 0) 736 && (screen.tscroll == 0)
780 && (screen.bscroll == (nrow - 1))) 737 && (screen.bscroll == (nrow - 1)))
781 { 738 {
782 /* _at least_ this many lines need to be scrolled */ 739 /* _at least_ this many lines need to be scrolled */
783 scr_scroll_text (screen.tscroll, screen.bscroll, nlines, 0); 740 scr_scroll_text (screen.tscroll, screen.bscroll, nlines);
784 screen.cur.row -= nlines; 741 screen.cur.row -= nlines;
785 } 742 }
786 } 743 }
787 744
788#ifdef DEBUG_STRICT 745#ifdef DEBUG_STRICT
811 MAX_IT (line->l, screen.cur.col); 768 MAX_IT (line->l, screen.cur.col);
812 769
813 screen.flags &= ~Screen_WrapNext; 770 screen.flags &= ~Screen_WrapNext;
814 771
815 if (screen.cur.row == screen.bscroll) 772 if (screen.cur.row == screen.bscroll)
816 scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); 773 scr_scroll_text (screen.tscroll, screen.bscroll, 1);
817 else if (screen.cur.row < (nrow - 1)) 774 else if (screen.cur.row < (nrow - 1))
818 row = ++screen.cur.row; 775 row = ++screen.cur.row;
819 776
820 line = &ROW(row); /* _must_ refresh */ 777 line = &ROW(row); /* _must_ refresh */
821 continue; 778 continue;
1234 1191
1235 screen.flags &= ~Screen_WrapNext; 1192 screen.flags &= ~Screen_WrapNext;
1236 1193
1237 if ((screen.cur.row == screen.bscroll && direction == UP) 1194 if ((screen.cur.row == screen.bscroll && direction == UP)
1238 || (screen.cur.row == screen.tscroll && direction == DN)) 1195 || (screen.cur.row == screen.tscroll && direction == DN))
1239 scr_scroll_text (screen.tscroll, screen.bscroll, dirn, 0); 1196 scr_scroll_text (screen.tscroll, screen.bscroll, dirn);
1240 else 1197 else
1241 screen.cur.row += dirn; 1198 screen.cur.row += dirn;
1242 1199
1243 MAX_IT (screen.cur.row, 0); 1200 MAX_IT (screen.cur.row, 0);
1244 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 1201 MIN_IT (screen.cur.row, (int32_t)nrow - 1);
1305 */ 1262 */
1306void 1263void
1307rxvt_term::scr_erase_screen (int mode) 1264rxvt_term::scr_erase_screen (int mode)
1308{ 1265{
1309 int num; 1266 int num;
1310 int32_t row, row_offset; 1267 int32_t row;
1311 rend_t ren; 1268 rend_t ren;
1312 XGCValues gcvalue; 1269 XGCValues gcvalue;
1313 1270
1314 want_refresh = 1; 1271 want_refresh = 1;
1315 ZERO_SCROLLBACK (); 1272 ZERO_SCROLLBACK ();
1316
1317 row_offset = (int32_t)saveLines;
1318 1273
1319 switch (mode) 1274 switch (mode)
1320 { 1275 {
1321 case 0: /* erase to end of screen */ 1276 case 0: /* erase to end of screen */
1322 selection_check (1); 1277 selection_check (1);
1367 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1322 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1368 } 1323 }
1369 1324
1370 for (; num--; row++) 1325 for (; num--; row++)
1371 { 1326 {
1372 scr_blank_screen_mem (save[row + row_offset], rstyle); 1327 scr_blank_screen_mem (ROW (row), rstyle);
1373 save[row + row_offset].l = 0; 1328 ROW (row).l = 0;
1374 scr_blank_line (drawn[row], 0, ncol, ren); 1329 scr_blank_line (drawn[row], 0, ncol, ren);
1375 } 1330 }
1376} 1331}
1377 1332
1378#if ENABLE_FRILLS 1333#if ENABLE_FRILLS
1392 * XTERM_SEQ: Screen Alignment Test: ESC # 8 1347 * XTERM_SEQ: Screen Alignment Test: ESC # 8
1393 */ 1348 */
1394void 1349void
1395rxvt_term::scr_E () 1350rxvt_term::scr_E ()
1396{ 1351{
1397 int i, j, k;
1398 rend_t *r1, fs; 1352 rend_t fs;
1399 1353
1400 want_refresh = 1; 1354 want_refresh = 1;
1401 ZERO_SCROLLBACK (); 1355 ZERO_SCROLLBACK ();
1402 1356
1403 num_scr_allow = 0; 1357 num_scr_allow = 0;
1404 selection_check (3); 1358 selection_check (3);
1405 1359
1406 fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); 1360 fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E'));
1407 for (k = saveLines, i = nrow; i--; k++) 1361 for (int row = nrow; row--; )
1408 { 1362 {
1409 line_t &line = save[k]; 1363 line_t &line = ROW(row);
1410 1364
1411 fill_text (line.t, 'E', ncol); 1365 fill_text (line.t, 'E', ncol);
1366 rend_t *r1 = line.r;
1412 1367
1413 for (r1 = line.r, j = ncol; j--; ) 1368 for (int j = ncol; j--; )
1414 *r1++ = fs; 1369 *r1++ = fs;
1415 1370
1416 line.l = ncol; /* make the `E's selectable */ 1371 line.l = ncol; /* make the `E's selectable */
1417 } 1372 }
1418} 1373}
1442 count = end; 1397 count = end;
1443 } 1398 }
1444 1399
1445 scr_do_wrap (); 1400 scr_do_wrap ();
1446 1401
1447 scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count, 0); 1402 scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count);
1448} 1403}
1449 1404
1450/* ------------------------------------------------------------------------- */ 1405/* ------------------------------------------------------------------------- */
1451/* 1406/*
1452 * Insert/Delete <count> characters from the current position 1407 * Insert/Delete <count> characters from the current position
1466 scr_do_wrap (); 1421 scr_do_wrap ();
1467 1422
1468 selection_check (1); 1423 selection_check (1);
1469 MIN_IT (count, (ncol - screen.cur.col)); 1424 MIN_IT (count, (ncol - screen.cur.col));
1470 1425
1471 row = screen.cur.row + saveLines; 1426 row = screen.cur.row;
1472 1427
1473 line_t *line = save + row; 1428 line_t *line = &ROW(row);
1474 1429
1475 switch (insdel) 1430 switch (insdel)
1476 { 1431 {
1477 case INSERT: 1432 case INSERT:
1478 for (col = ncol - 1; (col - count) >= screen.cur.col; col--) 1433 for (col = ncol - 1; (col - count) >= screen.cur.col; col--)
1499 selection.mark.col += count; /* XXX: yes? */ 1454 selection.mark.col += count; /* XXX: yes? */
1500 selection.end.col += count; 1455 selection.end.col += count;
1501 } 1456 }
1502 } 1457 }
1503 1458
1504 scr_blank_line (save[row], screen.cur.col, count, rstyle); 1459 scr_blank_line (*line, screen.cur.col, count, rstyle);
1505 break; 1460 break;
1506 1461
1507 case ERASE: 1462 case ERASE:
1508 screen.cur.col += count; /* don't worry if > ncol */ 1463 screen.cur.col += count; /* don't worry if > ncol */
1509 selection_check (1); 1464 selection_check (1);
1510 screen.cur.col -= count; 1465 screen.cur.col -= count;
1511 scr_blank_line (save[row], screen.cur.col, count, rstyle); 1466 scr_blank_line (*line, screen.cur.col, count, rstyle);
1512 break; 1467 break;
1513 1468
1514 case DELETE: 1469 case DELETE:
1515 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1470 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask);
1516 1471
1523 scr_blank_line (*line, ncol - count, count, tr); 1478 scr_blank_line (*line, ncol - count, count, tr);
1524 1479
1525 if (line->is_longer ()) /* break line continuation */ 1480 if (line->is_longer ()) /* break line continuation */
1526 line->l = ncol; 1481 line->l = ncol;
1527 1482
1528 line->l -= count; 1483 line->l = max (line->l - count, 0);
1529 MAX_IT (line->l, 0);
1530 1484
1531 if (selection.op && current_screen == selection.screen 1485 if (selection.op && current_screen == selection.screen
1532 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1486 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1533 { 1487 {
1534 if (selection.end.row != screen.cur.row 1488 if (selection.end.row != screen.cur.row
1663 XGCValues gcvalue; 1617 XGCValues gcvalue;
1664 1618
1665 if (rvideo != mode) 1619 if (rvideo != mode)
1666 { 1620 {
1667 rvideo = mode; 1621 rvideo = mode;
1668 SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); 1622 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1669#if XPM_BACKGROUND 1623#if XPM_BACKGROUND
1670 if (bgPixmap.pixmap == None) 1624 if (bgPixmap.pixmap == None)
1671#endif 1625#endif
1672#if TRANSPARENT 1626#if TRANSPARENT
1673 if (! (options & Opt_transparent) || am_transparent == 0) 1627 if (! (options & Opt_transparent) || am_transparent == 0)
1941/* ARGSUSED */ 1895/* ARGSUSED */
1942void 1896void
1943rxvt_term::scr_printscreen (int fullhist) 1897rxvt_term::scr_printscreen (int fullhist)
1944{ 1898{
1945#ifdef PRINTPIPE 1899#ifdef PRINTPIPE
1946 int i, r1, nrows, row_offset; 1900 int nrows, row_start;
1947 FILE *fd; 1901 FILE *fd;
1948 1902
1949 if ((fd = popen_printer ()) == NULL) 1903 if ((fd = popen_printer ()) == NULL)
1950 return; 1904 return;
1951 1905
1952 nrows = nrow;
1953 row_offset = saveLines;
1954
1955 if (!fullhist) 1906 if (fullhist)
1956 row_offset -= view_start; 1907 {
1908 nrows = nrow + nsaved;
1909 row_start = -nsaved;
1910 }
1957 else 1911 else
1958 { 1912 {
1959 nrows += nsaved; 1913 nrows = nrow;
1960 row_offset -= nsaved; 1914 row_start = -view_start;
1961 } 1915 }
1962 1916
1963 wctomb (0, 0); 1917 wctomb (0, 0);
1964 1918
1965 for (r1 = 0; r1 < nrows; r1++) 1919 for (int r1 = 0; r1 < nrows; r1++)
1966 { 1920 {
1967 text_t *tp = save[r1 + row_offset].t; 1921 text_t *tp = ROW(r1).t;
1968 int len = save[r1 + row_offset].l; 1922 int len = ROW(r1).l;
1969 1923
1970 for (i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN 1924 for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN
1971 { 1925 {
1972 char mb[MB_LEN_MAX]; 1926 char mb[MB_LEN_MAX];
1973 text_t t = *tp++; 1927 text_t t = *tp++;
1974 if (t == NOCHAR) 1928 if (t == NOCHAR)
1975 continue; 1929 continue;
2003{ 1957{
2004 unsigned char must_clear, /* use draw_string not draw_image_string */ 1958 unsigned char must_clear, /* use draw_string not draw_image_string */
2005 showcursor; /* show the cursor */ 1959 showcursor; /* show the cursor */
2006 int16_t col, row, /* column/row we're processing */ 1960 int16_t col, row, /* column/row we're processing */
2007 ocrow; /* old cursor row */ 1961 ocrow; /* old cursor row */
2008 int i, /* tmp */ 1962 int i; /* tmp */
2009 row_offset; /* basic offset in screen structure */
2010#ifndef NO_CURSORCOLOR 1963#ifndef NO_CURSORCOLOR
2011 rend_t cc1; /* store colours at cursor position (s) */ 1964 rend_t cc1; /* store colours at cursor position (s) */
2012#endif 1965#endif
2013 rend_t *crp; // cursor rendition pointer 1966 rend_t *crp; // cursor rendition pointer
2014 1967
2020 /* 1973 /*
2021 * A: set up vars 1974 * A: set up vars
2022 */ 1975 */
2023 must_clear = 0; 1976 must_clear = 0;
2024 refresh_count = 0; 1977 refresh_count = 0;
2025
2026 row_offset = term_start - view_start;
2027 1978
2028#if XPM_BACKGROUND 1979#if XPM_BACKGROUND
2029 must_clear |= bgPixmap.pixmap != None; 1980 must_clear |= bgPixmap.pixmap != None;
2030#endif 1981#endif
2031#if TRANSPARENT 1982#if TRANSPARENT
2135 * D: CopyArea pass - very useful for slower links 2086 * D: CopyArea pass - very useful for slower links
2136 * This has been deliberately kept simple. 2087 * This has been deliberately kept simple.
2137 */ 2088 */
2138 i = num_scr; 2089 i = num_scr;
2139 if (!display->is_local 2090 if (!display->is_local
2140 && refresh_type == FAST_REFRESH && num_scr_allow && i 2091 && refresh_type == FAST_REFRESH && num_scr_allow && num_scr
2141 && abs (i) < nrow && !must_clear) 2092 && abs (num_scr) < nrow && !must_clear)
2142 { 2093 {
2143 int16_t nits; 2094 int16_t nits;
2144 int j; 2095 int j;
2145 int len, wlen; 2096 int len, wlen;
2146 2097
2149 row = i > 0 ? 0 : j - 1; 2100 row = i > 0 ? 0 : j - 1;
2150 for (; j-- >= 0; row += (i > 0 ? 1 : -1)) 2101 for (; j-- >= 0; row += (i > 0 ? 1 : -1))
2151 { 2102 {
2152 if (row + i >= 0 && row + i < nrow && row + i != ocrow) 2103 if (row + i >= 0 && row + i < nrow && row + i != ocrow)
2153 { 2104 {
2154 line_t s = save[(row + row_offset) % nlines]; 2105 line_t s = ROW(row - view_start);
2155 line_t d = drawn[row]; 2106 line_t d = drawn[row];
2156 line_t d2 = drawn[row + i]; 2107 line_t d2 = drawn[row + i];
2157 2108
2158 for (nits = 0, col = ncol; col--; ) 2109 for (nits = 0, col = ncol; col--; )
2159 if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) 2110 if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col])
2179 2130
2180 if (len != -1) 2131 if (len != -1)
2181 { 2132 {
2182 /* also comes here at end if needed because of >= above */ 2133 /* also comes here at end if needed because of >= above */
2183 if (wlen < len) 2134 if (wlen < len)
2184 SWAP_IT (wlen, len, int); 2135 ::swap (wlen, len);
2185 2136
2186 XCopyArea (display->display, vt, vt, 2137 XCopyArea (display->display, vt, vt,
2187 gc, 0, Row2Pixel (len + i), 2138 gc, 0, Row2Pixel (len + i),
2188 (unsigned int)TermWin_TotalWidth (), 2139 (unsigned int)TermWin_TotalWidth (),
2189 (unsigned int)Height2Pixel (wlen - len + 1), 2140 (unsigned int)Height2Pixel (wlen - len + 1),
2197 /* 2148 /*
2198 * E: main pass across every character 2149 * E: main pass across every character
2199 */ 2150 */
2200 for (row = 0; row < nrow; row++) 2151 for (row = 0; row < nrow; row++)
2201 { 2152 {
2202 text_t *stp = save[(row + row_offset) % total_rows].t; 2153 text_t *stp = ROW(row - view_start).t;
2203 rend_t *srp = save[(row + row_offset) % total_rows].r; 2154 rend_t *srp = ROW(row - view_start).r;
2204 text_t *dtp = drawn[row].t; 2155 text_t *dtp = drawn[row].t;
2205 rend_t *drp = drawn[row].r; 2156 rend_t *drp = drawn[row].r;
2206 2157
2207 /* 2158 /*
2208 * E2: OK, now the real pass 2159 * E2: OK, now the real pass
2321 fore = Color_UL; 2272 fore = Color_UL;
2322#endif 2273#endif
2323 2274
2324 if (invert) 2275 if (invert)
2325 { 2276 {
2326 SWAP_IT (fore, back, int); 2277 ::swap (fore, back);
2327 2278
2328#ifndef NO_BOLD_UNDERLINE_REVERSE 2279#ifndef NO_BOLD_UNDERLINE_REVERSE
2329 if (ISSET_PIXCOLOR (Color_RV)) 2280 if (ISSET_PIXCOLOR (Color_RV))
2330 back = Color_RV; 2281 back = Color_RV;
2331 2282
3073 want_refresh = 1; 3024 want_refresh = 1;
3074 3025
3075 selection.mark.row = row - view_start; 3026 selection.mark.row = row - view_start;
3076 selection.mark.col = col; 3027 selection.mark.col = col;
3077 3028
3078 selection.mark.row = min (max (selection.mark.row, -nsaved), nrow - 1); 3029 selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1);
3079 selection.mark.col = min (max (selection.mark.col, 0), ncol - 1); 3030 selection.mark.col = clamp (selection.mark.col, 0, ncol - 1);
3080 3031
3081 while (selection.mark.col > 0 3032 while (selection.mark.col > 0
3082 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) 3033 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR)
3083 --selection.mark.col; 3034 --selection.mark.col;
3084 3035
3189 * flag == 2 ==> button 3 motion 3140 * flag == 2 ==> button 3 motion
3190 */ 3141 */
3191void 3142void
3192rxvt_term::selection_extend (int x, int y, int flag) 3143rxvt_term::selection_extend (int x, int y, int flag)
3193{ 3144{
3194 int col = min (max (Pixel2Col (x), 0), nrow - 1); 3145 int col = clamp (Pixel2Col (x), 0, ncol);
3195 int row = min (max (Pixel2Row (y), 0), ncol); 3146 int row = clamp (Pixel2Row (y), 0, nrow - 1);
3196 3147
3197 /* 3148 /*
3198 * If we're selecting characters (single click) then we must check first 3149 * If we're selecting characters (single click) then we must check first
3199 * if we are at the same place as the original mark. If we are then 3150 * if we are at the same place as the original mark. If we are then
3200 * select nothing. Otherwise, if we're to the right of the mark, you have to 3151 * select nothing. Otherwise, if we're to the right of the mark, you have to
3371 for (int end_row = selection.mark.row; end_row < nrow; end_row++) 3322 for (int end_row = selection.mark.row; end_row < nrow; end_row++)
3372 { 3323 {
3373 if (!ROW(end_row).is_longer ()) 3324 if (!ROW(end_row).is_longer ())
3374 { 3325 {
3375 selection.end.row = end_row; 3326 selection.end.row = end_row;
3376 selection.end.col = save[end_row + saveLines].l; 3327 selection.end.col = ROW(end_row).l;
3377 selection_remove_trailing_spaces (); 3328 selection_remove_trailing_spaces ();
3378 break; 3329 break;
3379 } 3330 }
3380 } 3331 }
3381 } 3332 }
3413 } 3364 }
3414 } 3365 }
3415 3366
3416#if ENABLE_FRILLS 3367#if ENABLE_FRILLS
3417 if (selection.rect && selection.beg.col > selection.end.col) 3368 if (selection.rect && selection.beg.col > selection.end.col)
3418 SWAP_IT (selection.beg.col, selection.end.col, int); 3369 ::swap (selection.beg.col, selection.end.col);
3419#endif 3370#endif
3420} 3371}
3421 3372
3422#if ENABLE_FRILLS 3373#if ENABLE_FRILLS
3423void 3374void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines