--- rxvt-unicode/src/screen.C 2005/12/20 20:58:31 1.176 +++ rxvt-unicode/src/screen.C 2005/12/21 14:25:41 1.185 @@ -85,9 +85,6 @@ #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) -#define LINENO(n) (((n) + term_start + total_rows) % total_rows) -#define ROW(n) (save [LINENO (n)]) - /* * CLEAR_ROWS : clear rows starting from row * CLEAR_CHARS: clear chars starting from pixel position @@ -263,7 +260,7 @@ } /* we have fewer rows so fix up cursor position */ - MIN_IT (screen.cur.row, (int32_t)nrow - 1); + min_it (screen.cur.row, (int32_t)nrow - 1); scr_reset_realloc (); /* realloc _last_ */ } @@ -300,7 +297,7 @@ #ifdef DEBUG_STRICT assert (screen.cur.row < nrow); #else /* drive with your eyes closed */ - MIN_IT (screen.cur.row, nrow - 1); + min_it (screen.cur.row, nrow - 1); #endif ncol = ocol; // save b/c scr_blank_screen_mem uses this } @@ -320,7 +317,7 @@ lresize (swap_save[p]); } - MIN_IT (screen.cur.col, (int16_t)ncol - 1); + min_it (screen.cur.col, (int16_t)ncol - 1); delete old_ta; delete old_ra; @@ -520,14 +517,14 @@ } /* boundary check in case screen size changed between SAVE and RESTORE */ - MIN_IT (s->cur.row, nrow - 1); - MIN_IT (s->cur.col, ncol - 1); + min_it (s->cur.row, nrow - 1); + min_it (s->cur.col, ncol - 1); #ifdef DEBUG_STRICT assert (s->cur.row >= 0); assert (s->cur.col >= 0); #else /* drive with your eyes closed */ - MAX_IT (s->cur.row, 0); - MAX_IT (s->cur.col, 0); + max_it (s->cur.row, 0); + max_it (s->cur.col, 0); #endif } @@ -548,14 +545,13 @@ selection_check (2); /* check for boundary cross */ - SWAP_IT (scrn, current_screen, int); + int i = current_screen; current_screen = scrn; scrn = i; + + ::swap (screen.cur.row, swap.cur.row); + ::swap (screen.cur.col, swap.cur.col); - SWAP_IT (screen.cur.row, swap.cur.row, int16_t); - SWAP_IT (screen.cur.col, swap.cur.col, int16_t); - MAX_IT (screen.cur.row, 0); - MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); - MAX_IT (screen.cur.col, 0); - MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); + screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); + screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); #if NSCREENS if (options & Opt_secondaryScreen) @@ -563,10 +559,10 @@ num_scr = 0; for (int i = nrow; i--; ) - SWAP_IT (ROW(i), swap_save[i], line_t); + ::swap (ROW(i), swap_save[i]); - SWAP_IT (screen.charset, swap.charset, int16_t); - SWAP_IT (screen.flags, swap.flags, int); + ::swap (screen.charset, swap.charset); + ::swap (screen.flags, swap.flags); screen.flags |= Screen_VisibleCursor; swap.flags |= Screen_VisibleCursor; } @@ -641,7 +637,9 @@ want_refresh = 1; num_scr += count; - if (row1 == 0 && count > 0 + if (count > 0 + && row1 == 0 + && row2 == nrow - 1 && (current_screen == PRIMARY || options & Opt_secondaryScroll)) { nsaved = min (nsaved + count, saveLines); @@ -749,9 +747,9 @@ assert ((screen.cur.row < nrow) && (screen.cur.row >= - (int32_t)nsaved)); #else /* drive with your eyes closed */ - MIN_IT (screen.cur.col, last_col - 1); - MIN_IT (screen.cur.row, (int32_t)nrow - 1); - MAX_IT (screen.cur.row, - (int32_t)nsaved); + min_it (screen.cur.col, last_col - 1); + min_it (screen.cur.row, (int32_t)nrow - 1); + max_it (screen.cur.row, - (int32_t)nsaved); #endif row = screen.cur.row; @@ -767,7 +765,7 @@ if (c == C0_LF) { if (!line->is_longer ()) /* XXX: think about this */ - MAX_IT (line->l, screen.cur.col); + max_it (line->l, screen.cur.col); screen.flags &= ~Screen_WrapNext; @@ -782,7 +780,7 @@ else if (c == C0_CR) { if (!line->is_longer ()) /* XXX: think about this */ - MAX_IT (line->l, screen.cur.col); + max_it (line->l, screen.cur.col); screen.flags &= ~Screen_WrapNext; screen.cur.col = 0; @@ -968,12 +966,12 @@ } if (!line->is_longer ()) /* XXX: think about this */ - MAX_IT (line->l, screen.cur.col); + max_it (line->l, screen.cur.col); #ifdef DEBUG_STRICT assert (screen.cur.row >= 0); #else /* drive with your eyes closed */ - MAX_IT (screen.cur.row, 0); + max_it (screen.cur.row, 0); #endif } @@ -1049,7 +1047,7 @@ base_rend = SET_FONT (base_rend, 0); if (!l.is_longer ()) /* XXX: think about this */ - MAX_IT (l.l, x); + max_it (l.l, x); i = screen.cur.col; @@ -1138,8 +1136,8 @@ ZERO_SCROLLBACK (); screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; - MAX_IT (screen.cur.col, 0); - MIN_IT (screen.cur.col, (int32_t)ncol - 1); + max_it (screen.cur.col, 0); + min_it (screen.cur.col, (int32_t)ncol - 1); screen.flags &= ~Screen_WrapNext; @@ -1167,14 +1165,14 @@ if (screen.flags & Screen_Relative) { /* relative origin mode */ screen.cur.row = row + screen.tscroll; - MIN_IT (screen.cur.row, screen.bscroll); + min_it (screen.cur.row, screen.bscroll); } else screen.cur.row = row; } - MAX_IT (screen.cur.row, 0); - MIN_IT (screen.cur.row, (int32_t)nrow - 1); + max_it (screen.cur.row, 0); + min_it (screen.cur.row, (int32_t)nrow - 1); } /* ------------------------------------------------------------------------- */ @@ -1199,8 +1197,8 @@ else screen.cur.row += dirn; - MAX_IT (screen.cur.row, 0); - MIN_IT (screen.cur.row, (int32_t)nrow - 1); + max_it (screen.cur.row, 0); + min_it (screen.cur.row, (int32_t)nrow - 1); selection_check (0); } @@ -1228,7 +1226,7 @@ case 0: /* erase to end of line */ col = screen.cur.col; num = ncol - col; - MIN_IT (ROW(row).l, (int16_t)col); + min_it (ROW(row).l, (int16_t)col); if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) CLEAR_SELECTION (); @@ -1305,7 +1303,7 @@ if (row >= nrow) /* Out Of Bounds */ return; - MIN_IT (num, (nrow - row)); + min_it (num, (nrow - row)); if (rstyle & (RS_RVid | RS_Uline)) ren = (rend_t) ~RS_None; @@ -1423,7 +1421,7 @@ scr_do_wrap (); selection_check (1); - MIN_IT (count, (ncol - screen.cur.col)); + min_it (count, (ncol - screen.cur.col)); row = screen.cur.row; @@ -1441,7 +1439,7 @@ if (!line->is_longer ()) { line->l += count; - MIN_IT (line->l, ncol); + min_it (line->l, ncol); } if (selection.op && current_screen == selection.screen @@ -1512,8 +1510,8 @@ void rxvt_term::scr_scroll_region (int top, int bot) { - MAX_IT (top, 0); - MIN_IT (bot, (int)nrow - 1); + max_it (top, 0); + min_it (bot, (int)nrow - 1); if (top > bot) return; @@ -1621,7 +1619,7 @@ if (rvideo != mode) { rvideo = mode; - SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); + ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); #if XPM_BACKGROUND if (bgPixmap.pixmap == None) #endif @@ -1767,10 +1765,11 @@ #endif #ifdef DEBUG_STRICT - x = max (x, 0); - x = min (x, (int)width); - y = max (y, 0); - y = min (y, (int)height); +#if 0 + // that's not debugging //TODO //FIXME + clamp_it (x, 0, width); + clamp_it (y, 0, height); +#endif #endif /* round down */ @@ -1783,8 +1782,8 @@ /* sanity checks */ for (i = PART_BEG; i < RC_COUNT; i++) { - MIN_IT (rc[i].col, ncol - 1); - MIN_IT (rc[i].row, nrow - 1); + min_it (rc[i].col, ncol - 1); + min_it (rc[i].row, nrow - 1); } for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) @@ -1961,8 +1960,7 @@ showcursor; /* show the cursor */ int16_t col, row, /* column/row we're processing */ ocrow; /* old cursor row */ - int i, /* tmp */ - row_offset; /* basic offset in screen structure */ + int i; /* tmp */ #ifndef NO_CURSORCOLOR rend_t cc1; /* store colours at cursor position (s) */ #endif @@ -1979,8 +1977,6 @@ must_clear = 0; refresh_count = 0; - row_offset = term_start - view_start; - #if XPM_BACKGROUND must_clear |= bgPixmap.pixmap != None; #endif @@ -2107,7 +2103,7 @@ { if (row + i >= 0 && row + i < nrow && row + i != ocrow) { - line_t s = save[(row + row_offset) % total_rows]; + line_t s = ROW(row - view_start); line_t d = drawn[row]; line_t d2 = drawn[row + i]; @@ -2137,7 +2133,7 @@ { /* also comes here at end if needed because of >= above */ if (wlen < len) - SWAP_IT (wlen, len, int); + ::swap (wlen, len); XCopyArea (display->display, vt, vt, gc, 0, Row2Pixel (len + i), @@ -2155,8 +2151,8 @@ */ for (row = 0; row < nrow; row++) { - text_t *stp = save[(row + row_offset) % total_rows].t; - rend_t *srp = save[(row + row_offset) % total_rows].r; + text_t *stp = ROW(row - view_start).t; + rend_t *srp = ROW(row - view_start).r; text_t *dtp = drawn[row].t; rend_t *drp = drawn[row].r; @@ -2279,7 +2275,7 @@ if (invert) { - SWAP_IT (fore, back, int); + ::swap (fore, back); #ifndef NO_BOLD_UNDERLINE_REVERSE if (ISSET_PIXCOLOR (Color_RV)) @@ -3031,8 +3027,8 @@ selection.mark.row = row - view_start; selection.mark.col = col; - selection.mark.row = min (max (selection.mark.row, -nsaved), nrow - 1); - selection.mark.col = min (max (selection.mark.col, 0), ncol - 1); + selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1); + selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); while (selection.mark.col > 0 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) @@ -3147,8 +3143,8 @@ void rxvt_term::selection_extend (int x, int y, int flag) { - int col = min (max (Pixel2Col (x), 0), nrow - 1); - int row = min (max (Pixel2Row (y), 0), ncol); + int col = clamp (Pixel2Col (x), 0, ncol); + int row = clamp (Pixel2Row (y), 0, nrow - 1); /* * If we're selecting characters (single click) then we must check first @@ -3371,7 +3367,7 @@ #if ENABLE_FRILLS if (selection.rect && selection.beg.col > selection.end.col) - SWAP_IT (selection.beg.col, selection.end.col, int); + ::swap (selection.beg.col, selection.end.col); #endif } @@ -3579,9 +3575,9 @@ rxvt_term::pixel_position (int *x, int *y) { *x = Pixel2Col (*x); - /* MAX_IT (*x, 0); MIN_IT (*x, (int)ncol - 1); */ + /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ *y = Pixel2Row (*y); - /* MAX_IT (*y, 0); MIN_IT (*y, (int)nrow - 1); */ + /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ } /* ------------------------------------------------------------------------- */ @@ -3613,14 +3609,14 @@ if (y < 0) y = nrow - h; // make space for border - w += 2; MIN_IT (w, ncol); - h += 2; MIN_IT (h, nrow); + w += 2; min_it (w, ncol); + h += 2; min_it (h, nrow); - x -= 1; MAX_IT (x, 0); - y -= 1; MAX_IT (y, 0); + x -= 1; max_it (x, 0); + y -= 1; max_it (y, 0); - MIN_IT (x, ncol - w); - MIN_IT (y, nrow - h); + min_it (x, ncol - w); + min_it (y, nrow - h); ov_x = x; ov_y = y; ov_w = w; ov_h = h;