--- rxvt-unicode/src/screen.C 2013/03/24 10:12:04 1.435 +++ rxvt-unicode/src/screen.C 2015/09/30 12:57:04 1.455 @@ -7,7 +7,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -256,9 +256,6 @@ if (!prev_row_buf) { - /* - * first time called (or after scr_release) so just malloc everything: don't rely on realloc - */ top_row = 0; term_start = 0; @@ -720,7 +717,7 @@ if (option (Opt_scrollWithBuffer) && view_start != 0 && view_start != -saveLines) - scr_page (UP, count); + scr_page (count); if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); @@ -1016,8 +1013,8 @@ && ROW(screen.cur.row - 1).is_longer ()) { linep = &ROW(screen.cur.row - 1); - tp = line->t + ncol - 1; - rp = line->r + ncol - 1; + tp = linep->t + ncol - 1; + rp = linep->r + ncol - 1; } else continue; @@ -1245,20 +1242,16 @@ void rxvt_term::scr_index (enum page_dirn direction) NOTHROW { - int dirn; - want_refresh = 1; ZERO_SCROLLBACK (); - dirn = ((direction == UP) ? 1 : -1); - screen.flags &= ~Screen_WrapNext; if ((screen.cur.row == screen.bscroll && direction == UP) || (screen.cur.row == screen.tscroll && direction == DN)) - scr_scroll_text (screen.tscroll, screen.bscroll, dirn); + scr_scroll_text (screen.tscroll, screen.bscroll, direction); else - screen.cur.row += dirn; + screen.cur.row += direction; clamp_it (screen.cur.row, 0, nrow - 1); selection_check (0); @@ -1906,7 +1899,8 @@ void rxvt_term::scr_move_to (int y, int len) NOTHROW { - scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); + // lerp (y, 0, len, top_row, nrow - 1) + scr_changeview (top_row + (nrow - 1 - top_row) * y / len); } /* ------------------------------------------------------------------------- */ @@ -1915,13 +1909,9 @@ * direction should be UP or DN */ bool -rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW +rxvt_term::scr_page (int nlines) NOTHROW { - int new_view_start = - direction == UP ? view_start - nlines - : view_start + nlines; - - return scr_changeview (new_view_start); + return scr_changeview (view_start - nlines); } bool @@ -2053,6 +2043,7 @@ ccol2; /* Cursor colour2 */ rend_t cur_rend; int cur_col; + int cursorwidth; want_refresh = 0; /* screen is current */ @@ -2087,8 +2078,6 @@ * C: set the cursor character (s) */ { - bool setoldcursor; - #ifdef CURSOR_BLINK if (hidden_cursor) showcursor = 0; @@ -2101,6 +2090,11 @@ while (col && ROW(screen.cur.row).t[col] == NOCHAR) col--; + cursorwidth = 1; + while (col + cursorwidth < ncol + && ROW(screen.cur.row).t[col + cursorwidth] == NOCHAR) + cursorwidth++; + cur_rend = ROW(screen.cur.row).r[col]; cur_col = col; @@ -2126,53 +2120,33 @@ ccol2 = Color_bg; #endif - if (focus) + if (focus && cursor_type == 0) { rend_t rend = cur_rend; - if (option (Opt_cursorUnderline)) - rend ^= RS_Uline; - else - { - rend ^= RS_RVid; - rend = SET_FGCOLOR (rend, ccol1); - rend = SET_BGCOLOR (rend, ccol2); - } + rend ^= RS_RVid; + rend = SET_FGCOLOR (rend, ccol1); + rend = SET_BGCOLOR (rend, ccol2); scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); } } /* make sure no outline cursor is left around */ - setoldcursor = 0; - if (ocrow != -1) - { - if (screen.cur.row - view_start != ocrow - || screen.cur.col != oldcursor.col) - { - if (ocrow < nrow - && oldcursor.col < ncol) - drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); - - if (focus || !showcursor) - oldcursor.row = -1; - else - setoldcursor = 1; - } - } - else if (!focus) - setoldcursor = 1; + if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol) + drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); - if (setoldcursor) + // save the current cursor coordinates if the cursor is visible + // and either the window is unfocused or the cursor style is + // underline or vertical bar, so as to clear the outline cursor in + // the next refresh if the cursor moves or becomes invisible + if (showcursor && (!focus || cursor_type != 0) && screen.cur.row - view_start < nrow) { - if (screen.cur.row - view_start >= nrow) - oldcursor.row = -1; - else - { - oldcursor.row = screen.cur.row - view_start; - oldcursor.col = screen.cur.col; - } + oldcursor.row = screen.cur.row - view_start; + oldcursor.col = screen.cur.col; } + else + oldcursor.row = -1; } #ifndef NO_SLOW_LINK_SUPPORT @@ -2263,10 +2237,7 @@ for (col = 0; col < ncol; col++) { /* compare new text with old - if exactly the same then continue */ - if (stp[col] == dtp[col] /* Must match characters to skip. */ - && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */ - || (stp[col] == ' ' /* space w/ no background change */ - && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) + if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col])) continue; // redraw one or more characters @@ -2448,6 +2419,10 @@ if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) { + if (showcursor && focus && row == screen.cur.row + && IN_RANGE_EXC (col, cur_col, cur_col + cursorwidth)) + XSetForeground (dpy, gc, pix_colors[ccol1]); + else #if ENABLE_FRILLS if (ISSET_PIXCOLOR (Color_underline)) XSetForeground (dpy, gc, pix_colors[Color_underline]); @@ -2468,28 +2443,32 @@ if (showcursor) { if (focus) - scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); + { + if (cursor_type == 0) + scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); + else if (oldcursor.row >= 0) + { + XSetForeground (dpy, gc, pix_colors[ccol1]); + if (cursor_type == 1) + XFillRectangle (dpy, vt, gc, + Col2Pixel (cur_col), + Row2Pixel (oldcursor.row + 1) - 2, + Width2Pixel (1), + 2); + else + XFillRectangle (dpy, vt, gc, + Col2Pixel (cur_col), + Row2Pixel (oldcursor.row), + 2, + Height2Pixel (1)); + } + } else if (oldcursor.row >= 0) { - int cursorwidth = 1; - int col = oldcursor.col; - - while (col && ROW(screen.cur.row).t[col] == NOCHAR) - col--; - - while (col + cursorwidth < ncol - && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) - cursorwidth++; - -#ifndef NO_CURSORCOLOR - if (ISSET_PIXCOLOR (Color_cursor)) - XSetForeground (dpy, gc, pix_colors[Color_cursor]); - else -#endif - XSetForeground (dpy, gc, pix_colors[ccol1]); + XSetForeground (dpy, gc, pix_colors[ccol1]); XDrawRectangle (dpy, vt, gc, - Col2Pixel (col), + Col2Pixel (cur_col), Row2Pixel (oldcursor.row), (unsigned int) (Width2Pixel (cursorwidth) - 1), (unsigned int) (Height2Pixel (1) - 1)); @@ -2537,7 +2516,7 @@ } void ecb_cold -rxvt_term::scr_recolour (bool refresh) NOTHROW +rxvt_term::scr_recolor (bool refresh) NOTHROW { bool transparent = false; @@ -2568,7 +2547,7 @@ XClearWindow (dpy, parent); - if (scrollBar.win) + if (scrollBar.state && scrollBar.win) { if (transparent) XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); @@ -2706,8 +2685,8 @@ rxvt_term::selection_changed () NOTHROW { line_t &r1 = ROW (selection.beg.row); - while (selection.beg.col > 0 && r1.t [selection.beg.col] == NOCHAR) - --selection.beg.col; + while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR) + ++selection.beg.col; line_t &r2 = ROW (selection.end.row); while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR)