1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*---------------------------------------------------------------------------* |
2 | * File: screen.C |
2 | * File: screen.C |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
5 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
… | |
… | |
645 | { |
645 | { |
646 | line_t &l = ROW(nrow - 1 - i); |
646 | line_t &l = ROW(nrow - 1 - i); |
647 | |
647 | |
648 | // optimize if already cleared, can be significant on slow machines |
648 | // optimize if already cleared, can be significant on slow machines |
649 | // could be rolled into scr_blank_screen_mem |
649 | // could be rolled into scr_blank_screen_mem |
650 | if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & RS_bgMask)) |
650 | if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask))) |
651 | { |
651 | { |
652 | scr_blank_line (l, 0, l.l, rstyle); |
652 | scr_blank_line (l, 0, l.l, rstyle); |
653 | l.l = 0; |
653 | l.l = 0; |
654 | l.f = 0; |
654 | l.f = 0; |
655 | } |
655 | } |
… | |
… | |
1969 | * screen.text/screen.rend contain what the screen will change to. |
1969 | * screen.text/screen.rend contain what the screen will change to. |
1970 | */ |
1970 | */ |
1971 | void |
1971 | void |
1972 | rxvt_term::scr_refresh () NOTHROW |
1972 | rxvt_term::scr_refresh () NOTHROW |
1973 | { |
1973 | { |
1974 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1974 | unsigned char have_bg, |
1975 | showcursor; /* show the cursor */ |
1975 | showcursor; /* show the cursor */ |
1976 | int16_t col, row, /* column/row we're processing */ |
1976 | int16_t col, row, /* column/row we're processing */ |
1977 | ocrow; /* old cursor row */ |
1977 | ocrow; /* old cursor row */ |
1978 | int i; /* tmp */ |
1978 | int i; /* tmp */ |
1979 | #ifndef NO_CURSORCOLOR |
1979 | #ifndef NO_CURSORCOLOR |
… | |
… | |
1987 | return; |
1987 | return; |
1988 | |
1988 | |
1989 | /* |
1989 | /* |
1990 | * A: set up vars |
1990 | * A: set up vars |
1991 | */ |
1991 | */ |
1992 | must_clear = 0; |
1992 | have_bg = 0; |
1993 | refresh_count = 0; |
1993 | refresh_count = 0; |
1994 | |
1994 | |
1995 | #if XPM_BACKGROUND |
1995 | #if XPM_BACKGROUND |
1996 | must_clear |= bgPixmap.pixmap != None; |
1996 | have_bg |= bgPixmap.pixmap != None; |
1997 | #endif |
1997 | #endif |
1998 | #if TRANSPARENT |
1998 | #if TRANSPARENT |
1999 | must_clear |= OPTION (Opt_transparent) && am_transparent; |
1999 | have_bg |= OPTION (Opt_transparent) && am_transparent; |
2000 | #endif |
2000 | #endif |
2001 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2001 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2002 | |
2002 | |
2003 | /* |
2003 | /* |
2004 | * B: reverse any characters which are selected |
2004 | * B: reverse any characters which are selected |
… | |
… | |
2103 | * D: CopyArea pass - very useful for slower links |
2103 | * D: CopyArea pass - very useful for slower links |
2104 | * This has been deliberately kept simple. |
2104 | * This has been deliberately kept simple. |
2105 | */ |
2105 | */ |
2106 | if (!display->is_local |
2106 | if (!display->is_local |
2107 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2107 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2108 | && abs (num_scr) < nrow && !must_clear) |
2108 | && abs (num_scr) < nrow && !have_bg) |
2109 | { |
2109 | { |
2110 | int16_t nits; |
2110 | int16_t nits; |
|
|
2111 | int i = num_scr; |
2111 | int j; |
2112 | int j; |
2112 | int len, wlen; |
2113 | int len, wlen; |
2113 | dLocal (int, num_scr); |
2114 | dLocal (int, num_scr); |
2114 | |
2115 | |
2115 | j = nrow; |
2116 | j = nrow; |
2116 | wlen = len = -1; |
2117 | wlen = len = -1; |
2117 | row = i > 0 ? 0 : j - 1; |
2118 | row = i > 0 ? 0 : j - 1; |
|
|
2119 | |
2118 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2120 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2119 | { |
2121 | { |
2120 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2122 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2121 | { |
2123 | { |
2122 | line_t s = ROW(view_start + row); |
2124 | line_t s = ROW(view_start + row); |
… | |
… | |
2143 | wlen = row; |
2145 | wlen = row; |
2144 | continue; |
2146 | continue; |
2145 | } |
2147 | } |
2146 | } |
2148 | } |
2147 | |
2149 | |
2148 | if (len != -1) |
2150 | if (len >= 0) |
2149 | { |
2151 | { |
2150 | /* also comes here at end if needed because of >= above */ |
2152 | /* also comes here at end if needed because of >= above */ |
2151 | if (wlen < len) |
2153 | if (wlen < len) |
2152 | ::swap (wlen, len); |
2154 | ::swap (wlen, len); |
2153 | |
2155 | |
|
|
2156 | XGCValues gcv; |
|
|
2157 | |
|
|
2158 | gcv.graphics_exposures = 1; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); |
2154 | XCopyArea (dpy, vt, vt, |
2159 | XCopyArea (dpy, vt, vt, |
2155 | gc, 0, Row2Pixel (len + i), |
2160 | gc, 0, Row2Pixel (len + i), |
2156 | (unsigned int)this->width, |
2161 | (unsigned int)this->width, |
2157 | (unsigned int)Height2Pixel (wlen - len + 1), |
2162 | (unsigned int)Height2Pixel (wlen - len + 1), |
2158 | 0, Row2Pixel (len)); |
2163 | 0, Row2Pixel (len)); |
|
|
2164 | gcv.graphics_exposures = 0; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); |
|
|
2165 | |
2159 | len = -1; |
2166 | len = -1; |
2160 | } |
2167 | } |
2161 | } |
2168 | } |
2162 | } |
2169 | } |
2163 | #endif |
2170 | #endif |
… | |
… | |
2219 | count++; |
2226 | count++; |
2220 | |
2227 | |
2221 | if (stp[col] != dtp[col] |
2228 | if (stp[col] != dtp[col] |
2222 | || !RS_SAME (srp[col], drp[col])) |
2229 | || !RS_SAME (srp[col], drp[col])) |
2223 | { |
2230 | { |
2224 | if (must_clear && (i++ > count / 2)) |
2231 | if (have_bg && (i++ > count / 2)) |
2225 | break; |
2232 | break; |
2226 | |
2233 | |
2227 | dtp[col] = stp[col]; |
2234 | dtp[col] = stp[col]; |
2228 | drp[col] = rend; |
2235 | drp[col] = rend; |
2229 | i = 0; |
2236 | i = 0; |
2230 | } |
2237 | } |
2231 | else if (must_clear || (stp[col] != ' ' && ++i >= 16)) |
2238 | else if (have_bg || (stp[col] != ' ' && ++i >= 16)) |
2232 | break; |
2239 | break; |
2233 | } |
2240 | } |
2234 | |
2241 | |
2235 | col--; /* went one too far. move back */ |
2242 | col--; /* went one too far. move back */ |
2236 | count -= i; /* dump any matching trailing chars */ |
2243 | count -= i; /* dump any matching trailing chars */ |
… | |
… | |
2330 | */ |
2337 | */ |
2331 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2338 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2332 | |
2339 | |
2333 | if (back == fore) |
2340 | if (back == fore) |
2334 | font->clear_rect (*drawable, xpixel, ypixel, fwidth * count, fheight, back); |
2341 | font->clear_rect (*drawable, xpixel, ypixel, fwidth * count, fheight, back); |
2335 | else if (back == Color_bg) |
2342 | else if (back == Color_bg && have_bg) |
2336 | { |
2343 | { |
2337 | if (must_clear) |
2344 | // this is very ugly, maybe push it into ->draw? |
2338 | { |
|
|
2339 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2340 | |
2345 | |
2341 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2346 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2342 | if (text[i] != ' ') |
2347 | if (text[i] != ' ') |
2343 | { |
2348 | { |
2344 | font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); |
2349 | font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); |
2345 | break; |
2350 | goto did_clear; |
2346 | } |
|
|
2347 | } |
2351 | } |
2348 | else |
2352 | |
2349 | font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_bg); |
2353 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2354 | did_clear: ; |
2350 | } |
2355 | } |
2351 | else |
2356 | else |
2352 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2357 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2353 | |
2358 | |
2354 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2359 | if (rend & RS_Uline && font->descent > 1 && fore != back) |