--- rxvt-unicode/src/screen.C 2013/01/13 17:42:24 1.428 +++ rxvt-unicode/src/screen.C 2013/03/24 10:15:27 1.436 @@ -152,6 +152,16 @@ } while (col < ncol && l.t[col] == NOCHAR); } +// set the rendition of a single wide character beginning at the given column +void +rxvt_term::scr_set_char_rend (line_t &l, int col, rend_t rend) +{ + do { + l.r[col] = rend; + col++; + } while (col < ncol && l.t[col] == NOCHAR); +} + /* ------------------------------------------------------------------------- * * SCREEN INITIALISATION * * ------------------------------------------------------------------------- */ @@ -190,6 +200,16 @@ row_buf = swap_buf + nrow; } +void +rxvt_term::copy_line (line_t &dst, line_t &src) +{ + scr_blank_screen_mem (dst, DEFAULT_RSTYLE); + dst.l = min (src.l, ncol); + memcpy (dst.t, src.t, sizeof (text_t) * dst.l); + memcpy (dst.r, src.r, sizeof (rend_t) * dst.l); + dst.f = src.f; +} + void ecb_cold rxvt_term::scr_reset () { @@ -232,15 +252,10 @@ line_t *prev_swap_buf = swap_buf; line_t *prev_row_buf = row_buf; - int common_col = min (prev_ncol, ncol); - scr_alloc (); 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; @@ -275,15 +290,15 @@ * add or delete rows as appropriate */ + int common_col = min (prev_ncol, ncol); + for (int row = min (nrow, prev_nrow); row--; ) { scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); - scr_blank_screen_mem (swap_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); - memcpy (swap_buf [row].t, prev_swap_buf [row].t, sizeof (text_t) * common_col); - memcpy (swap_buf [row].r, prev_swap_buf [row].r, sizeof (rend_t) * common_col); + + copy_line (swap_buf [row], prev_swap_buf [row]); } int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row @@ -388,11 +403,7 @@ line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)]; line_t &dst = row_buf [row]; - scr_blank_screen_mem (dst, DEFAULT_RSTYLE); - - memcpy (dst.t, src.t, sizeof (text_t) * common_col); - memcpy (dst.r, src.r, sizeof (rend_t) * common_col); - dst.l = common_col; + copy_line (dst, src); } for (int row = prev_nrow; row < nrow; row++) @@ -2035,12 +2046,10 @@ int16_t col, row, /* column/row we're processing */ ocrow; /* old cursor row */ int i; /* tmp */ -#ifndef NO_CURSORCOLOR - rend_t cc1; /* store colours at cursor position (s) */ -#endif - rend_t *crp; // cursor rendition pointer rend_t ccol1, /* Cursor colour */ ccol2; /* Cursor colour2 */ + rend_t cur_rend; + int cur_col; want_refresh = 0; /* screen is current */ @@ -2089,10 +2098,10 @@ while (col && ROW(screen.cur.row).t[col] == NOCHAR) col--; - crp = &ROW(screen.cur.row).r[col]; + cur_rend = ROW(screen.cur.row).r[col]; + cur_col = col; #ifndef NO_CURSORCOLOR - cc1 = *crp & (RS_fgMask | RS_bgMask); if (ISSET_PIXCOLOR (Color_cursor)) ccol1 = Color_cursor; else @@ -2116,14 +2125,18 @@ if (focus) { + rend_t rend = cur_rend; + if (option (Opt_cursorUnderline)) - *crp ^= RS_Uline; + rend ^= RS_Uline; else { - *crp ^= RS_RVid; - *crp = SET_FGCOLOR (*crp, ccol1); - *crp = SET_BGCOLOR (*crp, 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); } } @@ -2452,17 +2465,7 @@ if (showcursor) { if (focus) - { - if (option (Opt_cursorUnderline)) - *crp ^= RS_Uline; - else - { - *crp ^= RS_RVid; -#ifndef NO_CURSORCOLOR - *crp = (*crp & ~ (RS_fgMask | RS_bgMask)) | cc1; -#endif - } - } + scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); else if (oldcursor.row >= 0) { int cursorwidth = 1; @@ -2696,6 +2699,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 @@ -3006,7 +3023,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 @@ -3138,8 +3155,6 @@ LEFT, RIGHT } closeto = RIGHT; - want_refresh = 1; - switch (selection.op) { case SELECTION_INIT: @@ -3328,6 +3343,8 @@ if (selection.rect && selection.beg.col > selection.end.col) ::swap (selection.beg.col, selection.end.col); #endif + + selection_changed (); } #if !ENABLE_MINIMAL