ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.436 by sf-exg, Sun Mar 24 10:15:27 2013 UTC vs.
Revision 1.456 by sf-exg, Tue Oct 13 08:10:43 2015 UTC

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
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 */
1242void 1243void
1243rxvt_term::scr_index (enum page_dirn direction) NOTHROW 1244rxvt_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
1901 * the top of the screen 1898 * the top of the screen
1902 */ 1899 */
1903void 1900void
1904rxvt_term::scr_move_to (int y, int len) NOTHROW 1901rxvt_term::scr_move_to (int y, int len) NOTHROW
1905{ 1902{
1906 scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); 1903 // lerp (y, 0, len, top_row, nrow - 1)
1904 scr_changeview (top_row + (nrow - 1 - top_row) * y / len);
1907} 1905}
1908 1906
1909/* ------------------------------------------------------------------------- */ 1907/* ------------------------------------------------------------------------- */
1910/* 1908/*
1911 * Page the screen up/down nlines 1909 * Page the screen up/down nlines
1912 * direction should be UP or DN 1910 * direction should be UP or DN
1913 */ 1911 */
1914bool 1912bool
1915rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW 1913rxvt_term::scr_page (int nlines) NOTHROW
1916{ 1914{
1917 int new_view_start =
1918 direction == UP ? view_start - nlines
1919 : view_start + nlines;
1920
1921 return scr_changeview (new_view_start); 1915 return scr_changeview (view_start - nlines);
1922} 1916}
1923 1917
1924bool 1918bool
1925rxvt_term::scr_changeview (int new_view_start) NOTHROW 1919rxvt_term::scr_changeview (int new_view_start) NOTHROW
1926{ 1920{
2048 int i; /* tmp */ 2042 int i; /* tmp */
2049 rend_t ccol1, /* Cursor colour */ 2043 rend_t ccol1, /* Cursor colour */
2050 ccol2; /* Cursor colour2 */ 2044 ccol2; /* Cursor colour2 */
2051 rend_t cur_rend; 2045 rend_t cur_rend;
2052 int cur_col; 2046 int cur_col;
2047 int cursorwidth;
2053 2048
2054 want_refresh = 0; /* screen is current */ 2049 want_refresh = 0; /* screen is current */
2055 2050
2056 if (refresh_type == NO_REFRESH || !mapped) 2051 if (refresh_type == NO_REFRESH || !mapped)
2057 return; 2052 return;
2082 2077
2083 /* 2078 /*
2084 * C: set the cursor character (s) 2079 * C: set the cursor character (s)
2085 */ 2080 */
2086 { 2081 {
2087 bool setoldcursor;
2088
2089#ifdef CURSOR_BLINK 2082#ifdef CURSOR_BLINK
2090 if (hidden_cursor) 2083 if (hidden_cursor)
2091 showcursor = 0; 2084 showcursor = 0;
2092#endif 2085#endif
2093 2086
2095 { 2088 {
2096 int col = screen.cur.col; 2089 int col = screen.cur.col;
2097 2090
2098 while (col && ROW(screen.cur.row).t[col] == NOCHAR) 2091 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2099 col--; 2092 col--;
2093
2094 cursorwidth = 1;
2095 while (col + cursorwidth < ncol
2096 && ROW(screen.cur.row).t[col + cursorwidth] == NOCHAR)
2097 cursorwidth++;
2100 2098
2101 cur_rend = ROW(screen.cur.row).r[col]; 2099 cur_rend = ROW(screen.cur.row).r[col];
2102 cur_col = col; 2100 cur_col = col;
2103 2101
2104#ifndef NO_CURSORCOLOR 2102#ifndef NO_CURSORCOLOR
2121 ccol2 = bgcolor_of (rstyle); 2119 ccol2 = bgcolor_of (rstyle);
2122#else 2120#else
2123 ccol2 = Color_bg; 2121 ccol2 = Color_bg;
2124#endif 2122#endif
2125 2123
2126 if (focus) 2124 if (focus && cursor_type == 0)
2127 { 2125 {
2128 rend_t rend = cur_rend; 2126 rend_t rend = cur_rend;
2129 2127
2130 if (option (Opt_cursorUnderline))
2131 rend ^= RS_Uline;
2132 else
2133 {
2134 rend ^= RS_RVid; 2128 rend ^= RS_RVid;
2135 rend = SET_FGCOLOR (rend, ccol1); 2129 rend = SET_FGCOLOR (rend, ccol1);
2136 rend = SET_BGCOLOR (rend, ccol2); 2130 rend = SET_BGCOLOR (rend, ccol2);
2137 }
2138 2131
2139 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); 2132 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend);
2140 } 2133 }
2141 } 2134 }
2142 2135
2143 /* make sure no outline cursor is left around */ 2136 /* make sure no outline cursor is left around */
2144 setoldcursor = 0; 2137 if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol)
2145 if (ocrow != -1) 2138 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2139
2140 // save the current cursor coordinates if the cursor is visible
2141 // and either the window is unfocused or the cursor style is
2142 // underline or vertical bar, so as to clear the outline cursor in
2143 // the next refresh if the cursor moves or becomes invisible
2144 if (showcursor && (!focus || cursor_type != 0) && screen.cur.row - view_start < nrow)
2146 { 2145 {
2147 if (screen.cur.row - view_start != ocrow 2146 oldcursor.row = screen.cur.row - view_start;
2148 || screen.cur.col != oldcursor.col) 2147 oldcursor.col = screen.cur.col;
2149 {
2150 if (ocrow < nrow
2151 && oldcursor.col < ncol)
2152 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2153
2154 if (focus || !showcursor)
2155 oldcursor.row = -1;
2156 else
2157 setoldcursor = 1;
2158 }
2159 } 2148 }
2160 else if (!focus) 2149 else
2161 setoldcursor = 1;
2162
2163 if (setoldcursor)
2164 {
2165 if (screen.cur.row - view_start >= nrow)
2166 oldcursor.row = -1; 2150 oldcursor.row = -1;
2167 else
2168 {
2169 oldcursor.row = screen.cur.row - view_start;
2170 oldcursor.col = screen.cur.col;
2171 }
2172 }
2173 } 2151 }
2174 2152
2175#ifndef NO_SLOW_LINK_SUPPORT 2153#ifndef NO_SLOW_LINK_SUPPORT
2176 /* 2154 /*
2177 * D: CopyArea pass - very useful for slower links 2155 * D: CopyArea pass - very useful for slower links
2258 int ypixel = (int)Row2Pixel (row); 2236 int ypixel = (int)Row2Pixel (row);
2259 2237
2260 for (col = 0; col < ncol; col++) 2238 for (col = 0; col < ncol; col++)
2261 { 2239 {
2262 /* compare new text with old - if exactly the same then continue */ 2240 /* compare new text with old - if exactly the same then continue */
2263 if (stp[col] == dtp[col] /* Must match characters to skip. */ 2241 if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col]))
2264 && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */
2265 || (stp[col] == ' ' /* space w/ no background change */
2266 && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col]))))
2267 continue; 2242 continue;
2268 2243
2269 // redraw one or more characters 2244 // redraw one or more characters
2270 2245
2271 // seek to the beginning of wide characters 2246 // seek to the beginning of wide characters
2443 else 2418 else
2444 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2419 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2445 2420
2446 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) 2421 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back))
2447 { 2422 {
2423 if (showcursor && focus && row == screen.cur.row
2424 && IN_RANGE_EXC (col, cur_col, cur_col + cursorwidth))
2425 XSetForeground (dpy, gc, pix_colors[ccol1]);
2426 else
2448#if ENABLE_FRILLS 2427#if ENABLE_FRILLS
2449 if (ISSET_PIXCOLOR (Color_underline)) 2428 if (ISSET_PIXCOLOR (Color_underline))
2450 XSetForeground (dpy, gc, pix_colors[Color_underline]); 2429 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2451 else 2430 else
2452#endif 2431#endif
2463 * G: cleanup cursor and display outline cursor if necessary 2442 * G: cleanup cursor and display outline cursor if necessary
2464 */ 2443 */
2465 if (showcursor) 2444 if (showcursor)
2466 { 2445 {
2467 if (focus) 2446 if (focus)
2447 {
2448 if (cursor_type == 0)
2468 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); 2449 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend);
2450 else if (oldcursor.row >= 0)
2451 {
2452 XSetForeground (dpy, gc, pix_colors[ccol1]);
2453 if (cursor_type == 1)
2454 XFillRectangle (dpy, vt, gc,
2455 Col2Pixel (cur_col),
2456 Row2Pixel (oldcursor.row + 1) - 2,
2457 Width2Pixel (1),
2458 2);
2459 else
2460 XFillRectangle (dpy, vt, gc,
2461 Col2Pixel (cur_col),
2462 Row2Pixel (oldcursor.row),
2463 2,
2464 Height2Pixel (1));
2465 }
2466 }
2469 else if (oldcursor.row >= 0) 2467 else if (oldcursor.row >= 0)
2470 { 2468 {
2471 int cursorwidth = 1;
2472 int col = oldcursor.col;
2473
2474 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2475 col--;
2476
2477 while (col + cursorwidth < ncol
2478 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR)
2479 cursorwidth++;
2480
2481#ifndef NO_CURSORCOLOR
2482 if (ISSET_PIXCOLOR (Color_cursor))
2483 XSetForeground (dpy, gc, pix_colors[Color_cursor]);
2484 else
2485#endif
2486 XSetForeground (dpy, gc, pix_colors[ccol1]); 2469 XSetForeground (dpy, gc, pix_colors[ccol1]);
2487 2470
2488 XDrawRectangle (dpy, vt, gc, 2471 XDrawRectangle (dpy, vt, gc,
2489 Col2Pixel (col), 2472 Col2Pixel (cur_col),
2490 Row2Pixel (oldcursor.row), 2473 Row2Pixel (oldcursor.row),
2491 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2474 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2492 (unsigned int) (Height2Pixel (1) - 1)); 2475 (unsigned int) (Height2Pixel (1) - 1));
2493 } 2476 }
2494 } 2477 }
2532 scr_remap_chars (swap_buf [i]); 2515 scr_remap_chars (swap_buf [i]);
2533 } 2516 }
2534} 2517}
2535 2518
2536void ecb_cold 2519void ecb_cold
2537rxvt_term::scr_recolour (bool refresh) NOTHROW 2520rxvt_term::scr_recolor (bool refresh) NOTHROW
2538{ 2521{
2539 bool transparent = false; 2522 bool transparent = false;
2540 2523
2541#ifdef HAVE_IMG 2524#ifdef HAVE_IMG
2542 if (bg_img != 0) 2525 if (bg_img != 0)
2563 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 2546 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2564 } 2547 }
2565 2548
2566 XClearWindow (dpy, parent); 2549 XClearWindow (dpy, parent);
2567 2550
2568 if (scrollBar.win) 2551 if (scrollBar.state && scrollBar.win)
2569 { 2552 {
2570 if (transparent) 2553 if (transparent)
2571 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); 2554 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2572 else 2555 else
2573 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); 2556 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]);
2701 2684
2702void 2685void
2703rxvt_term::selection_changed () NOTHROW 2686rxvt_term::selection_changed () NOTHROW
2704{ 2687{
2705 line_t &r1 = ROW (selection.beg.row); 2688 line_t &r1 = ROW (selection.beg.row);
2706 while (selection.beg.col > 0 && r1.t [selection.beg.col] == NOCHAR) 2689 while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR)
2707 --selection.beg.col; 2690 ++selection.beg.col;
2708 2691
2709 line_t &r2 = ROW (selection.end.row); 2692 line_t &r2 = ROW (selection.end.row);
2710 while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR) 2693 while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR)
2711 ++selection.end.col; 2694 ++selection.end.col;
2712 2695

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines