--- rxvt-unicode/src/screen.C 2013/01/31 08:07:14 1.433 +++ rxvt-unicode/src/screen.C 2013/03/30 08:47:06 1.442 @@ -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; @@ -293,9 +290,14 @@ * add or delete rows as appropriate */ + int common_col = min (prev_ncol, ncol); + for (int row = min (nrow, prev_nrow); row--; ) { - copy_line (drawn_buf [row], prev_drawn_buf [row]); + scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); + memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col); + memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col); + copy_line (swap_buf [row], prev_swap_buf [row]); } @@ -715,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)); @@ -1240,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); @@ -1910,13 +1908,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 @@ -2048,6 +2042,7 @@ ccol2; /* Cursor colour2 */ rend_t cur_rend; int cur_col; + int cursorwidth; want_refresh = 0; /* screen is current */ @@ -2082,8 +2077,6 @@ * C: set the cursor character (s) */ { - bool setoldcursor; - #ifdef CURSOR_BLINK if (hidden_cursor) showcursor = 0; @@ -2096,6 +2089,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; @@ -2139,7 +2137,6 @@ } /* make sure no outline cursor is left around */ - setoldcursor = 0; if (ocrow != -1) { if (screen.cur.row - view_start != ocrow @@ -2148,26 +2145,19 @@ 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 (setoldcursor) + // save the current cursor coordinates if the cursor is visible + // and the window is unfocused, so as to clear the outline cursor + // in the next refresh if the cursor moves + if (showcursor && !focus && 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 @@ -2443,6 +2433,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]); @@ -2466,25 +2460,10 @@ scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); 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)); @@ -2697,6 +2676,20 @@ CLEAR_ALL_SELECTION (); } +void +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; + + line_t &r2 = ROW (selection.end.row); + while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR) + ++selection.end.col; + + want_refresh = 1; +} + /* ------------------------------------------------------------------------- */ /* * Paste a selection direct to the command fd @@ -3007,7 +3000,7 @@ */ /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ -#define DELIMIT_TEXT(x) \ +#define DELIMIT_TEXT(x) \ (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) #define DELIMIT_REND(x) 1 @@ -3081,6 +3074,14 @@ if (dirn == DN) col++; /* put us on one past the end */ + else + { + // if the delimiter on the left has width > 1 col points to the + // first NOCHAR in the delimiter cell and so we must move it to the + // beginning of the next cell. + while (ROW(row).t[col] == NOCHAR) + col++; + } /* Poke the values back in */ ret->row = row; @@ -3139,8 +3140,6 @@ LEFT, RIGHT } closeto = RIGHT; - want_refresh = 1; - switch (selection.op) { case SELECTION_INIT: @@ -3329,6 +3328,8 @@ if (selection.rect && selection.beg.col > selection.end.col) ::swap (selection.beg.col, selection.end.col); #endif + + selection_changed (); } #if !ENABLE_MINIMAL