… | |
… | |
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-2007 Marc Lehmann <schmorp@schmorp.de> |
6 | * Copyright (c) 2003-2007 Marc Lehmann <schmorp@schmorp.de> |
|
|
7 | * Copyright (c) 2015 Emanuele Giaquinta <e.giaquinta@glauco.it> |
7 | * |
8 | * |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
10 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 3 of the License, or |
11 | * the Free Software Foundation; either version 3 of the License, or |
11 | * (at your option) any later version. |
12 | * (at your option) any later version. |
… | |
… | |
614 | * Change the colour for following text |
615 | * Change the colour for following text |
615 | */ |
616 | */ |
616 | void |
617 | void |
617 | rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW |
618 | rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW |
618 | { |
619 | { |
619 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
620 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR24)) |
620 | color = fgbg; |
621 | color = fgbg; |
621 | |
622 | |
622 | if (fgbg == Color_fg) |
623 | if (fgbg == Color_fg) |
623 | rstyle = SET_FGCOLOR (rstyle, color); |
624 | rstyle = SET_FGCOLOR (rstyle, color); |
624 | else |
625 | else |
… | |
… | |
1011 | } |
1012 | } |
1012 | else if (screen.cur.row > 0 |
1013 | else if (screen.cur.row > 0 |
1013 | && ROW(screen.cur.row - 1).is_longer ()) |
1014 | && ROW(screen.cur.row - 1).is_longer ()) |
1014 | { |
1015 | { |
1015 | linep = &ROW(screen.cur.row - 1); |
1016 | linep = &ROW(screen.cur.row - 1); |
1016 | tp = line->t + ncol - 1; |
1017 | tp = linep->t + ncol - 1; |
1017 | rp = line->r + ncol - 1; |
1018 | rp = linep->r + ncol - 1; |
1018 | } |
1019 | } |
1019 | else |
1020 | else |
1020 | continue; |
1021 | continue; |
1021 | |
1022 | |
1022 | linep->touch (); |
1023 | linep->touch (); |
… | |
… | |
1713 | |
1714 | |
1714 | if (rvideo_state != on) |
1715 | if (rvideo_state != on) |
1715 | { |
1716 | { |
1716 | rvideo_state = on; |
1717 | rvideo_state = on; |
1717 | |
1718 | |
|
|
1719 | #if OFF_FOCUS_FADING |
|
|
1720 | if (rs[Rs_fade]) |
|
|
1721 | { |
|
|
1722 | ::swap (pix_colors_focused[Color_fg], pix_colors_focused[Color_bg]); |
|
|
1723 | ::swap (pix_colors_unfocused[Color_fg], pix_colors_unfocused[Color_bg]); |
|
|
1724 | } |
|
|
1725 | else |
|
|
1726 | #endif |
1718 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1727 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1719 | #ifdef HAVE_IMG |
1728 | #ifdef HAVE_IMG |
1720 | if (bg_img == 0) |
1729 | if (bg_img == 0) |
1721 | #endif |
1730 | #endif |
1722 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
1731 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
… | |
… | |
2118 | ccol2 = bgcolor_of (rstyle); |
2127 | ccol2 = bgcolor_of (rstyle); |
2119 | #else |
2128 | #else |
2120 | ccol2 = Color_bg; |
2129 | ccol2 = Color_bg; |
2121 | #endif |
2130 | #endif |
2122 | |
2131 | |
2123 | if (focus && cursor_type != 2) |
2132 | if (focus && cursor_type == 0) |
2124 | { |
2133 | { |
2125 | rend_t rend = cur_rend; |
2134 | rend_t rend = cur_rend; |
2126 | |
2135 | |
2127 | if (cursor_type == 1) |
|
|
2128 | rend ^= RS_Uline; |
|
|
2129 | else |
|
|
2130 | { |
|
|
2131 | rend ^= RS_RVid; |
2136 | rend ^= RS_RVid; |
2132 | rend = SET_FGCOLOR (rend, ccol1); |
2137 | rend = SET_FGCOLOR (rend, ccol1); |
2133 | rend = SET_BGCOLOR (rend, ccol2); |
2138 | rend = SET_BGCOLOR (rend, ccol2); |
2134 | } |
|
|
2135 | |
2139 | |
2136 | scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); |
2140 | scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); |
2137 | } |
2141 | } |
2138 | } |
2142 | } |
2139 | |
2143 | |
2140 | /* make sure no outline cursor is left around */ |
2144 | /* make sure no outline cursor is left around */ |
2141 | if (ocrow != -1) |
2145 | if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol) |
2142 | { |
|
|
2143 | if (screen.cur.row - view_start != ocrow |
|
|
2144 | || screen.cur.col != oldcursor.col || !showcursor) |
|
|
2145 | { |
|
|
2146 | if (ocrow < nrow |
|
|
2147 | && oldcursor.col < ncol) |
|
|
2148 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2146 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2149 | } |
|
|
2150 | } |
|
|
2151 | |
2147 | |
2152 | // save the current cursor coordinates if the cursor is visible |
2148 | // save the current cursor coordinates if the cursor is visible |
2153 | // and either the window is unfocused or the cursor style is |
2149 | // and either the window is unfocused or the cursor style is |
2154 | // vertical bar, so as to clear the outline cursor in the next |
2150 | // underline or vertical bar, so as to clear the outline cursor in |
2155 | // refresh if the cursor moves or becomes invisible |
2151 | // the next refresh if the cursor moves or becomes invisible |
2156 | if (showcursor && (!focus || cursor_type == 2) && screen.cur.row - view_start < nrow) |
2152 | if (showcursor && (!focus || cursor_type != 0) && screen.cur.row - view_start < nrow) |
2157 | { |
2153 | { |
2158 | oldcursor.row = screen.cur.row - view_start; |
2154 | oldcursor.row = screen.cur.row - view_start; |
2159 | oldcursor.col = screen.cur.col; |
2155 | oldcursor.col = screen.cur.col; |
2160 | } |
2156 | } |
2161 | else |
2157 | else |
… | |
… | |
2248 | int ypixel = (int)Row2Pixel (row); |
2244 | int ypixel = (int)Row2Pixel (row); |
2249 | |
2245 | |
2250 | for (col = 0; col < ncol; col++) |
2246 | for (col = 0; col < ncol; col++) |
2251 | { |
2247 | { |
2252 | /* compare new text with old - if exactly the same then continue */ |
2248 | /* compare new text with old - if exactly the same then continue */ |
2253 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2249 | if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col])) |
2254 | && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */ |
|
|
2255 | || (stp[col] == ' ' /* space w/ no background change */ |
|
|
2256 | && !((srp[col] ^ drp[col]) & (RS_attrMask | RS_bgMask))))) |
|
|
2257 | continue; |
2250 | continue; |
2258 | |
2251 | |
2259 | // redraw one or more characters |
2252 | // redraw one or more characters |
2260 | |
2253 | |
2261 | // seek to the beginning of wide characters |
2254 | // seek to the beginning of wide characters |
… | |
… | |
2458 | */ |
2451 | */ |
2459 | if (showcursor) |
2452 | if (showcursor) |
2460 | { |
2453 | { |
2461 | if (focus) |
2454 | if (focus) |
2462 | { |
2455 | { |
2463 | if (cursor_type != 2) |
2456 | if (cursor_type == 0) |
2464 | scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); |
2457 | scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); |
2465 | else if (oldcursor.row >= 0) |
2458 | else if (oldcursor.row >= 0) |
2466 | { |
2459 | { |
2467 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
2460 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
|
|
2461 | if (cursor_type == 1) |
2468 | XFillRectangle (dpy, vt, gc, |
2462 | XFillRectangle (dpy, vt, gc, |
2469 | Col2Pixel (cur_col), |
2463 | Col2Pixel (cur_col), |
|
|
2464 | Row2Pixel (oldcursor.row + 1) - 2, |
|
|
2465 | Width2Pixel (1), |
|
|
2466 | 2); |
|
|
2467 | else |
|
|
2468 | XFillRectangle (dpy, vt, gc, |
|
|
2469 | Col2Pixel (cur_col), |
2470 | Row2Pixel (oldcursor.row), |
2470 | Row2Pixel (oldcursor.row), |
2471 | 1, |
2471 | 2, |
2472 | Height2Pixel (1)); |
2472 | Height2Pixel (1)); |
2473 | } |
2473 | } |
2474 | } |
2474 | } |
2475 | else if (oldcursor.row >= 0) |
2475 | else if (oldcursor.row >= 0) |
2476 | { |
2476 | { |
2477 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
2477 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
… | |
… | |
2523 | scr_remap_chars (swap_buf [i]); |
2523 | scr_remap_chars (swap_buf [i]); |
2524 | } |
2524 | } |
2525 | } |
2525 | } |
2526 | |
2526 | |
2527 | void ecb_cold |
2527 | void ecb_cold |
2528 | rxvt_term::scr_recolour (bool refresh) NOTHROW |
2528 | rxvt_term::scr_recolor (bool refresh) NOTHROW |
2529 | { |
2529 | { |
2530 | bool transparent = false; |
2530 | bool transparent = false; |
2531 | |
2531 | |
2532 | #ifdef HAVE_IMG |
2532 | #ifdef HAVE_IMG |
2533 | if (bg_img != 0) |
2533 | if (bg_img != 0) |
… | |
… | |
2554 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
2554 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
2555 | } |
2555 | } |
2556 | |
2556 | |
2557 | XClearWindow (dpy, parent); |
2557 | XClearWindow (dpy, parent); |
2558 | |
2558 | |
2559 | if (scrollBar.win) |
2559 | if (scrollBar.state && scrollBar.win) |
2560 | { |
2560 | { |
2561 | if (transparent) |
2561 | if (transparent) |
2562 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2562 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2563 | else |
2563 | else |
2564 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); |
2564 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); |