--- rxvt-unicode/src/screen.C 2010/03/30 23:54:30 1.336 +++ rxvt-unicode/src/screen.C 2010/12/21 10:37:42 1.356 @@ -30,9 +30,10 @@ #include -#include "salloc.C" // HACK, should be a seperate compile! +#include "salloc.C" // HACK, should be a separate compile! -static inline void fill_text (text_t *start, text_t value, int len) +static inline void +fill_text (text_t *start, text_t value, int len) { while (len--) *start++ = value; @@ -145,6 +146,8 @@ rend_t rend = l.r[col] & ~RS_baseattrMask; rend = SET_FONT (rend, FONTSET (rend)->find_font (' ')); + l.touch (); + // found start, nuke do { l.t[col] = ' '; @@ -899,25 +902,29 @@ # endif #endif - // nuke the character at this position, if required - if (expect_false ( - line->t[screen.cur.col] == NOCHAR - || (screen.cur.col < ncol - 1 - && line->t[screen.cur.col + 1] == NOCHAR) - )) - scr_kill_char (*line, screen.cur.col); - rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); // if the character doesn't fit into the remaining columns... if (expect_false (screen.cur.col > ncol - width && ncol >= width)) { - // ... artificially enlargen the previous one - c = NOCHAR; - // and try the same character next loop iteration - --str; + if (screen.flags & Screen_Autowrap) + { + // ... artificially enlargen the previous one + c = NOCHAR; + // and try the same character next loop iteration + --str; + } + else + screen.cur.col = ncol - width; } + // nuke the character at this position, if required + // due to wonderful coincidences everywhere else in this loop + // we never have to check for overwriting a wide char itself, + // only its tail. + if (expect_false (line->t[screen.cur.col] == NOCHAR)) + scr_kill_char (*line, screen.cur.col); + line->touch (); do @@ -932,7 +939,8 @@ line->l = ncol; if (screen.flags & Screen_Autowrap) screen.flags |= Screen_WrapNext; - break; + + goto end_of_line; } c = NOCHAR; @@ -940,16 +948,14 @@ while (expect_false (--width > 0)); // pad with spaces when overwriting wide character with smaller one - if (expect_false (!width)) + for (int c = screen.cur.col; expect_false (c < ncol && line->t[c] == NOCHAR); c++) { - line->touch (); - - for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++) - { - line->t[c] = ' '; - line->r[c] = rend; - } + line->t[c] = ' '; + line->r[c] = rend; } + +end_of_line: + ; } #if ENABLE_COMBINING else // width == 0 @@ -1022,6 +1028,8 @@ #endif } } + else if (screen.flags & Screen_WrapNext) + screen.flags &= ~Screen_WrapNext; else scr_gotorc (0, -1, RELATIVE); } @@ -1337,16 +1345,13 @@ min_it (num, nrow - row); - // TODO: the code below does not work when view_start != 0 - // the workaround is to disable the clear and use a normal refresh - // when view_start != 0. mysterious. - if (rstyle & (RS_RVid | RS_Uline)) + if (rstyle & (RS_Blink | RS_RVid | RS_Uline)) ren = (rend_t) ~RS_None; else if (GET_BASEBG (rstyle) == Color_bg) { ren = DEFAULT_RSTYLE; - if (mapped && !view_start) + if (mapped) XClearArea (dpy, vt, 0, Row2Pixel (row - view_start), (unsigned int)width, (unsigned int)Height2Pixel (num), False); @@ -1355,7 +1360,7 @@ { ren = rstyle & (RS_fgMask | RS_bgMask); - if (mapped && !view_start) + if (mapped) { gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; XChangeGC (dpy, gc, GCForeground, &gcvalue); @@ -1372,8 +1377,8 @@ { scr_blank_screen_mem (ROW(row), rstyle); - if (!view_start) - scr_blank_line (drawn_buf [row], 0, ncol, ren); + if (row - view_start < nrow) + scr_blank_line (drawn_buf [row - view_start], 0, ncol, ren); } } @@ -2087,7 +2092,7 @@ ccol2 = Color_bg; #endif - if (showcursor && focus) + if (focus) { if (option (Opt_cursorUnderline)) *crp ^= RS_Uline; @@ -2233,7 +2238,7 @@ while (expect_false (stp[col] == NOCHAR && col > 0)) --col; - rend_t rend = srp[col]; /* screen rendition (target rendtion) */ + rend_t rend = srp[col]; /* screen rendition (target rendition) */ text_t *text = stp + col; int count = 1; @@ -2288,7 +2293,7 @@ int back = bgcolor_of (rend); // desired background // only do special processing if any attributes are set, which is unlikely - if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))) + if (expect_false (rend & (RS_baseattrMask | RS_Careful | RS_Sel))) { bool invert = rend & RS_RVid; @@ -2317,25 +2322,31 @@ fore = Color_UL; #endif - if (invert) - { #ifdef OPTION_HC - if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col) - || !ISSET_PIXCOLOR (Color_HC)) + if (rend & RS_Sel) + { + /* invert the column if no highlightColor is set or it is the + * current cursor column */ + if (!(showcursor && row == screen.cur.row && text - stp == screen.cur.col) + && ISSET_PIXCOLOR (Color_HC)) + { + if (ISSET_PIXCOLOR (Color_HTC)) + fore = Color_HTC; + // if invert is 0 reverse video is set so we use bg color as fg color + else if (!invert) + fore = back; + + back = Color_HC; + invert = 0; + } + } #endif - /* invert the column if no highlightColor is set or it is the - * current cursor column */ + + if (invert) + { ::swap (fore, back); -#ifdef OPTION_HC - else if (ISSET_PIXCOLOR (Color_HC)) - back = Color_HC; -#endif #ifndef NO_BOLD_UNDERLINE_REVERSE -# ifndef OPTION_HC - if (ISSET_PIXCOLOR (Color_RV)) - back = Color_RV; -# endif if (fore == back) { fore = Color_bg; @@ -2598,12 +2609,12 @@ if (selection.rect) scr_xor_rect (selection.beg.row, selection.beg.col, selection.end.row, selection.end.col, - RS_RVid, RS_RVid | RS_Uline); + RS_Sel | RS_RVid, RS_Sel | RS_RVid | RS_Uline); else #endif scr_xor_span (selection.beg.row, selection.beg.col, selection.end.row, selection.end.col, - RS_RVid); + RS_Sel | RS_RVid); } } @@ -2618,7 +2629,7 @@ { int row, wrote; unsigned int width, towrite; - char r1[] = "\n"; + const char r1[] = "\n"; for (row = saveLines + top_row; row < saveLines + nrow - 1; row++) @@ -2674,7 +2685,7 @@ * Paste a selection direct to the command fd */ void -rxvt_term::paste (char *data, unsigned int len) NOTHROW +rxvt_term::tt_paste (char *data, unsigned int len) NOTHROW { /* convert normal newline chars into common keyboard Return key sequence */ for (unsigned int i = 0; i < len; i++) @@ -2690,6 +2701,15 @@ tt_printf ("\e[201~"); } +void +rxvt_term::paste (char *data, unsigned int len) NOTHROW +{ + if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END))) + return; + + tt_paste (data, len); +} + /* ------------------------------------------------------------------------- */ /* * Respond to a notification that a primary selection has been sent @@ -2906,11 +2926,11 @@ #if X_HAVE_UTF8_STRING selection_type = Sel_UTF8String; if (selection_request_other (xa[XA_UTF8_STRING], selnum)) - return; + return; #else selection_type = Sel_CompoundText; if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum)) - return; + return; #endif } @@ -2972,20 +2992,6 @@ } } -void -rxvt_term::clipboard_copy (Time tm) -{ - if (selection.len > 0) - { - free (selection.clip_text); - selection.clip_len = selection.len; - selection.clip_text = (wchar_t *) malloc (sizeof (wchar_t) * selection.clip_len); - memcpy (selection.clip_text, selection.text, - sizeof (wchar_t) * selection.clip_len); - selection_grab (tm, true); - } -} - /* ------------------------------------------------------------------------- */ /* * Copy a selection into the cut buffer