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.179 by root, Tue Dec 20 22:47:14 2005 UTC vs.
Revision 1.183 by root, Wed Dec 21 14:19:19 2005 UTC

258 lfree (swap_save[p]); 258 lfree (swap_save[p]);
259 lfree (drawn[p]); 259 lfree (drawn[p]);
260 } 260 }
261 261
262 /* we have fewer rows so fix up cursor position */ 262 /* we have fewer rows so fix up cursor position */
263 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 263 min_it (screen.cur.row, (int32_t)nrow - 1);
264 264
265 scr_reset_realloc (); /* realloc _last_ */ 265 scr_reset_realloc (); /* realloc _last_ */
266 } 266 }
267 else if (nrow > prev_nrow) 267 else if (nrow > prev_nrow)
268 { 268 {
295 } 295 }
296 296
297#ifdef DEBUG_STRICT 297#ifdef DEBUG_STRICT
298 assert (screen.cur.row < nrow); 298 assert (screen.cur.row < nrow);
299#else /* drive with your eyes closed */ 299#else /* drive with your eyes closed */
300 MIN_IT (screen.cur.row, nrow - 1); 300 min_it (screen.cur.row, nrow - 1);
301#endif 301#endif
302 ncol = ocol; // save b/c scr_blank_screen_mem uses this 302 ncol = ocol; // save b/c scr_blank_screen_mem uses this
303 } 303 }
304 304
305 /* resize columns */ 305 /* resize columns */
315 { 315 {
316 lresize (drawn[p]); 316 lresize (drawn[p]);
317 lresize (swap_save[p]); 317 lresize (swap_save[p]);
318 } 318 }
319 319
320 MIN_IT (screen.cur.col, (int16_t)ncol - 1); 320 min_it (screen.cur.col, (int16_t)ncol - 1);
321 321
322 delete old_ta; 322 delete old_ta;
323 delete old_ra; 323 delete old_ra;
324 } 324 }
325 325
515 set_font_style (); 515 set_font_style ();
516 break; 516 break;
517 } 517 }
518 518
519 /* boundary check in case screen size changed between SAVE and RESTORE */ 519 /* boundary check in case screen size changed between SAVE and RESTORE */
520 MIN_IT (s->cur.row, nrow - 1); 520 min_it (s->cur.row, nrow - 1);
521 MIN_IT (s->cur.col, ncol - 1); 521 min_it (s->cur.col, ncol - 1);
522#ifdef DEBUG_STRICT 522#ifdef DEBUG_STRICT
523 assert (s->cur.row >= 0); 523 assert (s->cur.row >= 0);
524 assert (s->cur.col >= 0); 524 assert (s->cur.col >= 0);
525#else /* drive with your eyes closed */ 525#else /* drive with your eyes closed */
526 MAX_IT (s->cur.row, 0); 526 max_it (s->cur.row, 0);
527 MAX_IT (s->cur.col, 0); 527 max_it (s->cur.col, 0);
528#endif 528#endif
529} 529}
530 530
531/* ------------------------------------------------------------------------- */ 531/* ------------------------------------------------------------------------- */
532/* 532/*
543 if (current_screen == scrn) 543 if (current_screen == scrn)
544 return scrn; 544 return scrn;
545 545
546 selection_check (2); /* check for boundary cross */ 546 selection_check (2); /* check for boundary cross */
547 547
548 SWAP_IT (scrn, current_screen, int); 548 int i = current_screen; current_screen = scrn; scrn = i;
549 549
550 SWAP_IT (screen.cur.row, swap.cur.row, int16_t); 550 ::swap (screen.cur.row, swap.cur.row);
551 SWAP_IT (screen.cur.col, swap.cur.col, int16_t); 551 ::swap (screen.cur.col, swap.cur.col);
552 MAX_IT (screen.cur.row, 0); 552
553 MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); 553 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
554 MAX_IT (screen.cur.col, 0); 554 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
555 MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1);
556 555
557#if NSCREENS 556#if NSCREENS
558 if (options & Opt_secondaryScreen) 557 if (options & Opt_secondaryScreen)
559 { 558 {
560 num_scr = 0; 559 num_scr = 0;
561 560
562 for (int i = nrow; i--; ) 561 for (int i = nrow; i--; )
563 SWAP_IT (ROW(i), swap_save[i], line_t); 562 ::swap (ROW(i), swap_save[i]);
564 563
565 SWAP_IT (screen.charset, swap.charset, int16_t); 564 ::swap (screen.charset, swap.charset);
566 SWAP_IT (screen.flags, swap.flags, int); 565 ::swap (screen.flags, swap.flags);
567 screen.flags |= Screen_VisibleCursor; 566 screen.flags |= Screen_VisibleCursor;
568 swap.flags |= Screen_VisibleCursor; 567 swap.flags |= Screen_VisibleCursor;
569 } 568 }
570 else 569 else
571#endif 570#endif
746#ifdef DEBUG_STRICT 745#ifdef DEBUG_STRICT
747 assert (screen.cur.col < last_col); 746 assert (screen.cur.col < last_col);
748 assert ((screen.cur.row < nrow) 747 assert ((screen.cur.row < nrow)
749 && (screen.cur.row >= - (int32_t)nsaved)); 748 && (screen.cur.row >= - (int32_t)nsaved));
750#else /* drive with your eyes closed */ 749#else /* drive with your eyes closed */
751 MIN_IT (screen.cur.col, last_col - 1); 750 min_it (screen.cur.col, last_col - 1);
752 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 751 min_it (screen.cur.row, (int32_t)nrow - 1);
753 MAX_IT (screen.cur.row, - (int32_t)nsaved); 752 max_it (screen.cur.row, - (int32_t)nsaved);
754#endif 753#endif
755 row = screen.cur.row; 754 row = screen.cur.row;
756 755
757 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 756 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
758 757
764 763
765 if (c < 0x20) 764 if (c < 0x20)
766 if (c == C0_LF) 765 if (c == C0_LF)
767 { 766 {
768 if (!line->is_longer ()) /* XXX: think about this */ 767 if (!line->is_longer ()) /* XXX: think about this */
769 MAX_IT (line->l, screen.cur.col); 768 max_it (line->l, screen.cur.col);
770 769
771 screen.flags &= ~Screen_WrapNext; 770 screen.flags &= ~Screen_WrapNext;
772 771
773 if (screen.cur.row == screen.bscroll) 772 if (screen.cur.row == screen.bscroll)
774 scr_scroll_text (screen.tscroll, screen.bscroll, 1); 773 scr_scroll_text (screen.tscroll, screen.bscroll, 1);
779 continue; 778 continue;
780 } 779 }
781 else if (c == C0_CR) 780 else if (c == C0_CR)
782 { 781 {
783 if (!line->is_longer ()) /* XXX: think about this */ 782 if (!line->is_longer ()) /* XXX: think about this */
784 MAX_IT (line->l, screen.cur.col); 783 max_it (line->l, screen.cur.col);
785 784
786 screen.flags &= ~Screen_WrapNext; 785 screen.flags &= ~Screen_WrapNext;
787 screen.cur.col = 0; 786 screen.cur.col = 0;
788 continue; 787 continue;
789 } 788 }
965#endif 964#endif
966 } 965 }
967 } 966 }
968 967
969 if (!line->is_longer ()) /* XXX: think about this */ 968 if (!line->is_longer ()) /* XXX: think about this */
970 MAX_IT (line->l, screen.cur.col); 969 max_it (line->l, screen.cur.col);
971 970
972#ifdef DEBUG_STRICT 971#ifdef DEBUG_STRICT
973 assert (screen.cur.row >= 0); 972 assert (screen.cur.row >= 0);
974#else /* drive with your eyes closed */ 973#else /* drive with your eyes closed */
975 MAX_IT (screen.cur.row, 0); 974 max_it (screen.cur.row, 0);
976#endif 975#endif
977} 976}
978 977
979/* ------------------------------------------------------------------------- */ 978/* ------------------------------------------------------------------------- */
980/* 979/*
1046 if (ht && options & Opt_pastableTabs) 1045 if (ht && options & Opt_pastableTabs)
1047 { 1046 {
1048 base_rend = SET_FONT (base_rend, 0); 1047 base_rend = SET_FONT (base_rend, 0);
1049 1048
1050 if (!l.is_longer ()) /* XXX: think about this */ 1049 if (!l.is_longer ()) /* XXX: think about this */
1051 MAX_IT (l.l, x); 1050 max_it (l.l, x);
1052 1051
1053 i = screen.cur.col; 1052 i = screen.cur.col;
1054 1053
1055 l.t[i] = '\t'; 1054 l.t[i] = '\t';
1056 l.r[i] = base_rend; 1055 l.r[i] = base_rend;
1135{ 1134{
1136 want_refresh = 1; 1135 want_refresh = 1;
1137 ZERO_SCROLLBACK (); 1136 ZERO_SCROLLBACK ();
1138 1137
1139 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; 1138 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col;
1140 MAX_IT (screen.cur.col, 0); 1139 max_it (screen.cur.col, 0);
1141 MIN_IT (screen.cur.col, (int32_t)ncol - 1); 1140 min_it (screen.cur.col, (int32_t)ncol - 1);
1142 1141
1143 screen.flags &= ~Screen_WrapNext; 1142 screen.flags &= ~Screen_WrapNext;
1144 1143
1145 if (relative & R_RELATIVE) 1144 if (relative & R_RELATIVE)
1146 { 1145 {
1164 else 1163 else
1165 { 1164 {
1166 if (screen.flags & Screen_Relative) 1165 if (screen.flags & Screen_Relative)
1167 { /* relative origin mode */ 1166 { /* relative origin mode */
1168 screen.cur.row = row + screen.tscroll; 1167 screen.cur.row = row + screen.tscroll;
1169 MIN_IT (screen.cur.row, screen.bscroll); 1168 min_it (screen.cur.row, screen.bscroll);
1170 } 1169 }
1171 else 1170 else
1172 screen.cur.row = row; 1171 screen.cur.row = row;
1173 } 1172 }
1174 1173
1175 MAX_IT (screen.cur.row, 0); 1174 max_it (screen.cur.row, 0);
1176 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 1175 min_it (screen.cur.row, (int32_t)nrow - 1);
1177} 1176}
1178 1177
1179/* ------------------------------------------------------------------------- */ 1178/* ------------------------------------------------------------------------- */
1180/* 1179/*
1181 * direction should be UP or DN 1180 * direction should be UP or DN
1196 || (screen.cur.row == screen.tscroll && direction == DN)) 1195 || (screen.cur.row == screen.tscroll && direction == DN))
1197 scr_scroll_text (screen.tscroll, screen.bscroll, dirn); 1196 scr_scroll_text (screen.tscroll, screen.bscroll, dirn);
1198 else 1197 else
1199 screen.cur.row += dirn; 1198 screen.cur.row += dirn;
1200 1199
1201 MAX_IT (screen.cur.row, 0); 1200 max_it (screen.cur.row, 0);
1202 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 1201 min_it (screen.cur.row, (int32_t)nrow - 1);
1203 selection_check (0); 1202 selection_check (0);
1204} 1203}
1205 1204
1206/* ------------------------------------------------------------------------- */ 1205/* ------------------------------------------------------------------------- */
1207/* 1206/*
1225 switch (mode) 1224 switch (mode)
1226 { 1225 {
1227 case 0: /* erase to end of line */ 1226 case 0: /* erase to end of line */
1228 col = screen.cur.col; 1227 col = screen.cur.col;
1229 num = ncol - col; 1228 num = ncol - col;
1230 MIN_IT (ROW(row).l, (int16_t)col); 1229 min_it (ROW(row).l, (int16_t)col);
1231 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) 1230 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)
1232 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) 1231 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur))
1233 CLEAR_SELECTION (); 1232 CLEAR_SELECTION ();
1234 break; 1233 break;
1235 case 1: /* erase to beginning of line */ 1234 case 1: /* erase to beginning of line */
1302 CLEAR_SELECTION (); 1301 CLEAR_SELECTION ();
1303 1302
1304 if (row >= nrow) /* Out Of Bounds */ 1303 if (row >= nrow) /* Out Of Bounds */
1305 return; 1304 return;
1306 1305
1307 MIN_IT (num, (nrow - row)); 1306 min_it (num, (nrow - row));
1308 1307
1309 if (rstyle & (RS_RVid | RS_Uline)) 1308 if (rstyle & (RS_RVid | RS_Uline))
1310 ren = (rend_t) ~RS_None; 1309 ren = (rend_t) ~RS_None;
1311 else if (GET_BASEBG (rstyle) == Color_bg) 1310 else if (GET_BASEBG (rstyle) == Color_bg)
1312 { 1311 {
1420 return; 1419 return;
1421 1420
1422 scr_do_wrap (); 1421 scr_do_wrap ();
1423 1422
1424 selection_check (1); 1423 selection_check (1);
1425 MIN_IT (count, (ncol - screen.cur.col)); 1424 min_it (count, (ncol - screen.cur.col));
1426 1425
1427 row = screen.cur.row; 1426 row = screen.cur.row;
1428 1427
1429 line_t *line = &ROW(row); 1428 line_t *line = &ROW(row);
1430 1429
1438 } 1437 }
1439 1438
1440 if (!line->is_longer ()) 1439 if (!line->is_longer ())
1441 { 1440 {
1442 line->l += count; 1441 line->l += count;
1443 MIN_IT (line->l, ncol); 1442 min_it (line->l, ncol);
1444 } 1443 }
1445 1444
1446 if (selection.op && current_screen == selection.screen 1445 if (selection.op && current_screen == selection.screen
1447 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1446 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1448 { 1447 {
1509 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r 1508 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r
1510 */ 1509 */
1511void 1510void
1512rxvt_term::scr_scroll_region (int top, int bot) 1511rxvt_term::scr_scroll_region (int top, int bot)
1513{ 1512{
1514 MAX_IT (top, 0); 1513 max_it (top, 0);
1515 MIN_IT (bot, (int)nrow - 1); 1514 min_it (bot, (int)nrow - 1);
1516 1515
1517 if (top > bot) 1516 if (top > bot)
1518 return; 1517 return;
1519 1518
1520 screen.tscroll = top; 1519 screen.tscroll = top;
1618 XGCValues gcvalue; 1617 XGCValues gcvalue;
1619 1618
1620 if (rvideo != mode) 1619 if (rvideo != mode)
1621 { 1620 {
1622 rvideo = mode; 1621 rvideo = mode;
1623 SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); 1622 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1624#if XPM_BACKGROUND 1623#if XPM_BACKGROUND
1625 if (bgPixmap.pixmap == None) 1624 if (bgPixmap.pixmap == None)
1626#endif 1625#endif
1627#if TRANSPARENT 1626#if TRANSPARENT
1628 if (! (options & Opt_transparent) || am_transparent == 0) 1627 if (! (options & Opt_transparent) || am_transparent == 0)
1780 rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); 1779 rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1);
1781 1780
1782 /* sanity checks */ 1781 /* sanity checks */
1783 for (i = PART_BEG; i < RC_COUNT; i++) 1782 for (i = PART_BEG; i < RC_COUNT; i++)
1784 { 1783 {
1785 MIN_IT (rc[i].col, ncol - 1); 1784 min_it (rc[i].col, ncol - 1);
1786 MIN_IT (rc[i].row, nrow - 1); 1785 min_it (rc[i].row, nrow - 1);
1787 } 1786 }
1788 1787
1789 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) 1788 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++)
1790 fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); 1789 fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1);
1791 1790
2131 2130
2132 if (len != -1) 2131 if (len != -1)
2133 { 2132 {
2134 /* also comes here at end if needed because of >= above */ 2133 /* also comes here at end if needed because of >= above */
2135 if (wlen < len) 2134 if (wlen < len)
2136 SWAP_IT (wlen, len, int); 2135 ::swap (wlen, len);
2137 2136
2138 XCopyArea (display->display, vt, vt, 2137 XCopyArea (display->display, vt, vt,
2139 gc, 0, Row2Pixel (len + i), 2138 gc, 0, Row2Pixel (len + i),
2140 (unsigned int)TermWin_TotalWidth (), 2139 (unsigned int)TermWin_TotalWidth (),
2141 (unsigned int)Height2Pixel (wlen - len + 1), 2140 (unsigned int)Height2Pixel (wlen - len + 1),
2273 fore = Color_UL; 2272 fore = Color_UL;
2274#endif 2273#endif
2275 2274
2276 if (invert) 2275 if (invert)
2277 { 2276 {
2278 SWAP_IT (fore, back, int); 2277 ::swap (fore, back);
2279 2278
2280#ifndef NO_BOLD_UNDERLINE_REVERSE 2279#ifndef NO_BOLD_UNDERLINE_REVERSE
2281 if (ISSET_PIXCOLOR (Color_RV)) 2280 if (ISSET_PIXCOLOR (Color_RV))
2282 back = Color_RV; 2281 back = Color_RV;
2283 2282
3025 want_refresh = 1; 3024 want_refresh = 1;
3026 3025
3027 selection.mark.row = row - view_start; 3026 selection.mark.row = row - view_start;
3028 selection.mark.col = col; 3027 selection.mark.col = col;
3029 3028
3030 selection.mark.row = min (max (selection.mark.row, -nsaved), nrow - 1); 3029 selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1);
3031 selection.mark.col = min (max (selection.mark.col, 0), ncol - 1); 3030 selection.mark.col = clamp (selection.mark.col, 0, ncol - 1);
3032 3031
3033 while (selection.mark.col > 0 3032 while (selection.mark.col > 0
3034 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) 3033 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR)
3035 --selection.mark.col; 3034 --selection.mark.col;
3036 3035
3141 * flag == 2 ==> button 3 motion 3140 * flag == 2 ==> button 3 motion
3142 */ 3141 */
3143void 3142void
3144rxvt_term::selection_extend (int x, int y, int flag) 3143rxvt_term::selection_extend (int x, int y, int flag)
3145{ 3144{
3146 int col = min (max (Pixel2Col (x), 0), ncol); 3145 int col = clamp (Pixel2Col (x), 0, ncol);
3147 int row = min (max (Pixel2Row (y), 0), nrow - 1); 3146 int row = clamp (Pixel2Row (y), 0, nrow - 1);
3148 3147
3149 /* 3148 /*
3150 * 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
3151 * 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
3152 * 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
3365 } 3364 }
3366 } 3365 }
3367 3366
3368#if ENABLE_FRILLS 3367#if ENABLE_FRILLS
3369 if (selection.rect && selection.beg.col > selection.end.col) 3368 if (selection.rect && selection.beg.col > selection.end.col)
3370 SWAP_IT (selection.beg.col, selection.end.col, int); 3369 ::swap (selection.beg.col, selection.end.col);
3371#endif 3370#endif
3372} 3371}
3373 3372
3374#if ENABLE_FRILLS 3373#if ENABLE_FRILLS
3375void 3374void
3573 */ 3572 */
3574void 3573void
3575rxvt_term::pixel_position (int *x, int *y) 3574rxvt_term::pixel_position (int *x, int *y)
3576{ 3575{
3577 *x = Pixel2Col (*x); 3576 *x = Pixel2Col (*x);
3578 /* MAX_IT (*x, 0); MIN_IT (*x, (int)ncol - 1); */ 3577 /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */
3579 *y = Pixel2Row (*y); 3578 *y = Pixel2Row (*y);
3580 /* MAX_IT (*y, 0); MIN_IT (*y, (int)nrow - 1); */ 3579 /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */
3581} 3580}
3582 3581
3583/* ------------------------------------------------------------------------- */ 3582/* ------------------------------------------------------------------------- */
3584#ifdef USE_XIM 3583#ifdef USE_XIM
3585void 3584void
3607 3606
3608 if (x < 0) x = ncol - w; 3607 if (x < 0) x = ncol - w;
3609 if (y < 0) y = nrow - h; 3608 if (y < 0) y = nrow - h;
3610 3609
3611 // make space for border 3610 // make space for border
3612 w += 2; MIN_IT (w, ncol); 3611 w += 2; min_it (w, ncol);
3613 h += 2; MIN_IT (h, nrow); 3612 h += 2; min_it (h, nrow);
3614 3613
3615 x -= 1; MAX_IT (x, 0); 3614 x -= 1; max_it (x, 0);
3616 y -= 1; MAX_IT (y, 0); 3615 y -= 1; max_it (y, 0);
3617 3616
3618 MIN_IT (x, ncol - w); 3617 min_it (x, ncol - w);
3619 MIN_IT (y, nrow - h); 3618 min_it (y, nrow - h);
3620 3619
3621 ov_x = x; ov_y = y; 3620 ov_x = x; ov_y = y;
3622 ov_w = w; ov_h = h; 3621 ov_w = w; ov_h = h;
3623 3622
3624 ov_text = new text_t *[h]; 3623 ov_text = new text_t *[h];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines