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 */ |
… | |
… | |
2246 | int back = bgcolor_of (rend); // desired background |
2253 | int back = bgcolor_of (rend); // desired background |
2247 | |
2254 | |
2248 | // only do special processing if any attributes are set, which is unlikely |
2255 | // only do special processing if any attributes are set, which is unlikely |
2249 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2256 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2250 | { |
2257 | { |
2251 | #if ENABLE_STYLES |
|
|
2252 | // "careful" (too wide) character handling |
|
|
2253 | |
|
|
2254 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2255 | while (text > stp |
|
|
2256 | && srp[text - stp - 1] & RS_Careful |
|
|
2257 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2258 | text--, count++, xpixel -= fwidth; |
|
|
2259 | |
|
|
2260 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2261 | for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) |
|
|
2262 | drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; |
|
|
2263 | |
|
|
2264 | // force redraw before "careful" characters to avoid pixel droppings |
|
|
2265 | for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) |
|
|
2266 | drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; |
|
|
2267 | #endif |
|
|
2268 | |
|
|
2269 | bool invert = rend & RS_RVid; |
2258 | bool invert = rend & RS_RVid; |
2270 | |
2259 | |
2271 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2260 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2272 | if (rend & RS_Bold |
2261 | if (rend & RS_Bold |
2273 | && fore == Color_fg) |
2262 | && fore == Color_fg) |
… | |
… | |
2289 | else |
2278 | else |
2290 | invert = !invert; |
2279 | invert = !invert; |
2291 | # endif |
2280 | # endif |
2292 | } |
2281 | } |
2293 | |
2282 | |
2294 | if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) |
2283 | if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL)) |
2295 | fore = Color_UL; |
2284 | fore = Color_UL; |
2296 | #endif |
2285 | #endif |
2297 | |
2286 | |
2298 | if (invert) |
2287 | if (invert) |
2299 | { |
2288 | { |
|
|
2289 | #ifdef OPTION_HC |
|
|
2290 | if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col) |
|
|
2291 | || !ISSET_PIXCOLOR (Color_HC)) |
|
|
2292 | #endif |
|
|
2293 | /* invert the column if no highlightColor is set or it is the |
|
|
2294 | * current cursor column */ |
2300 | ::swap (fore, back); |
2295 | ::swap (fore, back); |
|
|
2296 | #ifdef OPTION_HC |
|
|
2297 | else if (ISSET_PIXCOLOR (Color_HC)) |
|
|
2298 | back = Color_HC; |
|
|
2299 | #endif |
2301 | |
2300 | |
2302 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2301 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
2302 | # ifndef OPTION_HC |
2303 | if (ISSET_PIXCOLOR (Color_RV)) |
2303 | if (ISSET_PIXCOLOR (Color_RV)) |
2304 | back = Color_RV; |
2304 | back = Color_RV; |
2305 | |
2305 | # endif |
2306 | if (fore == back) |
2306 | if (fore == back) |
2307 | { |
2307 | { |
2308 | fore = Color_bg; |
2308 | fore = Color_bg; |
2309 | back = Color_fg; |
2309 | back = Color_fg; |
2310 | } |
2310 | } |
… | |
… | |
2321 | } |
2321 | } |
2322 | else if (hidden_text) |
2322 | else if (hidden_text) |
2323 | fore = back; |
2323 | fore = back; |
2324 | } |
2324 | } |
2325 | #endif |
2325 | #endif |
|
|
2326 | |
|
|
2327 | #if ENABLE_STYLES |
|
|
2328 | // "careful" (too wide) character handling |
|
|
2329 | |
|
|
2330 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2331 | while (text > stp |
|
|
2332 | && srp[text - stp - 1] & RS_Careful |
|
|
2333 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2334 | text--, count++, xpixel -= fwidth; |
|
|
2335 | |
|
|
2336 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2337 | for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) |
|
|
2338 | drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; |
|
|
2339 | |
|
|
2340 | // force redraw before "careful" characters to avoid pixel droppings |
|
|
2341 | for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) |
|
|
2342 | drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; |
|
|
2343 | #endif |
2326 | } |
2344 | } |
2327 | |
2345 | |
2328 | /* |
2346 | /* |
2329 | * Actually do the drawing of the string here |
2347 | * Actually do the drawing of the string here |
2330 | */ |
2348 | */ |
2331 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2349 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2332 | |
2350 | |
2333 | if (back == fore) |
2351 | if (back == fore) |
2334 | font->clear_rect (*drawable, xpixel, ypixel, fwidth * count, fheight, back); |
2352 | font->clear_rect (*drawable, xpixel, ypixel, fwidth * count, fheight, back); |
2335 | else if (back == Color_bg) |
2353 | else if (back == Color_bg && have_bg) |
2336 | { |
2354 | { |
2337 | if (must_clear) |
2355 | // this is very ugly, maybe push it into ->draw? |
2338 | { |
|
|
2339 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2340 | |
2356 | |
2341 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2357 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2342 | if (text[i] != ' ') |
2358 | if (text[i] != ' ') |
2343 | { |
2359 | { |
2344 | font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); |
2360 | font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); |
2345 | break; |
2361 | goto did_clear; |
2346 | } |
|
|
2347 | } |
2362 | } |
2348 | else |
2363 | |
2349 | font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_bg); |
2364 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2365 | did_clear: ; |
2350 | } |
2366 | } |
2351 | else |
2367 | else |
2352 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2368 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2353 | |
2369 | |
2354 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2370 | if (rend & RS_Uline && font->descent > 1 && fore != back) |