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.435 by sf-exg, Sun Mar 24 10:12:04 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
254 254
255 scr_alloc (); 255 scr_alloc ();
256 256
257 if (!prev_row_buf) 257 if (!prev_row_buf)
258 { 258 {
259 /*
260 * first time called (or after scr_release) so just malloc everything: don't rely on realloc
261 */
262 top_row = 0; 259 top_row = 0;
263 term_start = 0; 260 term_start = 0;
264 261
265 memset (charsets, 'B', sizeof (charsets)); 262 memset (charsets, 'B', sizeof (charsets));
266 rstyle = DEFAULT_RSTYLE; 263 rstyle = DEFAULT_RSTYLE;
718 715
719 // finally move the view window, if desired 716 // finally move the view window, if desired
720 if (option (Opt_scrollWithBuffer) 717 if (option (Opt_scrollWithBuffer)
721 && view_start != 0 718 && view_start != 0
722 && view_start != -saveLines) 719 && view_start != -saveLines)
723 scr_page (UP, count); 720 scr_page (count);
724 721
725 if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) 722 if (SHOULD_INVOKE (HOOK_SCROLL_BACK))
726 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));
727 } 724 }
728 else 725 else
1243 * direction should be UP or DN 1240 * direction should be UP or DN
1244 */ 1241 */
1245void 1242void
1246rxvt_term::scr_index (enum page_dirn direction) NOTHROW 1243rxvt_term::scr_index (enum page_dirn direction) NOTHROW
1247{ 1244{
1248 int dirn;
1249
1250 want_refresh = 1; 1245 want_refresh = 1;
1251 ZERO_SCROLLBACK (); 1246 ZERO_SCROLLBACK ();
1252 1247
1253 dirn = ((direction == UP) ? 1 : -1);
1254
1255 screen.flags &= ~Screen_WrapNext; 1248 screen.flags &= ~Screen_WrapNext;
1256 1249
1257 if ((screen.cur.row == screen.bscroll && direction == UP) 1250 if ((screen.cur.row == screen.bscroll && direction == UP)
1258 || (screen.cur.row == screen.tscroll && direction == DN)) 1251 || (screen.cur.row == screen.tscroll && direction == DN))
1259 scr_scroll_text (screen.tscroll, screen.bscroll, dirn); 1252 scr_scroll_text (screen.tscroll, screen.bscroll, direction);
1260 else 1253 else
1261 screen.cur.row += dirn; 1254 screen.cur.row += direction;
1262 1255
1263 clamp_it (screen.cur.row, 0, nrow - 1); 1256 clamp_it (screen.cur.row, 0, nrow - 1);
1264 selection_check (0); 1257 selection_check (0);
1265} 1258}
1266 1259
1904 * the top of the screen 1897 * the top of the screen
1905 */ 1898 */
1906void 1899void
1907rxvt_term::scr_move_to (int y, int len) NOTHROW 1900rxvt_term::scr_move_to (int y, int len) NOTHROW
1908{ 1901{
1909 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);
1910} 1904}
1911 1905
1912/* ------------------------------------------------------------------------- */ 1906/* ------------------------------------------------------------------------- */
1913/* 1907/*
1914 * Page the screen up/down nlines 1908 * Page the screen up/down nlines
1915 * direction should be UP or DN 1909 * direction should be UP or DN
1916 */ 1910 */
1917bool 1911bool
1918rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW 1912rxvt_term::scr_page (int nlines) NOTHROW
1919{ 1913{
1920 int new_view_start =
1921 direction == UP ? view_start - nlines
1922 : view_start + nlines;
1923
1924 return scr_changeview (new_view_start); 1914 return scr_changeview (view_start - nlines);
1925} 1915}
1926 1916
1927bool 1917bool
1928rxvt_term::scr_changeview (int new_view_start) NOTHROW 1918rxvt_term::scr_changeview (int new_view_start) NOTHROW
1929{ 1919{
2051 int i; /* tmp */ 2041 int i; /* tmp */
2052 rend_t ccol1, /* Cursor colour */ 2042 rend_t ccol1, /* Cursor colour */
2053 ccol2; /* Cursor colour2 */ 2043 ccol2; /* Cursor colour2 */
2054 rend_t cur_rend; 2044 rend_t cur_rend;
2055 int cur_col; 2045 int cur_col;
2046 int cursorwidth;
2056 2047
2057 want_refresh = 0; /* screen is current */ 2048 want_refresh = 0; /* screen is current */
2058 2049
2059 if (refresh_type == NO_REFRESH || !mapped) 2050 if (refresh_type == NO_REFRESH || !mapped)
2060 return; 2051 return;
2085 2076
2086 /* 2077 /*
2087 * C: set the cursor character (s) 2078 * C: set the cursor character (s)
2088 */ 2079 */
2089 { 2080 {
2090 bool setoldcursor;
2091
2092#ifdef CURSOR_BLINK 2081#ifdef CURSOR_BLINK
2093 if (hidden_cursor) 2082 if (hidden_cursor)
2094 showcursor = 0; 2083 showcursor = 0;
2095#endif 2084#endif
2096 2085
2098 { 2087 {
2099 int col = screen.cur.col; 2088 int col = screen.cur.col;
2100 2089
2101 while (col && ROW(screen.cur.row).t[col] == NOCHAR) 2090 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2102 col--; 2091 col--;
2092
2093 cursorwidth = 1;
2094 while (col + cursorwidth < ncol
2095 && ROW(screen.cur.row).t[col + cursorwidth] == NOCHAR)
2096 cursorwidth++;
2103 2097
2104 cur_rend = ROW(screen.cur.row).r[col]; 2098 cur_rend = ROW(screen.cur.row).r[col];
2105 cur_col = col; 2099 cur_col = col;
2106 2100
2107#ifndef NO_CURSORCOLOR 2101#ifndef NO_CURSORCOLOR
2124 ccol2 = bgcolor_of (rstyle); 2118 ccol2 = bgcolor_of (rstyle);
2125#else 2119#else
2126 ccol2 = Color_bg; 2120 ccol2 = Color_bg;
2127#endif 2121#endif
2128 2122
2129 if (focus) 2123 if (focus && cursor_type == 0)
2130 { 2124 {
2131 rend_t rend = cur_rend; 2125 rend_t rend = cur_rend;
2132 2126
2133 if (option (Opt_cursorUnderline))
2134 rend ^= RS_Uline;
2135 else
2136 {
2137 rend ^= RS_RVid; 2127 rend ^= RS_RVid;
2138 rend = SET_FGCOLOR (rend, ccol1); 2128 rend = SET_FGCOLOR (rend, ccol1);
2139 rend = SET_BGCOLOR (rend, ccol2); 2129 rend = SET_BGCOLOR (rend, ccol2);
2140 }
2141 2130
2142 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); 2131 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend);
2143 } 2132 }
2144 } 2133 }
2145 2134
2146 /* make sure no outline cursor is left around */ 2135 /* make sure no outline cursor is left around */
2147 setoldcursor = 0; 2136 if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol)
2148 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)
2149 { 2144 {
2150 if (screen.cur.row - view_start != ocrow 2145 oldcursor.row = screen.cur.row - view_start;
2151 || screen.cur.col != oldcursor.col) 2146 oldcursor.col = screen.cur.col;
2152 {
2153 if (ocrow < nrow
2154 && oldcursor.col < ncol)
2155 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2156
2157 if (focus || !showcursor)
2158 oldcursor.row = -1;
2159 else
2160 setoldcursor = 1;
2161 }
2162 } 2147 }
2163 else if (!focus) 2148 else
2164 setoldcursor = 1;
2165
2166 if (setoldcursor)
2167 {
2168 if (screen.cur.row - view_start >= nrow)
2169 oldcursor.row = -1; 2149 oldcursor.row = -1;
2170 else
2171 {
2172 oldcursor.row = screen.cur.row - view_start;
2173 oldcursor.col = screen.cur.col;
2174 }
2175 }
2176 } 2150 }
2177 2151
2178#ifndef NO_SLOW_LINK_SUPPORT 2152#ifndef NO_SLOW_LINK_SUPPORT
2179 /* 2153 /*
2180 * D: CopyArea pass - very useful for slower links 2154 * D: CopyArea pass - very useful for slower links
2261 int ypixel = (int)Row2Pixel (row); 2235 int ypixel = (int)Row2Pixel (row);
2262 2236
2263 for (col = 0; col < ncol; col++) 2237 for (col = 0; col < ncol; col++)
2264 { 2238 {
2265 /* compare new text with old - if exactly the same then continue */ 2239 /* compare new text with old - if exactly the same then continue */
2266 if (stp[col] == dtp[col] /* Must match characters to skip. */ 2240 if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col]))
2267 && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */
2268 || (stp[col] == ' ' /* space w/ no background change */
2269 && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col]))))
2270 continue; 2241 continue;
2271 2242
2272 // redraw one or more characters 2243 // redraw one or more characters
2273 2244
2274 // seek to the beginning of wide characters 2245 // seek to the beginning of wide characters
2446 else 2417 else
2447 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2418 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2448 2419
2449 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) 2420 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back))
2450 { 2421 {
2422 if (showcursor && focus && row == screen.cur.row
2423 && IN_RANGE_EXC (col, cur_col, cur_col + cursorwidth))
2424 XSetForeground (dpy, gc, pix_colors[ccol1]);
2425 else
2451#if ENABLE_FRILLS 2426#if ENABLE_FRILLS
2452 if (ISSET_PIXCOLOR (Color_underline)) 2427 if (ISSET_PIXCOLOR (Color_underline))
2453 XSetForeground (dpy, gc, pix_colors[Color_underline]); 2428 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2454 else 2429 else
2455#endif 2430#endif
2466 * G: cleanup cursor and display outline cursor if necessary 2441 * G: cleanup cursor and display outline cursor if necessary
2467 */ 2442 */
2468 if (showcursor) 2443 if (showcursor)
2469 { 2444 {
2470 if (focus) 2445 if (focus)
2446 {
2447 if (cursor_type == 0)
2471 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 }
2472 else if (oldcursor.row >= 0) 2466 else if (oldcursor.row >= 0)
2473 { 2467 {
2474 int cursorwidth = 1;
2475 int col = oldcursor.col;
2476
2477 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2478 col--;
2479
2480 while (col + cursorwidth < ncol
2481 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR)
2482 cursorwidth++;
2483
2484#ifndef NO_CURSORCOLOR
2485 if (ISSET_PIXCOLOR (Color_cursor))
2486 XSetForeground (dpy, gc, pix_colors[Color_cursor]);
2487 else
2488#endif
2489 XSetForeground (dpy, gc, pix_colors[ccol1]); 2468 XSetForeground (dpy, gc, pix_colors[ccol1]);
2490 2469
2491 XDrawRectangle (dpy, vt, gc, 2470 XDrawRectangle (dpy, vt, gc,
2492 Col2Pixel (col), 2471 Col2Pixel (cur_col),
2493 Row2Pixel (oldcursor.row), 2472 Row2Pixel (oldcursor.row),
2494 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2473 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2495 (unsigned int) (Height2Pixel (1) - 1)); 2474 (unsigned int) (Height2Pixel (1) - 1));
2496 } 2475 }
2497 } 2476 }
2535 scr_remap_chars (swap_buf [i]); 2514 scr_remap_chars (swap_buf [i]);
2536 } 2515 }
2537} 2516}
2538 2517
2539void ecb_cold 2518void ecb_cold
2540rxvt_term::scr_recolour (bool refresh) NOTHROW 2519rxvt_term::scr_recolor (bool refresh) NOTHROW
2541{ 2520{
2542 bool transparent = false; 2521 bool transparent = false;
2543 2522
2544#ifdef HAVE_IMG 2523#ifdef HAVE_IMG
2545 if (bg_img != 0) 2524 if (bg_img != 0)
2566 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 2545 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2567 } 2546 }
2568 2547
2569 XClearWindow (dpy, parent); 2548 XClearWindow (dpy, parent);
2570 2549
2571 if (scrollBar.win) 2550 if (scrollBar.state && scrollBar.win)
2572 { 2551 {
2573 if (transparent) 2552 if (transparent)
2574 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); 2553 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2575 else 2554 else
2576 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); 2555 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]);
2704 2683
2705void 2684void
2706rxvt_term::selection_changed () NOTHROW 2685rxvt_term::selection_changed () NOTHROW
2707{ 2686{
2708 line_t &r1 = ROW (selection.beg.row); 2687 line_t &r1 = ROW (selection.beg.row);
2709 while (selection.beg.col > 0 && r1.t [selection.beg.col] == NOCHAR) 2688 while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR)
2710 --selection.beg.col; 2689 ++selection.beg.col;
2711 2690
2712 line_t &r2 = ROW (selection.end.row); 2691 line_t &r2 = ROW (selection.end.row);
2713 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)
2714 ++selection.end.col; 2693 ++selection.end.col;
2715 2694

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines