]> Sergey Matveev's repositories - st.git/blobdiff - x.c
Coloured italics
[st.git] / x.c
diff --git a/x.c b/x.c
index cd96575be257240b094888f9ca2bbdaaa0e3792a..4ef3fdedf3c4e4e46c10d53bcb8284a491372b74 100644 (file)
--- a/x.c
+++ b/x.c
@@ -818,7 +818,7 @@ xloadcols(void)
 int
 xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b)
 {
-       if (!BETWEEN(x, 0, dc.collen))
+       if (!BETWEEN(x, 0, dc.collen - 1))
                return 1;
 
        *r = dc.col[x].color.red >> 8;
@@ -833,7 +833,7 @@ xsetcolorname(int x, const char *name)
 {
        Color ncolor;
 
-       if (!BETWEEN(x, 0, dc.collen))
+       if (!BETWEEN(x, 0, dc.collen - 1))
                return 1;
 
        if (!xloadcolor(x, name, &ncolor))
@@ -1381,12 +1381,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
        XRenderColor colfg, colbg;
        XRectangle r;
 
-       /* Fallback on color display for attributes not supported by the font */
-       if (base.mode & ATTR_ITALIC && base.mode & ATTR_BOLD) {
-               if (dc.ibfont.badslant || dc.ibfont.badweight)
-                       base.fg = defaultattr;
-       } else if ((base.mode & ATTR_ITALIC && dc.ifont.badslant) ||
-           (base.mode & ATTR_BOLD && dc.bfont.badweight)) {
+       if (base.mode & ATTR_ITALIC) {
                base.fg = defaultattr;
        }
 
@@ -1493,12 +1488,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
 
        /* Render underline and strikethrough. */
        if (base.mode & ATTR_UNDERLINE) {
-               XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
+               XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent * chscale + 1,
                                width, 1);
        }
 
        if (base.mode & ATTR_STRUCK) {
-               XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
+               XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent * chscale / 3,
                                width, 1);
        }
 
@@ -1617,6 +1612,9 @@ xseticontitle(char *p)
        XTextProperty prop;
        DEFAULT(p, opt_title);
 
+       if (p[0] == '\0')
+               p = opt_title;
+
        if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
                                        &prop) != Success)
                return;
@@ -1631,6 +1629,9 @@ xsettitle(char *p)
        XTextProperty prop;
        DEFAULT(p, opt_title);
 
+       if (p[0] == '\0')
+               p = opt_title;
+
        if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
                                        &prop) != Success)
                return;
@@ -1833,7 +1834,7 @@ void
 kpress(XEvent *ev)
 {
        XKeyEvent *e = &ev->xkey;
-       KeySym ksym;
+       KeySym ksym = NoSymbol;
        char buf[64], *customkey;
        int len;
        Rune c;
@@ -1843,10 +1844,13 @@ kpress(XEvent *ev)
        if (IS_SET(MODE_KBDLOCK))
                return;
 
-       if (xw.ime.xic)
+       if (xw.ime.xic) {
                len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
-       else
+               if (status == XBufferOverflow)
+                       return;
+       } else {
                len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
+       }
        /* 1. shortcuts */
        for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
                if (ksym == bp->keysym && match(bp->mod, e->state)) {