--- rxvt-2.6.4.orig/src/screen.c
+++ rxvt-2.6.4/src/screen.c
@@ -188,7 +188,7 @@
 	rp[row] = MALLOC(sizeof(rend_t) * TermWin.ncol);
     }
     if (!keepr)
-	efs &= ~(RS_Uline);
+	efs &= ~(RS_Uline | RS_RVid);
     MEMSET(tp[row], ' ', width);
     for (er = rp[row]; width--;)
 	*er++ = efs;
@@ -853,8 +853,8 @@
     count = scroll_text(screen.tscroll, screen.bscroll, count, 0);
 /* XXX: Ummm, no?  care needed with [bt]scroll, yes? */
     if (count > 0) {
-	row = TermWin.nrow - count + TermWin.saveLines;
-	erow = TermWin.nrow + TermWin.saveLines;
+	row = TermWin.saveLines + screen.bscroll - count;
+	erow = TermWin.saveLines + screen.bscroll + 1;
     } else {
 	row = TermWin.saveLines;
 	erow = TermWin.saveLines - count;
@@ -2107,6 +2107,54 @@
 #define FONT_RBEAR(X, Y)						\
     (X)->per_char[(Y) - (X)->min_char_or_byte2].rbearing
 
+#ifdef MULTICHAR_SET
+static int
+draw_string16(Display *display,
+	      Drawable d,
+	      GC gc,
+	      int x,
+	      int y,
+	      XChar2b *str,
+	      int len)
+{
+    while (len > 0) {
+	XDrawString16(display, d, gc, x, y, str, 1);
+	if (str->byte1 == '\0') {
+	    x += TermWin.fwidth;
+	}
+	else {
+	    x += TermWin.fwidth * 2;
+	}
+	str++;
+	len--;
+    }
+    return 0;
+}
+
+static int
+draw_image_string16(Display *display,
+		    Drawable d,
+		    GC gc,
+		    int x,
+		    int y,
+		    XChar2b *str,
+		    int len)
+{
+    while (len > 0) {
+	XDrawImageString16(display, d, gc, x, y, str, 1);
+	if (str->byte1 == '\0') {
+	    x += TermWin.fwidth;
+	}
+	else {
+	    x += TermWin.fwidth * 2;
+	}
+	str++;
+	len--;
+    }
+    return 0;
+}
+#endif
+
 /* EXTPROTO */
 void
 scr_refresh(int type)
@@ -2262,11 +2310,19 @@
 #ifndef NO_CURSORCOLOR
 	cc1 = *srp & (RS_fgMask | RS_bgMask);
 	if (Xdepth <= 2 || !rs[Rs_color + Color_cursor])
+#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
+	    ccol1 = GET_FGCOLOR(rstyle);
+#else
 	    ccol1 = Color_fg;
+#endif
 	else
 	    ccol1 = Color_cursor;
 	if (Xdepth <= 2 || !rs[Rs_color + Color_cursor2])
+#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
+	    ccol2 = GET_BGCOLOR(rstyle);
+#else
 	    ccol2 = Color_bg;
+#endif
 	else
 	    ccol2 = Color_cursor2;
 	*srp = SET_FGCOLOR(*srp, ccol1);
@@ -2366,9 +2422,9 @@
 	    len = 0;
 	    buffer[len++] = stp[col];
 	    ypixelc = Row2Pixel(row);
-	    ypixel = ypixelc + TermWin.font->ascent;
+	    ypixel = ypixelc + TermWin.fascent;
 	    xpixel = Col2Pixel(col);
-	    fontdiff = 0;
+	    fontdiff = TermWin.fontdiff;
 	    wlen = 1;
 
 /*
@@ -2382,9 +2438,14 @@
 		    if (!wbyte) {
 			wbyte = 1;
 			XSetFont(Xdisplay, TermWin.gc, TermWin.mfont->fid);
-		    fontdiff = TermWin.mprop;
-			draw_string = XDrawString16;
-			draw_image_string = XDrawImageString16;
+			fontdiff |= TermWin.mprop;
+			if (TermWin.mprop) {
+			    draw_string = draw_string16;
+			    draw_image_string = draw_image_string16;
+			} else {
+			    draw_string = XDrawString16;
+			    draw_image_string = XDrawImageString16;
+			}
 		    }
 		/* double stepping - we're in Kanji mode */
 		    for (; ++col < TermWin.ncol;) {
@@ -2512,11 +2573,12 @@
 	    if (!wbyte && MONO_BOLD(rend) && TermWin.boldFont != NULL) {
 		bfont = 1;
 		XSetFont(Xdisplay, TermWin.gc, TermWin.boldFont->fid);
-		fontdiff = TermWin.bprop;
+		fontdiff |= TermWin.bprop;
 		rend &= ~RS_Bold;	/* we've taken care of it */
 	    } else if (bfont) {
 		bfont = 0;
-		XSetFont(Xdisplay, TermWin.gc, TermWin.font->fid);
+		if (!wbyte)
+		    XSetFont(Xdisplay, TermWin.gc, TermWin.font->fid);
 	    }
 #endif
 /*
@@ -3341,14 +3403,6 @@
 
 /* ------------------------------------------------------------------------- */
 /*
- * On some systems, the Atom typedef is 64 bits wide.  We need to have a type
- * that is exactly 32 bits wide, because a format of 64 is not allowed by
- * the X11 protocol.
- */
-typedef CARD32  Atom32;
-
-/* ------------------------------------------------------------------------- */
-/*
  * Respond to a request for our current selection
  * EXT: SelectionRequest
  */
@@ -3357,7 +3411,7 @@
 selection_send(const XSelectionRequestEvent * rq)
 {
     XEvent          ev;
-    Atom32          target_list[4];
+    Atom            target_list[4];
     Atom            target;
     static Atom     xa_targets = None;
     static Atom     xa_compound_text = None;
@@ -3382,13 +3436,12 @@
     ev.xselection.time = rq->time;
 
     if (rq->target == xa_targets) {
-	target_list[0] = (Atom32) xa_targets;
-	target_list[1] = (Atom32) XA_STRING;
-	target_list[2] = (Atom32) xa_text;
-	target_list[3] = (Atom32) xa_compound_text;
+	target_list[0] = xa_targets;
+	target_list[1] = XA_STRING;
+	target_list[2] = xa_text;
+	target_list[3] = xa_compound_text;
 	XChangeProperty(Xdisplay, rq->requestor, rq->property, rq->target,
-			(8 * sizeof(target_list[0])), PropModeReplace,
-			(unsigned char *)target_list,
+			32, PropModeReplace, (unsigned char *)target_list,
 			(sizeof(target_list) / sizeof(target_list[0])));
 	ev.xselection.property = rq->property;
     } else if (rq->target == XA_STRING
@@ -3503,3 +3556,26 @@
     pos->y = Height2Pixel((screen.cur.row + 1)) + xwa.y;
 }
 #endif
+
+#ifdef MULTICHAR_SET
+/* EXTPROTO */
+int
+scr_multi1(void)
+{
+    rend_t          rend;
+    
+    rend = screen.rend[screen.cur.row + TermWin.saveLines][screen.cur.col];
+    return ((rend & RS_multiMask)==RS_multi1);
+}
+
+/* EXTPROTO */
+int
+scr_multi2(void)
+{
+    rend_t          rend;
+    
+    if (screen.cur.col==0)  return 0;
+    rend = screen.rend[screen.cur.row + TermWin.saveLines][screen.cur.col-1];
+    return ((rend & RS_multiMask)==RS_multi2);
+}
+#endif
