From 33558ca042357ee7387b7c0ba9574af1106c4037 Mon Sep 17 00:00:00 2001 From: Aurélien Aptel Date: Wed, 15 Feb 2012 19:10:31 +0100 Subject: handle dim/bright colors. --- st.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/st.c b/st.c index fca97ce..627e566 100644 --- a/st.c +++ b/st.c @@ -1341,14 +1341,8 @@ csihandle(void) { void csidump(void) { - int i; - printf("ESC [ %s", escseq.priv ? "? " : ""); - if(escseq.narg) - for(i = 0; i < escseq.narg; i++) - printf("%d ", escseq.arg[i]); - if(escseq.mode) - putchar(escseq.mode); - putchar('\n'); + fwrite("\033[", 1, 2, stdout); + fwrite(escseq.buf, 1, escseq.len, stdout); } void @@ -1761,23 +1755,29 @@ xinit(void) { void xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { - ulong xfg = dc.col[base.fg], xbg = dc.col[base.bg], temp; + int fg = base.fg, bg = base.bg, temp; int winx = x*xw.cw, winy = y*xw.ch + dc.font.ascent, width = charlen*xw.cw; + XFontSet fontset = dc.font.set; int i; /* only switch default fg/bg if term is in RV mode */ if(IS_SET(MODE_REVERSE)) { - if(base.fg == DefaultFG) - xfg = dc.col[DefaultBG]; - if(base.bg == DefaultBG) - xbg = dc.col[DefaultFG]; + if(fg == DefaultFG) + fg = DefaultBG; + if(bg == DefaultBG) + bg = DefaultFG; } if(base.mode & ATTR_REVERSE) - temp = xfg, xfg = xbg, xbg = temp; + temp = fg, fg = bg, bg = temp; + + if(base.mode & ATTR_BOLD) { + fg += 8; + fontset = dc.bfont.set; + } - XSetBackground(xw.dpy, dc.gc, xbg); - XSetForeground(xw.dpy, dc.gc, xfg); + XSetBackground(xw.dpy, dc.gc, dc.col[bg]); + XSetForeground(xw.dpy, dc.gc, dc.col[fg]); if(base.mode & ATTR_GFX) { for(i = 0; i < bytelen; i++) { @@ -1789,8 +1789,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) { } } - XmbDrawImageString(xw.dpy, xw.buf, base.mode & ATTR_BOLD ? dc.bfont.set : dc.font.set, - dc.gc, winx, winy, s, bytelen); + XmbDrawImageString(xw.dpy, xw.buf, fontset, dc.gc, winx, winy, s, bytelen); if(base.mode & ATTR_UNDERLINE) XDrawLine(xw.dpy, xw.buf, dc.gc, winx, winy+1, winx+width-1, winy+1); -- cgit v1.2.3-13-gbd6f