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.439 by sf-exg, Mon Mar 25 16:24:18 2013 UTC vs.
Revision 1.452 by root, Sat Dec 13 09:49:48 2014 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{
2125 ccol2 = bgcolor_of (rstyle); 2118 ccol2 = bgcolor_of (rstyle);
2126#else 2119#else
2127 ccol2 = Color_bg; 2120 ccol2 = Color_bg;
2128#endif 2121#endif
2129 2122
2130 if (focus) 2123 if (focus && cursor_type != 2)
2131 { 2124 {
2132 rend_t rend = cur_rend; 2125 rend_t rend = cur_rend;
2133 2126
2134 if (option (Opt_cursorUnderline)) 2127 if (cursor_type == 1)
2135 rend ^= RS_Uline; 2128 rend ^= RS_Uline;
2136 else 2129 else
2137 { 2130 {
2138 rend ^= RS_RVid; 2131 rend ^= RS_RVid;
2139 rend = SET_FGCOLOR (rend, ccol1); 2132 rend = SET_FGCOLOR (rend, ccol1);
2143 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); 2136 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend);
2144 } 2137 }
2145 } 2138 }
2146 2139
2147 /* make sure no outline cursor is left around */ 2140 /* make sure no outline cursor is left around */
2148 if (ocrow != -1) 2141 if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol)
2149 {
2150 if (screen.cur.row - view_start != ocrow
2151 || screen.cur.col != oldcursor.col)
2152 {
2153 if (ocrow < nrow
2154 && oldcursor.col < ncol)
2155 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); 2142 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2156 }
2157 }
2158 2143
2159 // save the current cursor coordinates if the cursor is visible 2144 // save the current cursor coordinates if the cursor is visible
2160 // and the window is unfocused, so as to clear the outline cursor 2145 // and either the window is unfocused or the cursor style is
2161 // in the next refresh if the cursor moves 2146 // vertical bar, so as to clear the outline cursor in the next
2147 // refresh if the cursor moves or becomes invisible
2162 if (showcursor && !focus && screen.cur.row - view_start < nrow) 2148 if (showcursor && (!focus || cursor_type == 2) && screen.cur.row - view_start < nrow)
2163 { 2149 {
2164 oldcursor.row = screen.cur.row - view_start; 2150 oldcursor.row = screen.cur.row - view_start;
2165 oldcursor.col = screen.cur.col; 2151 oldcursor.col = screen.cur.col;
2166 } 2152 }
2167 else 2153 else
2254 int ypixel = (int)Row2Pixel (row); 2240 int ypixel = (int)Row2Pixel (row);
2255 2241
2256 for (col = 0; col < ncol; col++) 2242 for (col = 0; col < ncol; col++)
2257 { 2243 {
2258 /* compare new text with old - if exactly the same then continue */ 2244 /* compare new text with old - if exactly the same then continue */
2259 if (stp[col] == dtp[col] /* Must match characters to skip. */ 2245 if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col]))
2260 && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */
2261 || (stp[col] == ' ' /* space w/ no background change */
2262 && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col]))))
2263 continue; 2246 continue;
2264 2247
2265 // redraw one or more characters 2248 // redraw one or more characters
2266 2249
2267 // seek to the beginning of wide characters 2250 // seek to the beginning of wide characters
2463 * G: cleanup cursor and display outline cursor if necessary 2446 * G: cleanup cursor and display outline cursor if necessary
2464 */ 2447 */
2465 if (showcursor) 2448 if (showcursor)
2466 { 2449 {
2467 if (focus) 2450 if (focus)
2451 {
2452 if (cursor_type != 2)
2468 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); 2453 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend);
2454 else if (oldcursor.row >= 0)
2455 {
2456 XSetForeground (dpy, gc, pix_colors[ccol1]);
2457 XFillRectangle (dpy, vt, gc,
2458 Col2Pixel (cur_col),
2459 Row2Pixel (oldcursor.row),
2460 1,
2461 Height2Pixel (1));
2462 }
2463 }
2469 else if (oldcursor.row >= 0) 2464 else if (oldcursor.row >= 0)
2470 { 2465 {
2471 XSetForeground (dpy, gc, pix_colors[ccol1]); 2466 XSetForeground (dpy, gc, pix_colors[ccol1]);
2472 2467
2473 XDrawRectangle (dpy, vt, gc, 2468 XDrawRectangle (dpy, vt, gc,
2548 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 2543 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2549 } 2544 }
2550 2545
2551 XClearWindow (dpy, parent); 2546 XClearWindow (dpy, parent);
2552 2547
2553 if (scrollBar.win) 2548 if (scrollBar.state && scrollBar.win)
2554 { 2549 {
2555 if (transparent) 2550 if (transparent)
2556 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); 2551 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2557 else 2552 else
2558 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); 2553 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]);
2686 2681
2687void 2682void
2688rxvt_term::selection_changed () NOTHROW 2683rxvt_term::selection_changed () NOTHROW
2689{ 2684{
2690 line_t &r1 = ROW (selection.beg.row); 2685 line_t &r1 = ROW (selection.beg.row);
2691 while (selection.beg.col > 0 && r1.t [selection.beg.col] == NOCHAR) 2686 while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR)
2692 --selection.beg.col; 2687 ++selection.beg.col;
2693 2688
2694 line_t &r2 = ROW (selection.end.row); 2689 line_t &r2 = ROW (selection.end.row);
2695 while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR) 2690 while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR)
2696 ++selection.end.col; 2691 ++selection.end.col;
2697 2692

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines