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.438 by sf-exg, Mon Mar 25 15:41:07 2013 UTC vs.
Revision 1.454 by sf-exg, Sun Jan 18 13:08:46 2015 UTC

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 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * 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 9 * 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 10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
715 715
716 // finally move the view window, if desired 716 // finally move the view window, if desired
717 if (option (Opt_scrollWithBuffer) 717 if (option (Opt_scrollWithBuffer)
718 && view_start != 0 718 && view_start != 0
719 && view_start != -saveLines) 719 && view_start != -saveLines)
720 scr_page (UP, count); 720 scr_page (count);
721 721
722 if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) 722 if (SHOULD_INVOKE (HOOK_SCROLL_BACK))
723 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); 723 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END));
724 } 724 }
725 else 725 else
1240 * direction should be UP or DN 1240 * direction should be UP or DN
1241 */ 1241 */
1242void 1242void
1243rxvt_term::scr_index (enum page_dirn direction) NOTHROW 1243rxvt_term::scr_index (enum page_dirn direction) NOTHROW
1244{ 1244{
1245 int dirn;
1246
1247 want_refresh = 1; 1245 want_refresh = 1;
1248 ZERO_SCROLLBACK (); 1246 ZERO_SCROLLBACK ();
1249 1247
1250 dirn = ((direction == UP) ? 1 : -1);
1251
1252 screen.flags &= ~Screen_WrapNext; 1248 screen.flags &= ~Screen_WrapNext;
1253 1249
1254 if ((screen.cur.row == screen.bscroll && direction == UP) 1250 if ((screen.cur.row == screen.bscroll && direction == UP)
1255 || (screen.cur.row == screen.tscroll && direction == DN)) 1251 || (screen.cur.row == screen.tscroll && direction == DN))
1256 scr_scroll_text (screen.tscroll, screen.bscroll, dirn); 1252 scr_scroll_text (screen.tscroll, screen.bscroll, direction);
1257 else 1253 else
1258 screen.cur.row += dirn; 1254 screen.cur.row += direction;
1259 1255
1260 clamp_it (screen.cur.row, 0, nrow - 1); 1256 clamp_it (screen.cur.row, 0, nrow - 1);
1261 selection_check (0); 1257 selection_check (0);
1262} 1258}
1263 1259
1901 * the top of the screen 1897 * the top of the screen
1902 */ 1898 */
1903void 1899void
1904rxvt_term::scr_move_to (int y, int len) NOTHROW 1900rxvt_term::scr_move_to (int y, int len) NOTHROW
1905{ 1901{
1906 scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); 1902 // lerp (y, 0, len, top_row, nrow - 1)
1903 scr_changeview (top_row + (nrow - 1 - top_row) * y / len);
1907} 1904}
1908 1905
1909/* ------------------------------------------------------------------------- */ 1906/* ------------------------------------------------------------------------- */
1910/* 1907/*
1911 * Page the screen up/down nlines 1908 * Page the screen up/down nlines
1912 * direction should be UP or DN 1909 * direction should be UP or DN
1913 */ 1910 */
1914bool 1911bool
1915rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW 1912rxvt_term::scr_page (int nlines) NOTHROW
1916{ 1913{
1917 int new_view_start =
1918 direction == UP ? view_start - nlines
1919 : view_start + nlines;
1920
1921 return scr_changeview (new_view_start); 1914 return scr_changeview (view_start - nlines);
1922} 1915}
1923 1916
1924bool 1917bool
1925rxvt_term::scr_changeview (int new_view_start) NOTHROW 1918rxvt_term::scr_changeview (int new_view_start) NOTHROW
1926{ 1919{
2083 2076
2084 /* 2077 /*
2085 * C: set the cursor character (s) 2078 * C: set the cursor character (s)
2086 */ 2079 */
2087 { 2080 {
2088 bool setoldcursor;
2089
2090#ifdef CURSOR_BLINK 2081#ifdef CURSOR_BLINK
2091 if (hidden_cursor) 2082 if (hidden_cursor)
2092 showcursor = 0; 2083 showcursor = 0;
2093#endif 2084#endif
2094 2085
2127 ccol2 = bgcolor_of (rstyle); 2118 ccol2 = bgcolor_of (rstyle);
2128#else 2119#else
2129 ccol2 = Color_bg; 2120 ccol2 = Color_bg;
2130#endif 2121#endif
2131 2122
2132 if (focus) 2123 if (focus && cursor_type == 0)
2133 { 2124 {
2134 rend_t rend = cur_rend; 2125 rend_t rend = cur_rend;
2135 2126
2136 if (option (Opt_cursorUnderline))
2137 rend ^= RS_Uline;
2138 else
2139 {
2140 rend ^= RS_RVid; 2127 rend ^= RS_RVid;
2141 rend = SET_FGCOLOR (rend, ccol1); 2128 rend = SET_FGCOLOR (rend, ccol1);
2142 rend = SET_BGCOLOR (rend, ccol2); 2129 rend = SET_BGCOLOR (rend, ccol2);
2143 }
2144 2130
2145 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); 2131 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend);
2146 } 2132 }
2147 } 2133 }
2148 2134
2149 /* make sure no outline cursor is left around */ 2135 /* make sure no outline cursor is left around */
2150 setoldcursor = 0; 2136 if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol)
2151 if (ocrow != -1) 2137 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2138
2139 // save the current cursor coordinates if the cursor is visible
2140 // and either the window is unfocused or the cursor style is
2141 // underline or vertical bar, so as to clear the outline cursor in
2142 // the next refresh if the cursor moves or becomes invisible
2143 if (showcursor && (!focus || cursor_type != 0) && screen.cur.row - view_start < nrow)
2152 { 2144 {
2153 if (screen.cur.row - view_start != ocrow 2145 oldcursor.row = screen.cur.row - view_start;
2154 || screen.cur.col != oldcursor.col) 2146 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 } 2147 }
2166 else if (!focus) 2148 else
2167 setoldcursor = 1;
2168
2169 if (setoldcursor)
2170 {
2171 if (screen.cur.row - view_start >= nrow)
2172 oldcursor.row = -1; 2149 oldcursor.row = -1;
2173 else
2174 {
2175 oldcursor.row = screen.cur.row - view_start;
2176 oldcursor.col = screen.cur.col;
2177 }
2178 }
2179 } 2150 }
2180 2151
2181#ifndef NO_SLOW_LINK_SUPPORT 2152#ifndef NO_SLOW_LINK_SUPPORT
2182 /* 2153 /*
2183 * D: CopyArea pass - very useful for slower links 2154 * D: CopyArea pass - very useful for slower links
2264 int ypixel = (int)Row2Pixel (row); 2235 int ypixel = (int)Row2Pixel (row);
2265 2236
2266 for (col = 0; col < ncol; col++) 2237 for (col = 0; col < ncol; col++)
2267 { 2238 {
2268 /* compare new text with old - if exactly the same then continue */ 2239 /* compare new text with old - if exactly the same then continue */
2269 if (stp[col] == dtp[col] /* Must match characters to skip. */ 2240 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; 2241 continue;
2274 2242
2275 // redraw one or more characters 2243 // redraw one or more characters
2276 2244
2277 // seek to the beginning of wide characters 2245 // seek to the beginning of wide characters
2473 * G: cleanup cursor and display outline cursor if necessary 2441 * G: cleanup cursor and display outline cursor if necessary
2474 */ 2442 */
2475 if (showcursor) 2443 if (showcursor)
2476 { 2444 {
2477 if (focus) 2445 if (focus)
2446 {
2447 if (cursor_type == 0)
2478 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); 2448 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend);
2449 else if (oldcursor.row >= 0)
2450 {
2451 XSetForeground (dpy, gc, pix_colors[ccol1]);
2452 if (cursor_type == 1)
2453 XFillRectangle (dpy, vt, gc,
2454 Col2Pixel (cur_col),
2455 Row2Pixel (oldcursor.row + 1) - 2,
2456 Width2Pixel (1),
2457 2);
2458 else
2459 XFillRectangle (dpy, vt, gc,
2460 Col2Pixel (cur_col),
2461 Row2Pixel (oldcursor.row),
2462 2,
2463 Height2Pixel (1));
2464 }
2465 }
2479 else if (oldcursor.row >= 0) 2466 else if (oldcursor.row >= 0)
2480 { 2467 {
2481 XSetForeground (dpy, gc, pix_colors[ccol1]); 2468 XSetForeground (dpy, gc, pix_colors[ccol1]);
2482 2469
2483 XDrawRectangle (dpy, vt, gc, 2470 XDrawRectangle (dpy, vt, gc,
2527 scr_remap_chars (swap_buf [i]); 2514 scr_remap_chars (swap_buf [i]);
2528 } 2515 }
2529} 2516}
2530 2517
2531void ecb_cold 2518void ecb_cold
2532rxvt_term::scr_recolour (bool refresh) NOTHROW 2519rxvt_term::scr_recolor (bool refresh) NOTHROW
2533{ 2520{
2534 bool transparent = false; 2521 bool transparent = false;
2535 2522
2536#ifdef HAVE_IMG 2523#ifdef HAVE_IMG
2537 if (bg_img != 0) 2524 if (bg_img != 0)
2558 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 2545 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2559 } 2546 }
2560 2547
2561 XClearWindow (dpy, parent); 2548 XClearWindow (dpy, parent);
2562 2549
2563 if (scrollBar.win) 2550 if (scrollBar.state && scrollBar.win)
2564 { 2551 {
2565 if (transparent) 2552 if (transparent)
2566 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); 2553 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2567 else 2554 else
2568 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); 2555 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]);
2696 2683
2697void 2684void
2698rxvt_term::selection_changed () NOTHROW 2685rxvt_term::selection_changed () NOTHROW
2699{ 2686{
2700 line_t &r1 = ROW (selection.beg.row); 2687 line_t &r1 = ROW (selection.beg.row);
2701 while (selection.beg.col > 0 && r1.t [selection.beg.col] == NOCHAR) 2688 while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR)
2702 --selection.beg.col; 2689 ++selection.beg.col;
2703 2690
2704 line_t &r2 = ROW (selection.end.row); 2691 line_t &r2 = ROW (selection.end.row);
2705 while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR) 2692 while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR)
2706 ++selection.end.col; 2693 ++selection.end.col;
2707 2694

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines