… | |
… | |
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 2 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. |
12 | * |
13 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
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 |
… | |
… | |
715 | |
716 | |
716 | // finally move the view window, if desired |
717 | // finally move the view window, if desired |
717 | if (option (Opt_scrollWithBuffer) |
718 | if (option (Opt_scrollWithBuffer) |
718 | && view_start != 0 |
719 | && view_start != 0 |
719 | && view_start != -saveLines) |
720 | && view_start != -saveLines) |
720 | scr_page (UP, count); |
721 | scr_page (count); |
721 | |
722 | |
722 | if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) |
723 | if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) |
723 | HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); |
724 | HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); |
724 | } |
725 | } |
725 | else |
726 | 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 (); |
… | |
… | |
1240 | * direction should be UP or DN |
1241 | * direction should be UP or DN |
1241 | */ |
1242 | */ |
1242 | void |
1243 | void |
1243 | rxvt_term::scr_index (enum page_dirn direction) NOTHROW |
1244 | rxvt_term::scr_index (enum page_dirn direction) NOTHROW |
1244 | { |
1245 | { |
1245 | int dirn; |
|
|
1246 | |
|
|
1247 | want_refresh = 1; |
1246 | want_refresh = 1; |
1248 | ZERO_SCROLLBACK (); |
1247 | ZERO_SCROLLBACK (); |
1249 | |
1248 | |
1250 | dirn = ((direction == UP) ? 1 : -1); |
|
|
1251 | |
|
|
1252 | screen.flags &= ~Screen_WrapNext; |
1249 | screen.flags &= ~Screen_WrapNext; |
1253 | |
1250 | |
1254 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1251 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1255 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1252 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1256 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn); |
1253 | scr_scroll_text (screen.tscroll, screen.bscroll, direction); |
1257 | else |
1254 | else |
1258 | screen.cur.row += dirn; |
1255 | screen.cur.row += direction; |
1259 | |
1256 | |
1260 | clamp_it (screen.cur.row, 0, nrow - 1); |
1257 | clamp_it (screen.cur.row, 0, nrow - 1); |
1261 | selection_check (0); |
1258 | selection_check (0); |
1262 | } |
1259 | } |
1263 | |
1260 | |
… | |
… | |
1717 | |
1714 | |
1718 | if (rvideo_state != on) |
1715 | if (rvideo_state != on) |
1719 | { |
1716 | { |
1720 | rvideo_state = on; |
1717 | rvideo_state = on; |
1721 | |
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 |
1722 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1727 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1723 | #ifdef HAVE_IMG |
1728 | #ifdef HAVE_IMG |
1724 | if (bg_img == 0) |
1729 | if (bg_img == 0) |
1725 | #endif |
1730 | #endif |
1726 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
1731 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
… | |
… | |
1901 | * the top of the screen |
1906 | * the top of the screen |
1902 | */ |
1907 | */ |
1903 | void |
1908 | void |
1904 | rxvt_term::scr_move_to (int y, int len) NOTHROW |
1909 | rxvt_term::scr_move_to (int y, int len) NOTHROW |
1905 | { |
1910 | { |
1906 | scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); |
1911 | // lerp (y, 0, len, top_row, nrow - 1) |
|
|
1912 | scr_changeview (top_row + (nrow - 1 - top_row) * y / len); |
1907 | } |
1913 | } |
1908 | |
1914 | |
1909 | /* ------------------------------------------------------------------------- */ |
1915 | /* ------------------------------------------------------------------------- */ |
1910 | /* |
1916 | /* |
1911 | * Page the screen up/down nlines |
1917 | * Page the screen up/down nlines |
1912 | * direction should be UP or DN |
1918 | * direction should be UP or DN |
1913 | */ |
1919 | */ |
1914 | bool |
1920 | bool |
1915 | rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW |
1921 | rxvt_term::scr_page (int nlines) NOTHROW |
1916 | { |
1922 | { |
1917 | int new_view_start = |
|
|
1918 | direction == UP ? view_start - nlines |
|
|
1919 | : view_start + nlines; |
|
|
1920 | |
|
|
1921 | return scr_changeview (new_view_start); |
1923 | return scr_changeview (view_start - nlines); |
1922 | } |
1924 | } |
1923 | |
1925 | |
1924 | bool |
1926 | bool |
1925 | rxvt_term::scr_changeview (int new_view_start) NOTHROW |
1927 | rxvt_term::scr_changeview (int new_view_start) NOTHROW |
1926 | { |
1928 | { |
… | |
… | |
2083 | |
2085 | |
2084 | /* |
2086 | /* |
2085 | * C: set the cursor character (s) |
2087 | * C: set the cursor character (s) |
2086 | */ |
2088 | */ |
2087 | { |
2089 | { |
2088 | bool setoldcursor; |
|
|
2089 | |
|
|
2090 | #ifdef CURSOR_BLINK |
2090 | #ifdef CURSOR_BLINK |
2091 | if (hidden_cursor) |
2091 | if (hidden_cursor) |
2092 | showcursor = 0; |
2092 | showcursor = 0; |
2093 | #endif |
2093 | #endif |
2094 | |
2094 | |
… | |
… | |
2127 | ccol2 = bgcolor_of (rstyle); |
2127 | ccol2 = bgcolor_of (rstyle); |
2128 | #else |
2128 | #else |
2129 | ccol2 = Color_bg; |
2129 | ccol2 = Color_bg; |
2130 | #endif |
2130 | #endif |
2131 | |
2131 | |
2132 | if (focus) |
2132 | if (focus && cursor_type == 0) |
2133 | { |
2133 | { |
2134 | rend_t rend = cur_rend; |
2134 | rend_t rend = cur_rend; |
2135 | |
2135 | |
2136 | if (option (Opt_cursorUnderline)) |
|
|
2137 | rend ^= RS_Uline; |
|
|
2138 | else |
|
|
2139 | { |
|
|
2140 | rend ^= RS_RVid; |
2136 | rend ^= RS_RVid; |
2141 | rend = SET_FGCOLOR (rend, ccol1); |
2137 | rend = SET_FGCOLOR (rend, ccol1); |
2142 | rend = SET_BGCOLOR (rend, ccol2); |
2138 | rend = SET_BGCOLOR (rend, ccol2); |
2143 | } |
|
|
2144 | |
2139 | |
2145 | scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); |
2140 | scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); |
2146 | } |
2141 | } |
2147 | } |
2142 | } |
2148 | |
2143 | |
2149 | /* make sure no outline cursor is left around */ |
2144 | /* make sure no outline cursor is left around */ |
2150 | setoldcursor = 0; |
2145 | if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol) |
2151 | if (ocrow != -1) |
2146 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
|
|
2147 | |
|
|
2148 | // save the current cursor coordinates if the cursor is visible |
|
|
2149 | // and either the window is unfocused or the cursor style is |
|
|
2150 | // underline or vertical bar, so as to clear the outline cursor in |
|
|
2151 | // the next refresh if the cursor moves or becomes invisible |
|
|
2152 | if (showcursor && (!focus || cursor_type != 0) && screen.cur.row - view_start < nrow) |
2152 | { |
2153 | { |
2153 | if (screen.cur.row - view_start != ocrow |
2154 | oldcursor.row = screen.cur.row - view_start; |
2154 | || screen.cur.col != oldcursor.col) |
2155 | oldcursor.col = screen.cur.col; |
2155 | { |
|
|
2156 | if (ocrow < nrow |
|
|
2157 | && oldcursor.col < ncol) |
|
|
2158 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
|
|
2159 | |
|
|
2160 | if (focus || !showcursor) |
|
|
2161 | oldcursor.row = -1; |
|
|
2162 | else |
|
|
2163 | setoldcursor = 1; |
|
|
2164 | } |
|
|
2165 | } |
2156 | } |
2166 | else if (!focus) |
2157 | else |
2167 | setoldcursor = 1; |
|
|
2168 | |
|
|
2169 | if (setoldcursor) |
|
|
2170 | { |
|
|
2171 | if (screen.cur.row - view_start >= nrow) |
|
|
2172 | oldcursor.row = -1; |
2158 | oldcursor.row = -1; |
2173 | else |
|
|
2174 | { |
|
|
2175 | oldcursor.row = screen.cur.row - view_start; |
|
|
2176 | oldcursor.col = screen.cur.col; |
|
|
2177 | } |
|
|
2178 | } |
|
|
2179 | } |
2159 | } |
2180 | |
2160 | |
2181 | #ifndef NO_SLOW_LINK_SUPPORT |
2161 | #ifndef NO_SLOW_LINK_SUPPORT |
2182 | /* |
2162 | /* |
2183 | * D: CopyArea pass - very useful for slower links |
2163 | * D: CopyArea pass - very useful for slower links |
… | |
… | |
2264 | int ypixel = (int)Row2Pixel (row); |
2244 | int ypixel = (int)Row2Pixel (row); |
2265 | |
2245 | |
2266 | for (col = 0; col < ncol; col++) |
2246 | for (col = 0; col < ncol; col++) |
2267 | { |
2247 | { |
2268 | /* compare new text with old - if exactly the same then continue */ |
2248 | /* compare new text with old - if exactly the same then continue */ |
2269 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2249 | if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col])) |
2270 | && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */ |
|
|
2271 | || (stp[col] == ' ' /* space w/ no background change */ |
|
|
2272 | && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) |
|
|
2273 | continue; |
2250 | continue; |
2274 | |
2251 | |
2275 | // redraw one or more characters |
2252 | // redraw one or more characters |
2276 | |
2253 | |
2277 | // seek to the beginning of wide characters |
2254 | // seek to the beginning of wide characters |
… | |
… | |
2473 | * G: cleanup cursor and display outline cursor if necessary |
2450 | * G: cleanup cursor and display outline cursor if necessary |
2474 | */ |
2451 | */ |
2475 | if (showcursor) |
2452 | if (showcursor) |
2476 | { |
2453 | { |
2477 | if (focus) |
2454 | if (focus) |
|
|
2455 | { |
|
|
2456 | if (cursor_type == 0) |
2478 | 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); |
|
|
2458 | else if (oldcursor.row >= 0) |
|
|
2459 | { |
|
|
2460 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
|
|
2461 | if (cursor_type == 1) |
|
|
2462 | XFillRectangle (dpy, vt, gc, |
|
|
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), |
|
|
2471 | 2, |
|
|
2472 | Height2Pixel (1)); |
|
|
2473 | } |
|
|
2474 | } |
2479 | else if (oldcursor.row >= 0) |
2475 | else if (oldcursor.row >= 0) |
2480 | { |
2476 | { |
2481 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
2477 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
2482 | |
2478 | |
2483 | XDrawRectangle (dpy, vt, gc, |
2479 | XDrawRectangle (dpy, vt, gc, |
… | |
… | |
2527 | scr_remap_chars (swap_buf [i]); |
2523 | scr_remap_chars (swap_buf [i]); |
2528 | } |
2524 | } |
2529 | } |
2525 | } |
2530 | |
2526 | |
2531 | void ecb_cold |
2527 | void ecb_cold |
2532 | rxvt_term::scr_recolour (bool refresh) NOTHROW |
2528 | rxvt_term::scr_recolor (bool refresh) NOTHROW |
2533 | { |
2529 | { |
2534 | bool transparent = false; |
2530 | bool transparent = false; |
2535 | |
2531 | |
2536 | #ifdef HAVE_IMG |
2532 | #ifdef HAVE_IMG |
2537 | if (bg_img != 0) |
2533 | if (bg_img != 0) |
… | |
… | |
2558 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
2554 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
2559 | } |
2555 | } |
2560 | |
2556 | |
2561 | XClearWindow (dpy, parent); |
2557 | XClearWindow (dpy, parent); |
2562 | |
2558 | |
2563 | if (scrollBar.win) |
2559 | if (scrollBar.state && scrollBar.win) |
2564 | { |
2560 | { |
2565 | if (transparent) |
2561 | if (transparent) |
2566 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2562 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2567 | else |
2563 | else |
2568 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); |
2564 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); |
… | |
… | |
2696 | |
2692 | |
2697 | void |
2693 | void |
2698 | rxvt_term::selection_changed () NOTHROW |
2694 | rxvt_term::selection_changed () NOTHROW |
2699 | { |
2695 | { |
2700 | line_t &r1 = ROW (selection.beg.row); |
2696 | line_t &r1 = ROW (selection.beg.row); |
2701 | while (selection.beg.col > 0 && r1.t [selection.beg.col] == NOCHAR) |
2697 | while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR) |
2702 | --selection.beg.col; |
2698 | ++selection.beg.col; |
2703 | |
2699 | |
2704 | line_t &r2 = ROW (selection.end.row); |
2700 | line_t &r2 = ROW (selection.end.row); |
2705 | while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR) |
2701 | while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR) |
2706 | ++selection.end.col; |
2702 | ++selection.end.col; |
2707 | |
2703 | |
… | |
… | |
3504 | cl = selection.clip_text; |
3500 | cl = selection.clip_text; |
3505 | selectlen = selection.clip_len; |
3501 | selectlen = selection.clip_len; |
3506 | } |
3502 | } |
3507 | else |
3503 | else |
3508 | { |
3504 | { |
3509 | cl = L""; |
3505 | cl = (wchar_t *)L""; |
3510 | selectlen = 0; |
3506 | selectlen = 0; |
3511 | } |
3507 | } |
3512 | |
3508 | |
3513 | #if !ENABLE_MINIMAL |
3509 | #if !ENABLE_MINIMAL |
3514 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
3510 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |