X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=st.c;h=aaf868d84ca783a10040b0f15de590f227a8cf86;hb=0c94f8621b738c51c9e08abc3c52fe8dfe24b953;hp=b604f0e71185d9896ec7f97a00c745a62f532a24;hpb=62756fdb4945a80f4a53e6d354d5d93f51035517;p=st.git diff --git a/st.c b/st.c index b604f0e..aaf868d 100644 --- a/st.c +++ b/st.c @@ -560,7 +560,8 @@ static int frclen = 0; ssize_t xwrite(int fd, const char *s, size_t len) { - size_t aux = len, r; + size_t aux = len; + ssize_t r; while (len > 0) { r = write(fd, s, len); @@ -1530,7 +1531,8 @@ ttywrite(const char *s, size_t n) * This means the buffer is getting full * again. Empty it. */ - ttyread(); + if (n < 256) + ttyread(); n -= r; s += r; } else { @@ -2894,15 +2896,15 @@ tputc(Rune u) int width, len; Glyph *gp; + control = ISCONTROL(u); len = utf8encode(u, c); - if ((width = wcwidth(u)) == -1) { + if (!control && (width = wcwidth(u)) == -1) { memcpy(c, "\357\277\275", 4); /* UTF_INVALID */ width = 1; } if (IS_SET(MODE_PRINT)) tprinter(c, len); - control = ISCONTROL(u); /* * STR sequence must be checked before anything else @@ -3410,6 +3412,7 @@ xinit(void) Cursor cursor; Window parent; pid_t thispid = getpid(); + XColor xmousefg, xmousebg; if (!(xw.dpy = XOpenDisplay(NULL))) die("Can't open display\n"); @@ -3482,11 +3485,22 @@ xinit(void) die("XCreateIC failed. Could not obtain input method.\n"); /* white cursor, black outline */ - cursor = XCreateFontCursor(xw.dpy, XC_xterm); + cursor = XCreateFontCursor(xw.dpy, mouseshape); XDefineCursor(xw.dpy, xw.win, cursor); - XRecolorCursor(xw.dpy, cursor, - &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff}, - &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000}); + + if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) { + xmousefg.red = 0xffff; + xmousefg.green = 0xffff; + xmousefg.blue = 0xffff; + } + + if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) { + xmousebg.red = 0x0000; + xmousebg.green = 0x0000; + xmousebg.blue = 0x0000; + } + + XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg); xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False); xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False); @@ -4258,9 +4272,11 @@ usage(void) { die("%s " VERSION " (c) 2010-2015 st engineers\n" "usage: st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]\n" - " [-i] [-t title] [-w windowid] [-e command ...] [command ...]\n" + " [-i] [-t title] [-T title] [-w windowid] [-e command ...]" + " [command ...]\n" " st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]\n" - " [-i] [-t title] [-w windowid] [-l line] [stty_args ...]\n", + " [-i] [-t title] [-T title] [-w windowid] [-l line]" + " [stty_args ...]\n", argv0); } @@ -4301,6 +4317,7 @@ main(int argc, char *argv[]) opt_line = EARGF(usage()); break; case 't': + case 'T': opt_title = EARGF(usage()); break; case 'w':