--- rxvt-unicode/src/screen.C 2012/06/29 22:10:09 1.424 +++ rxvt-unicode/src/screen.C 2013/03/25 12:28:04 1.437 @@ -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,10 +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); + copy_line (dst, src); } for (int row = prev_nrow; row < nrow; row++) @@ -411,7 +423,6 @@ if (!drawn_buf [row].valid ()) scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); } - printf ("pc %p\n", prev_chunk);//D chunk_free (prev_chunk, prev_chunk_size); free (tabs); @@ -1709,7 +1720,7 @@ rvideo_state = on; ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); -#ifdef HAVE_BG_PIXMAP +#ifdef HAVE_IMG if (bg_img == 0) #endif XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); @@ -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 */ @@ -2054,7 +2063,7 @@ unsigned int old_screen_flags = screen.flags; bool have_bg = 0; -#ifdef HAVE_BG_PIXMAP +#ifdef HAVE_IMG have_bg = bg_img != 0; #endif ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ @@ -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; @@ -2475,12 +2478,7 @@ && 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), @@ -2535,7 +2533,7 @@ { bool transparent = false; -#ifdef HAVE_BG_PIXMAP +#ifdef HAVE_IMG if (bg_img != 0) { # if ENABLE_TRANSPARENCY @@ -2567,7 +2565,7 @@ if (transparent) XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); else - XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); + XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); scrollBar.state = SB_STATE_IDLE; scrollBar.show (0); } @@ -2696,6 +2694,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 +3018,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 +3150,6 @@ LEFT, RIGHT } closeto = RIGHT; - want_refresh = 1; - switch (selection.op) { case SELECTION_INIT: @@ -3328,6 +3338,8 @@ if (selection.rect && selection.beg.col > selection.end.col) ::swap (selection.beg.col, selection.end.col); #endif + + selection_changed (); } #if !ENABLE_MINIMAL