--- rxvt-unicode/src/screen.C 2006/01/25 00:42:21 1.249 +++ rxvt-unicode/src/screen.C 2006/02/17 14:30:51 1.259 @@ -95,18 +95,18 @@ #define CLEAR_ROWS(row, num) \ if (mapped) \ - XClearArea (display->display, drawBuffer, 0, \ + XClearArea (dpy, drawBuffer, 0, \ Row2Pixel (row), (unsigned int)width, \ (unsigned int)Height2Pixel (num), False) #define CLEAR_CHARS(x, y, num) \ if (mapped) \ - XClearArea (display->display, drawBuffer, x, y, \ + XClearArea (dpy, drawBuffer, x, y, \ (unsigned int)Width2Pixel (num), \ (unsigned int)Height2Pixel (1), False) #define ERASE_ROWS(row, num) \ - XFillRectangle (display->display, drawBuffer, gc, \ + XFillRectangle (dpy, drawBuffer, gc, \ 0, Row2Pixel (row), \ (unsigned int)width, \ (unsigned int)Height2Pixel (num)) @@ -128,7 +128,7 @@ l.touch (); - efs &= ~RS_baseattrMask; + efs &= ~RS_baseattrMask; // remove italic etc. fontstyles efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); text_t *et = l.t + col; @@ -643,14 +643,18 @@ // erase newly scrolled-in lines for (int i = count; i--; ) { - // basically this is a slightly optimized scr_blank_screen_mem - // it is worth the effort on slower machines line_t &l = ROW(nrow - 1 - i); - scr_blank_line (l, 0, l.l, rstyle); - - l.l = 0; - l.f = 0; + // optimize if already cleared, can be significant on slow machines + // could be rolled into scr_blank_screen_mem + if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask))) + { + scr_blank_line (l, 0, l.l, rstyle); + l.l = 0; + l.f = 0; + } + else + scr_blank_screen_mem (l, rstyle); } // now copy lines below the scroll region bottom to the @@ -1112,7 +1116,7 @@ * Move cursor left in row. If we're at the left boundary, shift everything * in that row right. Clear left column. */ -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL void rxvt_term::scr_backindex () NOTHROW { @@ -1129,7 +1133,7 @@ * Move cursor right in row. If we're at the right boundary, shift everything * in that row left. Clear right column. */ -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL void rxvt_term::scr_forwardindex () NOTHROW { @@ -1340,10 +1344,10 @@ { ren = rstyle & (RS_fgMask | RS_bgMask); gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; - XChangeGC (display->display, gc, GCForeground, &gcvalue); + XChangeGC (dpy, gc, GCForeground, &gcvalue); ERASE_ROWS (row, num); gcvalue.foreground = pix_colors[Color_fg]; - XChangeGC (display->display, gc, GCForeground, &gcvalue); + XChangeGC (dpy, gc, GCForeground, &gcvalue); } for (; num--; row++) @@ -1353,7 +1357,7 @@ } } -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL void rxvt_term::scr_erase_savelines () NOTHROW { @@ -1652,12 +1656,12 @@ #if TRANSPARENT if (!OPTION (Opt_transparent) || am_transparent == 0) #endif - XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); + XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); XGCValues gcvalue; gcvalue.foreground = pix_colors[Color_fg]; gcvalue.background = pix_colors[Color_bg]; - XChangeGC (display->display, gc, GCBackground | GCForeground, &gcvalue); + XChangeGC (dpy, gc, GCBackground | GCForeground, &gcvalue); scr_clear (); scr_touch (true); @@ -1752,10 +1756,9 @@ for (int i = 0; i < nrow; i++) { - int col = 0; rend_t *drp = drawn_buf[i].r; - for (; col < ncol; col++, drp++) + for (int col = 0; col < ncol; col++, drp++) if ((*drp & mask) == value) { found = true; @@ -1887,7 +1890,7 @@ # ifdef MAPALERT_OPTION if (OPTION (Opt_mapAlert)) # endif - XMapWindow (display->display, parent[0]); + XMapWindow (dpy, parent[0]); # endif if (OPTION (Opt_visualBell)) @@ -1899,7 +1902,7 @@ bell_ev.start (NOW + VISUAL_BELL_DURATION); } else - XBell (display->display, 0); + XBell (dpy, 0); #endif } @@ -2148,7 +2151,7 @@ if (wlen < len) ::swap (wlen, len); - XCopyArea (display->display, vt, vt, + XCopyArea (dpy, vt, vt, gc, 0, Row2Pixel (len + i), (unsigned int)this->width, (unsigned int)Height2Pixel (wlen - len + 1), @@ -2246,15 +2249,21 @@ if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) { #if ENABLE_STYLES - // force redraw after "careful" characters to avoid pixel droppings - if (srp[col] & RS_Careful && col < ncol - 1 && 0) - drp[col + 1] = ~srp[col + 1]; + // "careful" (too wide) character handling // include previous careful character(s) if possible, looks nicer (best effort...) while (text > stp && srp[text - stp - 1] & RS_Careful && RS_SAME (rend, srp[text - stp - 1])) text--, count++, xpixel -= fwidth; + + // force redraw after "careful" characters to avoid pixel droppings + for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) + drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; + + // force redraw before "careful" characters to avoid pixel droppings + for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) + drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; #endif bool invert = rend & RS_RVid; @@ -2322,9 +2331,7 @@ rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; if (back == fore) - font->clear_rect (*drawable, xpixel, ypixel, - fwidth * count, fheight, - back); + font->clear_rect (*drawable, xpixel, ypixel, fwidth * count, fheight, back); else if (back == Color_bg) { if (must_clear) @@ -2348,12 +2355,12 @@ { #if ENABLE_FRILLS if (ISSET_PIXCOLOR (Color_underline)) - XSetForeground (display->display, gc, pix_colors[Color_underline]); + XSetForeground (dpy, gc, pix_colors[Color_underline]); else #endif - XSetForeground (display->display, gc, pix_colors[fore]); + XSetForeground (dpy, gc, pix_colors[fore]); - XDrawLine (display->display, drawBuffer, gc, + XDrawLine (dpy, drawBuffer, gc, xpixel, ypixel + font->ascent + 1, xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); } @@ -2396,10 +2403,10 @@ #ifndef NO_CURSORCOLOR if (ISSET_PIXCOLOR (Color_cursor)) - XSetForeground (display->display, gc, pix_colors[Color_cursor]); + XSetForeground (dpy, gc, pix_colors[Color_cursor]); #endif - XDrawRectangle (display->display, drawBuffer, gc, + XDrawRectangle (dpy, drawBuffer, gc, Col2Pixel (col), Row2Pixel (oldcursor.row), (unsigned int) (Width2Pixel (cursorwidth) - 1), @@ -2453,13 +2460,13 @@ #endif ) { - XSetWindowBackground (display->display, parent[0], pix_colors[Color_border]); - XClearWindow (display->display, parent[0]); - XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); + XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]); + XClearWindow (dpy, parent[0]); + XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); #if HAVE_SCROLLBARS if (scrollBar.win) { - XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); + XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); scrollBar.setIdle (); scrollbar_show (0); } @@ -2482,7 +2489,7 @@ want_refresh = 1; if (really) - XClearWindow (display->display, vt); + XClearWindow (dpy, vt); } void @@ -2541,7 +2548,7 @@ && current_screen == selection.screen && selection.end.row >= view_start) { -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL if (selection.rect) scr_xor_rect (selection.beg.row, selection.beg.col, selection.end.row, selection.end.col, @@ -2667,7 +2674,7 @@ unsigned long bytes_after; XTextProperty ct; - if (XGetWindowProperty (display->display, win, prop, + if (XGetWindowProperty (dpy, win, prop, 0, PROP_SIZE / 4, delete_prop, AnyPropertyType, &ct.encoding, &ct.format, @@ -2686,7 +2693,7 @@ // fetch and append remaining data XTextProperty ct2; - if (XGetWindowProperty (display->display, win, prop, + if (XGetWindowProperty (dpy, win, prop, ct.nitems / 4, (bytes_after + 3) / 4, delete_prop, AnyPropertyType, &ct2.encoding, &ct2.format, @@ -2709,7 +2716,7 @@ { // INCR selection, start handshake if (!delete_prop) - XDeleteProperty (display->display, win, prop); + XDeleteProperty (dpy, win, prop); selection_wait = Sel_incr; incr_buf_fill = 0; @@ -2766,7 +2773,7 @@ char **cl; int cr; -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it // so recode it manually if (ct.encoding == xa[XA_UTF8_STRING]) @@ -2780,7 +2787,7 @@ } else #endif - if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 + if (XmbTextPropertyToTextList (dpy, &ct, &cl, &cr) >= 0 && cl) { for (int i = 0; i < cr; i++) @@ -2872,9 +2879,9 @@ else sel = xa[XA_CLIPBOARD]; - if (XGetSelectionOwner (display->display, sel) != None) + if (XGetSelectionOwner (dpy, sel) != None) { - XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], + XConvertSelection (dpy, sel, target, xa[XA_VT_SELECTION], vt, selection_request_time); return 1; } @@ -2947,7 +2954,7 @@ for (; row <= selection.end.row; row++, col = 0) { -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL if (selection.rect) { col = selection.beg.col; @@ -2960,7 +2967,7 @@ col = max (col, 0); if (row == selection.end.row -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL || selection.rect #endif ) @@ -2993,7 +3000,7 @@ new_selection_text[ofs++] = *t++; } -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL if (selection.rect) { while (ofs @@ -3037,8 +3044,8 @@ { selection_time = tm; - XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); - if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) + XSetSelectionOwner (dpy, XA_PRIMARY, vt, tm); + if (XGetSelectionOwner (dpy, XA_PRIMARY) == vt) { display->set_selection_owner (this); return true; @@ -3052,7 +3059,7 @@ #if 0 XTextProperty ct; - if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) + if (XwcTextListToTextProperty (dpy, &selection.text, 1, XStringStyle, &ct) >= 0) { set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); XFree (ct.value); @@ -3364,7 +3371,7 @@ { if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN && !ROW(selection.beg.row).is_longer () -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL && !selection.rect #endif ) @@ -3373,7 +3380,7 @@ if ( selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN && !ROW(selection.end.row).is_longer () -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL && !selection.rect #endif ) @@ -3400,7 +3407,9 @@ { selection.end.row = end_row; selection.end.col = ROW(end_row).l; +# if !ENABLE_MINIMAL selection_remove_trailing_spaces (); +# endif break; } } @@ -3439,13 +3448,13 @@ } } -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL if (selection.rect && selection.beg.col > selection.end.col) ::swap (selection.beg.col, selection.end.col); #endif } -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL void rxvt_term::selection_remove_trailing_spaces () NOTHROW { @@ -3510,7 +3519,6 @@ rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW { XSelectionEvent ev; - dDisp; ev.type = SelectionNotify; ev.property = None; @@ -3534,7 +3542,7 @@ *target++ = xa[XA_UTF8_STRING]; #endif - XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM, + XChangeProperty (dpy, rq.requestor, rq.property, XA_ATOM, 32, PropModeReplace, (unsigned char *)target_list, target - target_list); ev.property = rq.property; @@ -3547,7 +3555,7 @@ #endif else if (rq.target == xa[XA_TIMESTAMP] && selection.text) { - XChangeProperty (disp, rq.requestor, rq.property, rq.target, + XChangeProperty (dpy, rq.requestor, rq.property, rq.target, 32, PropModeReplace, (unsigned char *)&selection_time, 1); ev.property = rq.property; } @@ -3581,7 +3589,7 @@ style = enc_text; else if (target == xa[XA_COMPOUND_TEXT]) style = enc_compound_text; -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL else if (target == xa[XA_UTF8_STRING]) style = enc_utf8; #endif @@ -3602,7 +3610,7 @@ selectlen = 0; } -#if ENABLE_FRILLS +#if !ENABLE_MINIMAL // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it // so recode it manually if (style == enc_utf8) @@ -3615,7 +3623,7 @@ } else #endif - if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) + if (XwcTextListToTextProperty (dpy, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) freect = 1; else { @@ -3625,7 +3633,7 @@ ct.encoding = target; } - XChangeProperty (disp, rq.requestor, rq.property, + XChangeProperty (dpy, rq.requestor, rq.property, ct.encoding, 8, PropModeReplace, ct.value, (int)ct.nitems); ev.property = rq.property; @@ -3634,7 +3642,7 @@ XFree (ct.value); } - XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev); + XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev); } /* ------------------------------------------------------------------------- * @@ -3660,7 +3668,7 @@ { XWindowAttributes xwa; - XGetWindowAttributes (display->display, vt, &xwa); + XGetWindowAttributes (dpy, vt, &xwa); pos.x = xwa.x + Col2Pixel (screen.cur.col); pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; @@ -3766,7 +3774,7 @@ while (*s) { text_t t = *s++; - int width = wcwidth (t); + int width = WCWIDTH (t); while (width--) {