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.176 by root, Tue Dec 20 20:58:31 2005 UTC vs.
Revision 1.184 by root, Wed Dec 21 14:23:30 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 */
261 lfree (swap_save[p]); 258 lfree (swap_save[p]);
262 lfree (drawn[p]); 259 lfree (drawn[p]);
263 } 260 }
264 261
265 /* we have fewer rows so fix up cursor position */ 262 /* we have fewer rows so fix up cursor position */
266 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 263 min_it (screen.cur.row, (int32_t)nrow - 1);
267 264
268 scr_reset_realloc (); /* realloc _last_ */ 265 scr_reset_realloc (); /* realloc _last_ */
269 } 266 }
270 else if (nrow > prev_nrow) 267 else if (nrow > prev_nrow)
271 { 268 {
298 } 295 }
299 296
300#ifdef DEBUG_STRICT 297#ifdef DEBUG_STRICT
301 assert (screen.cur.row < nrow); 298 assert (screen.cur.row < nrow);
302#else /* drive with your eyes closed */ 299#else /* drive with your eyes closed */
303 MIN_IT (screen.cur.row, nrow - 1); 300 min_it (screen.cur.row, nrow - 1);
304#endif 301#endif
305 ncol = ocol; // save b/c scr_blank_screen_mem uses this 302 ncol = ocol; // save b/c scr_blank_screen_mem uses this
306 } 303 }
307 304
308 /* resize columns */ 305 /* resize columns */
318 { 315 {
319 lresize (drawn[p]); 316 lresize (drawn[p]);
320 lresize (swap_save[p]); 317 lresize (swap_save[p]);
321 } 318 }
322 319
323 MIN_IT (screen.cur.col, (int16_t)ncol - 1); 320 min_it (screen.cur.col, (int16_t)ncol - 1);
324 321
325 delete old_ta; 322 delete old_ta;
326 delete old_ra; 323 delete old_ra;
327 } 324 }
328 325
518 set_font_style (); 515 set_font_style ();
519 break; 516 break;
520 } 517 }
521 518
522 /* boundary check in case screen size changed between SAVE and RESTORE */ 519 /* boundary check in case screen size changed between SAVE and RESTORE */
523 MIN_IT (s->cur.row, nrow - 1); 520 min_it (s->cur.row, nrow - 1);
524 MIN_IT (s->cur.col, ncol - 1); 521 min_it (s->cur.col, ncol - 1);
525#ifdef DEBUG_STRICT 522#ifdef DEBUG_STRICT
526 assert (s->cur.row >= 0); 523 assert (s->cur.row >= 0);
527 assert (s->cur.col >= 0); 524 assert (s->cur.col >= 0);
528#else /* drive with your eyes closed */ 525#else /* drive with your eyes closed */
529 MAX_IT (s->cur.row, 0); 526 max_it (s->cur.row, 0);
530 MAX_IT (s->cur.col, 0); 527 max_it (s->cur.col, 0);
531#endif 528#endif
532} 529}
533 530
534/* ------------------------------------------------------------------------- */ 531/* ------------------------------------------------------------------------- */
535/* 532/*
546 if (current_screen == scrn) 543 if (current_screen == scrn)
547 return scrn; 544 return scrn;
548 545
549 selection_check (2); /* check for boundary cross */ 546 selection_check (2); /* check for boundary cross */
550 547
551 SWAP_IT (scrn, current_screen, int); 548 int i = current_screen; current_screen = scrn; scrn = i;
552 549
553 SWAP_IT (screen.cur.row, swap.cur.row, int16_t); 550 ::swap (screen.cur.row, swap.cur.row);
554 SWAP_IT (screen.cur.col, swap.cur.col, int16_t); 551 ::swap (screen.cur.col, swap.cur.col);
555 MAX_IT (screen.cur.row, 0); 552
556 MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); 553 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
557 MAX_IT (screen.cur.col, 0); 554 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
558 MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1);
559 555
560#if NSCREENS 556#if NSCREENS
561 if (options & Opt_secondaryScreen) 557 if (options & Opt_secondaryScreen)
562 { 558 {
563 num_scr = 0; 559 num_scr = 0;
564 560
565 for (int i = nrow; i--; ) 561 for (int i = nrow; i--; )
566 SWAP_IT (ROW(i), swap_save[i], line_t); 562 ::swap (ROW(i), swap_save[i]);
567 563
568 SWAP_IT (screen.charset, swap.charset, int16_t); 564 ::swap (screen.charset, swap.charset);
569 SWAP_IT (screen.flags, swap.flags, int); 565 ::swap (screen.flags, swap.flags);
570 screen.flags |= Screen_VisibleCursor; 566 screen.flags |= Screen_VisibleCursor;
571 swap.flags |= Screen_VisibleCursor; 567 swap.flags |= Screen_VisibleCursor;
572 } 568 }
573 else 569 else
574#endif 570#endif
639 return 0; 635 return 0;
640 636
641 want_refresh = 1; 637 want_refresh = 1;
642 num_scr += count; 638 num_scr += count;
643 639
644 if (row1 == 0 && count > 0 640 if (count > 0
641 && row1 == 0
642 && row2 == nrow - 1
645 && (current_screen == PRIMARY || options & Opt_secondaryScroll)) 643 && (current_screen == PRIMARY || options & Opt_secondaryScroll))
646 { 644 {
647 nsaved = min (nsaved + count, saveLines); 645 nsaved = min (nsaved + count, saveLines);
648 term_start = (term_start + count) % total_rows; 646 term_start = (term_start + count) % total_rows;
649 647
747#ifdef DEBUG_STRICT 745#ifdef DEBUG_STRICT
748 assert (screen.cur.col < last_col); 746 assert (screen.cur.col < last_col);
749 assert ((screen.cur.row < nrow) 747 assert ((screen.cur.row < nrow)
750 && (screen.cur.row >= - (int32_t)nsaved)); 748 && (screen.cur.row >= - (int32_t)nsaved));
751#else /* drive with your eyes closed */ 749#else /* drive with your eyes closed */
752 MIN_IT (screen.cur.col, last_col - 1); 750 min_it (screen.cur.col, last_col - 1);
753 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 751 min_it (screen.cur.row, (int32_t)nrow - 1);
754 MAX_IT (screen.cur.row, - (int32_t)nsaved); 752 max_it (screen.cur.row, - (int32_t)nsaved);
755#endif 753#endif
756 row = screen.cur.row; 754 row = screen.cur.row;
757 755
758 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 756 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
759 757
765 763
766 if (c < 0x20) 764 if (c < 0x20)
767 if (c == C0_LF) 765 if (c == C0_LF)
768 { 766 {
769 if (!line->is_longer ()) /* XXX: think about this */ 767 if (!line->is_longer ()) /* XXX: think about this */
770 MAX_IT (line->l, screen.cur.col); 768 max_it (line->l, screen.cur.col);
771 769
772 screen.flags &= ~Screen_WrapNext; 770 screen.flags &= ~Screen_WrapNext;
773 771
774 if (screen.cur.row == screen.bscroll) 772 if (screen.cur.row == screen.bscroll)
775 scr_scroll_text (screen.tscroll, screen.bscroll, 1); 773 scr_scroll_text (screen.tscroll, screen.bscroll, 1);
780 continue; 778 continue;
781 } 779 }
782 else if (c == C0_CR) 780 else if (c == C0_CR)
783 { 781 {
784 if (!line->is_longer ()) /* XXX: think about this */ 782 if (!line->is_longer ()) /* XXX: think about this */
785 MAX_IT (line->l, screen.cur.col); 783 max_it (line->l, screen.cur.col);
786 784
787 screen.flags &= ~Screen_WrapNext; 785 screen.flags &= ~Screen_WrapNext;
788 screen.cur.col = 0; 786 screen.cur.col = 0;
789 continue; 787 continue;
790 } 788 }
966#endif 964#endif
967 } 965 }
968 } 966 }
969 967
970 if (!line->is_longer ()) /* XXX: think about this */ 968 if (!line->is_longer ()) /* XXX: think about this */
971 MAX_IT (line->l, screen.cur.col); 969 max_it (line->l, screen.cur.col);
972 970
973#ifdef DEBUG_STRICT 971#ifdef DEBUG_STRICT
974 assert (screen.cur.row >= 0); 972 assert (screen.cur.row >= 0);
975#else /* drive with your eyes closed */ 973#else /* drive with your eyes closed */
976 MAX_IT (screen.cur.row, 0); 974 max_it (screen.cur.row, 0);
977#endif 975#endif
978} 976}
979 977
980/* ------------------------------------------------------------------------- */ 978/* ------------------------------------------------------------------------- */
981/* 979/*
1047 if (ht && options & Opt_pastableTabs) 1045 if (ht && options & Opt_pastableTabs)
1048 { 1046 {
1049 base_rend = SET_FONT (base_rend, 0); 1047 base_rend = SET_FONT (base_rend, 0);
1050 1048
1051 if (!l.is_longer ()) /* XXX: think about this */ 1049 if (!l.is_longer ()) /* XXX: think about this */
1052 MAX_IT (l.l, x); 1050 max_it (l.l, x);
1053 1051
1054 i = screen.cur.col; 1052 i = screen.cur.col;
1055 1053
1056 l.t[i] = '\t'; 1054 l.t[i] = '\t';
1057 l.r[i] = base_rend; 1055 l.r[i] = base_rend;
1136{ 1134{
1137 want_refresh = 1; 1135 want_refresh = 1;
1138 ZERO_SCROLLBACK (); 1136 ZERO_SCROLLBACK ();
1139 1137
1140 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; 1138 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col;
1141 MAX_IT (screen.cur.col, 0); 1139 max_it (screen.cur.col, 0);
1142 MIN_IT (screen.cur.col, (int32_t)ncol - 1); 1140 min_it (screen.cur.col, (int32_t)ncol - 1);
1143 1141
1144 screen.flags &= ~Screen_WrapNext; 1142 screen.flags &= ~Screen_WrapNext;
1145 1143
1146 if (relative & R_RELATIVE) 1144 if (relative & R_RELATIVE)
1147 { 1145 {
1165 else 1163 else
1166 { 1164 {
1167 if (screen.flags & Screen_Relative) 1165 if (screen.flags & Screen_Relative)
1168 { /* relative origin mode */ 1166 { /* relative origin mode */
1169 screen.cur.row = row + screen.tscroll; 1167 screen.cur.row = row + screen.tscroll;
1170 MIN_IT (screen.cur.row, screen.bscroll); 1168 min_it (screen.cur.row, screen.bscroll);
1171 } 1169 }
1172 else 1170 else
1173 screen.cur.row = row; 1171 screen.cur.row = row;
1174 } 1172 }
1175 1173
1176 MAX_IT (screen.cur.row, 0); 1174 max_it (screen.cur.row, 0);
1177 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 1175 min_it (screen.cur.row, (int32_t)nrow - 1);
1178} 1176}
1179 1177
1180/* ------------------------------------------------------------------------- */ 1178/* ------------------------------------------------------------------------- */
1181/* 1179/*
1182 * direction should be UP or DN 1180 * direction should be UP or DN
1197 || (screen.cur.row == screen.tscroll && direction == DN)) 1195 || (screen.cur.row == screen.tscroll && direction == DN))
1198 scr_scroll_text (screen.tscroll, screen.bscroll, dirn); 1196 scr_scroll_text (screen.tscroll, screen.bscroll, dirn);
1199 else 1197 else
1200 screen.cur.row += dirn; 1198 screen.cur.row += dirn;
1201 1199
1202 MAX_IT (screen.cur.row, 0); 1200 max_it (screen.cur.row, 0);
1203 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 1201 min_it (screen.cur.row, (int32_t)nrow - 1);
1204 selection_check (0); 1202 selection_check (0);
1205} 1203}
1206 1204
1207/* ------------------------------------------------------------------------- */ 1205/* ------------------------------------------------------------------------- */
1208/* 1206/*
1226 switch (mode) 1224 switch (mode)
1227 { 1225 {
1228 case 0: /* erase to end of line */ 1226 case 0: /* erase to end of line */
1229 col = screen.cur.col; 1227 col = screen.cur.col;
1230 num = ncol - col; 1228 num = ncol - col;
1231 MIN_IT (ROW(row).l, (int16_t)col); 1229 min_it (ROW(row).l, (int16_t)col);
1232 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) 1230 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)
1233 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) 1231 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur))
1234 CLEAR_SELECTION (); 1232 CLEAR_SELECTION ();
1235 break; 1233 break;
1236 case 1: /* erase to beginning of line */ 1234 case 1: /* erase to beginning of line */
1303 CLEAR_SELECTION (); 1301 CLEAR_SELECTION ();
1304 1302
1305 if (row >= nrow) /* Out Of Bounds */ 1303 if (row >= nrow) /* Out Of Bounds */
1306 return; 1304 return;
1307 1305
1308 MIN_IT (num, (nrow - row)); 1306 min_it (num, (nrow - row));
1309 1307
1310 if (rstyle & (RS_RVid | RS_Uline)) 1308 if (rstyle & (RS_RVid | RS_Uline))
1311 ren = (rend_t) ~RS_None; 1309 ren = (rend_t) ~RS_None;
1312 else if (GET_BASEBG (rstyle) == Color_bg) 1310 else if (GET_BASEBG (rstyle) == Color_bg)
1313 { 1311 {
1421 return; 1419 return;
1422 1420
1423 scr_do_wrap (); 1421 scr_do_wrap ();
1424 1422
1425 selection_check (1); 1423 selection_check (1);
1426 MIN_IT (count, (ncol - screen.cur.col)); 1424 min_it (count, (ncol - screen.cur.col));
1427 1425
1428 row = screen.cur.row; 1426 row = screen.cur.row;
1429 1427
1430 line_t *line = &ROW(row); 1428 line_t *line = &ROW(row);
1431 1429
1439 } 1437 }
1440 1438
1441 if (!line->is_longer ()) 1439 if (!line->is_longer ())
1442 { 1440 {
1443 line->l += count; 1441 line->l += count;
1444 MIN_IT (line->l, ncol); 1442 min_it (line->l, ncol);
1445 } 1443 }
1446 1444
1447 if (selection.op && current_screen == selection.screen 1445 if (selection.op && current_screen == selection.screen
1448 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1446 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1449 { 1447 {
1480 scr_blank_line (*line, ncol - count, count, tr); 1478 scr_blank_line (*line, ncol - count, count, tr);
1481 1479
1482 if (line->is_longer ()) /* break line continuation */ 1480 if (line->is_longer ()) /* break line continuation */
1483 line->l = ncol; 1481 line->l = ncol;
1484 1482
1485 line->l = max (line->l - count, 0); 1483 max_it (line->l - count, 0);
1486 1484
1487 if (selection.op && current_screen == selection.screen 1485 if (selection.op && current_screen == selection.screen
1488 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1486 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1489 { 1487 {
1490 if (selection.end.row != screen.cur.row 1488 if (selection.end.row != screen.cur.row
1510 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r 1508 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r
1511 */ 1509 */
1512void 1510void
1513rxvt_term::scr_scroll_region (int top, int bot) 1511rxvt_term::scr_scroll_region (int top, int bot)
1514{ 1512{
1515 MAX_IT (top, 0); 1513 max_it (top, 0);
1516 MIN_IT (bot, (int)nrow - 1); 1514 min_it (bot, (int)nrow - 1);
1517 1515
1518 if (top > bot) 1516 if (top > bot)
1519 return; 1517 return;
1520 1518
1521 screen.tscroll = top; 1519 screen.tscroll = top;
1619 XGCValues gcvalue; 1617 XGCValues gcvalue;
1620 1618
1621 if (rvideo != mode) 1619 if (rvideo != mode)
1622 { 1620 {
1623 rvideo = mode; 1621 rvideo = mode;
1624 SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); 1622 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1625#if XPM_BACKGROUND 1623#if XPM_BACKGROUND
1626 if (bgPixmap.pixmap == None) 1624 if (bgPixmap.pixmap == None)
1627#endif 1625#endif
1628#if TRANSPARENT 1626#if TRANSPARENT
1629 if (! (options & Opt_transparent) || am_transparent == 0) 1627 if (! (options & Opt_transparent) || am_transparent == 0)
1765 eheight = height; 1763 eheight = height;
1766 } 1764 }
1767#endif 1765#endif
1768 1766
1769#ifdef DEBUG_STRICT 1767#ifdef DEBUG_STRICT
1770 x = max (x, 0); 1768#if 0
1771 x = min (x, (int)width); 1769 // that's not debugging //TODO //FIXME
1772 y = max (y, 0); 1770 clamp_it (x, 0, width);
1773 y = min (y, (int)height); 1771 clamp_it (y, 0, height);
1772#endif
1774#endif 1773#endif
1775 1774
1776 /* round down */ 1775 /* round down */
1777 rc[PART_BEG].col = Pixel2Col (x); 1776 rc[PART_BEG].col = Pixel2Col (x);
1778 rc[PART_BEG].row = Pixel2Row (y); 1777 rc[PART_BEG].row = Pixel2Row (y);
1781 rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); 1780 rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1);
1782 1781
1783 /* sanity checks */ 1782 /* sanity checks */
1784 for (i = PART_BEG; i < RC_COUNT; i++) 1783 for (i = PART_BEG; i < RC_COUNT; i++)
1785 { 1784 {
1786 MIN_IT (rc[i].col, ncol - 1); 1785 min_it (rc[i].col, ncol - 1);
1787 MIN_IT (rc[i].row, nrow - 1); 1786 min_it (rc[i].row, nrow - 1);
1788 } 1787 }
1789 1788
1790 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) 1789 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++)
1791 fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); 1790 fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1);
1792 1791
1959{ 1958{
1960 unsigned char must_clear, /* use draw_string not draw_image_string */ 1959 unsigned char must_clear, /* use draw_string not draw_image_string */
1961 showcursor; /* show the cursor */ 1960 showcursor; /* show the cursor */
1962 int16_t col, row, /* column/row we're processing */ 1961 int16_t col, row, /* column/row we're processing */
1963 ocrow; /* old cursor row */ 1962 ocrow; /* old cursor row */
1964 int i, /* tmp */ 1963 int i; /* tmp */
1965 row_offset; /* basic offset in screen structure */
1966#ifndef NO_CURSORCOLOR 1964#ifndef NO_CURSORCOLOR
1967 rend_t cc1; /* store colours at cursor position (s) */ 1965 rend_t cc1; /* store colours at cursor position (s) */
1968#endif 1966#endif
1969 rend_t *crp; // cursor rendition pointer 1967 rend_t *crp; // cursor rendition pointer
1970 1968
1976 /* 1974 /*
1977 * A: set up vars 1975 * A: set up vars
1978 */ 1976 */
1979 must_clear = 0; 1977 must_clear = 0;
1980 refresh_count = 0; 1978 refresh_count = 0;
1981
1982 row_offset = term_start - view_start;
1983 1979
1984#if XPM_BACKGROUND 1980#if XPM_BACKGROUND
1985 must_clear |= bgPixmap.pixmap != None; 1981 must_clear |= bgPixmap.pixmap != None;
1986#endif 1982#endif
1987#if TRANSPARENT 1983#if TRANSPARENT
2105 row = i > 0 ? 0 : j - 1; 2101 row = i > 0 ? 0 : j - 1;
2106 for (; j-- >= 0; row += (i > 0 ? 1 : -1)) 2102 for (; j-- >= 0; row += (i > 0 ? 1 : -1))
2107 { 2103 {
2108 if (row + i >= 0 && row + i < nrow && row + i != ocrow) 2104 if (row + i >= 0 && row + i < nrow && row + i != ocrow)
2109 { 2105 {
2110 line_t s = save[(row + row_offset) % total_rows]; 2106 line_t s = ROW(row - view_start);
2111 line_t d = drawn[row]; 2107 line_t d = drawn[row];
2112 line_t d2 = drawn[row + i]; 2108 line_t d2 = drawn[row + i];
2113 2109
2114 for (nits = 0, col = ncol; col--; ) 2110 for (nits = 0, col = ncol; col--; )
2115 if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) 2111 if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col])
2135 2131
2136 if (len != -1) 2132 if (len != -1)
2137 { 2133 {
2138 /* also comes here at end if needed because of >= above */ 2134 /* also comes here at end if needed because of >= above */
2139 if (wlen < len) 2135 if (wlen < len)
2140 SWAP_IT (wlen, len, int); 2136 ::swap (wlen, len);
2141 2137
2142 XCopyArea (display->display, vt, vt, 2138 XCopyArea (display->display, vt, vt,
2143 gc, 0, Row2Pixel (len + i), 2139 gc, 0, Row2Pixel (len + i),
2144 (unsigned int)TermWin_TotalWidth (), 2140 (unsigned int)TermWin_TotalWidth (),
2145 (unsigned int)Height2Pixel (wlen - len + 1), 2141 (unsigned int)Height2Pixel (wlen - len + 1),
2153 /* 2149 /*
2154 * E: main pass across every character 2150 * E: main pass across every character
2155 */ 2151 */
2156 for (row = 0; row < nrow; row++) 2152 for (row = 0; row < nrow; row++)
2157 { 2153 {
2158 text_t *stp = save[(row + row_offset) % total_rows].t; 2154 text_t *stp = ROW(row - view_start).t;
2159 rend_t *srp = save[(row + row_offset) % total_rows].r; 2155 rend_t *srp = ROW(row - view_start).r;
2160 text_t *dtp = drawn[row].t; 2156 text_t *dtp = drawn[row].t;
2161 rend_t *drp = drawn[row].r; 2157 rend_t *drp = drawn[row].r;
2162 2158
2163 /* 2159 /*
2164 * E2: OK, now the real pass 2160 * E2: OK, now the real pass
2277 fore = Color_UL; 2273 fore = Color_UL;
2278#endif 2274#endif
2279 2275
2280 if (invert) 2276 if (invert)
2281 { 2277 {
2282 SWAP_IT (fore, back, int); 2278 ::swap (fore, back);
2283 2279
2284#ifndef NO_BOLD_UNDERLINE_REVERSE 2280#ifndef NO_BOLD_UNDERLINE_REVERSE
2285 if (ISSET_PIXCOLOR (Color_RV)) 2281 if (ISSET_PIXCOLOR (Color_RV))
2286 back = Color_RV; 2282 back = Color_RV;
2287 2283
3029 want_refresh = 1; 3025 want_refresh = 1;
3030 3026
3031 selection.mark.row = row - view_start; 3027 selection.mark.row = row - view_start;
3032 selection.mark.col = col; 3028 selection.mark.col = col;
3033 3029
3034 selection.mark.row = min (max (selection.mark.row, -nsaved), nrow - 1); 3030 selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1);
3035 selection.mark.col = min (max (selection.mark.col, 0), ncol - 1); 3031 selection.mark.col = clamp (selection.mark.col, 0, ncol - 1);
3036 3032
3037 while (selection.mark.col > 0 3033 while (selection.mark.col > 0
3038 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) 3034 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR)
3039 --selection.mark.col; 3035 --selection.mark.col;
3040 3036
3145 * flag == 2 ==> button 3 motion 3141 * flag == 2 ==> button 3 motion
3146 */ 3142 */
3147void 3143void
3148rxvt_term::selection_extend (int x, int y, int flag) 3144rxvt_term::selection_extend (int x, int y, int flag)
3149{ 3145{
3150 int col = min (max (Pixel2Col (x), 0), nrow - 1); 3146 int col = clamp (Pixel2Col (x), 0, ncol);
3151 int row = min (max (Pixel2Row (y), 0), ncol); 3147 int row = clamp (Pixel2Row (y), 0, nrow - 1);
3152 3148
3153 /* 3149 /*
3154 * If we're selecting characters (single click) then we must check first 3150 * If we're selecting characters (single click) then we must check first
3155 * if we are at the same place as the original mark. If we are then 3151 * if we are at the same place as the original mark. If we are then
3156 * select nothing. Otherwise, if we're to the right of the mark, you have to 3152 * select nothing. Otherwise, if we're to the right of the mark, you have to
3369 } 3365 }
3370 } 3366 }
3371 3367
3372#if ENABLE_FRILLS 3368#if ENABLE_FRILLS
3373 if (selection.rect && selection.beg.col > selection.end.col) 3369 if (selection.rect && selection.beg.col > selection.end.col)
3374 SWAP_IT (selection.beg.col, selection.end.col, int); 3370 ::swap (selection.beg.col, selection.end.col);
3375#endif 3371#endif
3376} 3372}
3377 3373
3378#if ENABLE_FRILLS 3374#if ENABLE_FRILLS
3379void 3375void
3577 */ 3573 */
3578void 3574void
3579rxvt_term::pixel_position (int *x, int *y) 3575rxvt_term::pixel_position (int *x, int *y)
3580{ 3576{
3581 *x = Pixel2Col (*x); 3577 *x = Pixel2Col (*x);
3582 /* MAX_IT (*x, 0); MIN_IT (*x, (int)ncol - 1); */ 3578 /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */
3583 *y = Pixel2Row (*y); 3579 *y = Pixel2Row (*y);
3584 /* MAX_IT (*y, 0); MIN_IT (*y, (int)nrow - 1); */ 3580 /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */
3585} 3581}
3586 3582
3587/* ------------------------------------------------------------------------- */ 3583/* ------------------------------------------------------------------------- */
3588#ifdef USE_XIM 3584#ifdef USE_XIM
3589void 3585void
3611 3607
3612 if (x < 0) x = ncol - w; 3608 if (x < 0) x = ncol - w;
3613 if (y < 0) y = nrow - h; 3609 if (y < 0) y = nrow - h;
3614 3610
3615 // make space for border 3611 // make space for border
3616 w += 2; MIN_IT (w, ncol); 3612 w += 2; min_it (w, ncol);
3617 h += 2; MIN_IT (h, nrow); 3613 h += 2; min_it (h, nrow);
3618 3614
3619 x -= 1; MAX_IT (x, 0); 3615 x -= 1; max_it (x, 0);
3620 y -= 1; MAX_IT (y, 0); 3616 y -= 1; max_it (y, 0);
3621 3617
3622 MIN_IT (x, ncol - w); 3618 min_it (x, ncol - w);
3623 MIN_IT (y, nrow - h); 3619 min_it (y, nrow - h);
3624 3620
3625 ov_x = x; ov_y = y; 3621 ov_x = x; ov_y = y;
3626 ov_w = w; ov_h = h; 3622 ov_w = w; ov_h = h;
3627 3623
3628 ov_text = new text_t *[h]; 3624 ov_text = new text_t *[h];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines