diff --git a/Makefile b/Makefile index 75566f0..40dc8d5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# st - simple terminal +# xst - xresources simple terminal # See LICENSE file for copyright and license details. .POSIX: @@ -7,13 +7,7 @@ include config.mk SRC = st.c x.c boxdraw.c OBJ = $(SRC:.c=.o) -all: options st - -options: - @echo st build options: - @echo "CFLAGS = $(STCFLAGS)" - @echo "LDFLAGS = $(STLDFLAGS)" - @echo "CC = $(CC)" +all: xst config.h: cp config.def.h config.h @@ -27,21 +21,21 @@ boxdraw.o: config.h st.h boxdraw_data.h $(OBJ): config.h config.mk -st: $(OBJ) +xst: $(OBJ) $(CC) -o xst $(OBJ) $(STLDFLAGS) clean: - rm -f xst config.h $(OBJ) st-$(VERSION).tar.gz + rm -f xst config.h $(OBJ) xst-$(VERSION).tar.gz dist: clean - mkdir -p st-$(VERSION) + mkdir -p xst-$(VERSION) cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\ config.def.h st.info st.1 arg.h st.h win.h $(SRC)\ - st-$(VERSION) - tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz - rm -rf st-$(VERSION) + xst-$(VERSION) + tar -cf - xst-$(VERSION) | gzip > xst-$(VERSION).tar.gz + rm -rf xst-$(VERSION) -install: st +install: xst mkdir -p $(DESTDIR)$(PREFIX)/bin cp -f xst $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/xst @@ -62,4 +56,4 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/share/terminfo/x/xst-meta-256color rm -f $(DESTDIR)$(PREFIX)/share/terminfo/x/xst-mono -.PHONY: all options clean dist install uninstall +.PHONY: all clean dist install uninstall diff --git a/config.def.h b/config.def.h index 76c38a1..5564498 100644 --- a/config.def.h +++ b/config.def.h @@ -83,7 +83,7 @@ int allowwindowops = 0; * near minlatency, but it waits longer for slow updates to avoid partial draw. * low minlatency will tear/flicker more, as it can "detect" idle too early. */ -static double minlatency = 8; +static double minlatency = 2; static double maxlatency = 33; /* diff --git a/st.c b/st.c index 96d0d48..a2d02ed 100644 --- a/st.c +++ b/st.c @@ -1178,7 +1178,7 @@ tscrollup(int orig, int n, int copyhist) void selscroll(int orig, int n) { - if (sel.ob.x == -1) + if (sel.ob.x == -1 || sel.alt != IS_SET(MODE_ALTSCREEN)) return; if (BETWEEN(sel.nb.y, orig, term.bot) != BETWEEN(sel.ne.y, orig, term.bot)) { @@ -1235,6 +1235,7 @@ csiparse(void) { char *p = csiescseq.buf, *np; long int v; + int sep = ';'; /* colon or semi-colon, but not both */ csiescseq.narg = 0; if (*p == '?') { @@ -1253,7 +1254,9 @@ csiparse(void) csiescseq.arg[csiescseq.narg++] = v; p = np; readcolonargs(&p, csiescseq.narg-1, csiescseq.carg); - if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ) + if (sep == ';' && *p == ':') + sep = ':'; /* allow override to colon once */ + if (*p != sep || csiescseq.narg == ESC_ARG_SIZ) break; p++; } @@ -1773,7 +1776,7 @@ csihandle(void) ttywrite(vtiden, strlen(vtiden), 0); break; case 'b': /* REP -- if last char is printable print it more times */ - DEFAULT(csiescseq.arg[0], 1); + LIMIT(csiescseq.arg[0], 1, 65535); if (term.lastc) while (csiescseq.arg[0]-- > 0) tputc(term.lastc); @@ -1858,6 +1861,7 @@ csihandle(void) } break; case 'S': /* SU -- Scroll line up */ + if (csiescseq.priv) break; DEFAULT(csiescseq.arg[0], 1); tscrollup(term.top, csiescseq.arg[0], 0); break; @@ -2513,6 +2517,7 @@ eschandle(uchar ascii) treset(); resettitle(); xloadcols(); + xsetmode(0, MODE_HIDE); break; case '=': /* DECPAM -- Application keypad */ xsetmode(1, MODE_APPKEYPAD); @@ -2654,11 +2659,16 @@ tputc(Rune u) gp = &term.line[term.c.y][term.c.x]; } - if (IS_SET(MODE_INSERT) && term.c.x+width < term.col) + if (IS_SET(MODE_INSERT) && term.c.x+width < term.col) { memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph)); + gp->mode &= ~ATTR_WIDE; + } if (term.c.x+width > term.col) { - tnewline(1); + if (IS_SET(MODE_WRAP)) + tnewline(1); + else + tmoveto(term.col - width, term.c.y); gp = &term.line[term.c.y][term.c.x]; } diff --git a/st.info b/st.info index fe0d4f5..eeb9bbb 100644 --- a/st.info +++ b/st.info @@ -185,6 +185,10 @@ xst-mono| simpleterm monocolor, # XTerm extensions rmxx=\E[29m, smxx=\E[9m, + BE=\E[?2004h, + BD=\E[?2004l, + PS=\E[200~, + PE=\E[201~, # disabled rep for now: causes some issues with older ncurses versions. # rep=%p1%c\E[%p2%{1}%-%db, # tmux extensions, see TERMINFO EXTENSIONS in tmux(1) diff --git a/x.c b/x.c index 29dafe9..46eef22 100644 --- a/x.c +++ b/x.c @@ -888,7 +888,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; @@ -903,7 +903,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)) @@ -1322,7 +1322,7 @@ xinit(int cols, int rows) { XGCValues gcvalues; Cursor cursor; - Window parent; + Window parent, root; pid_t thispid = getpid(); XColor xmousefg, xmousebg; XWindowAttributes attr; @@ -1378,15 +1378,21 @@ xinit(int cols, int rows) | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask; xw.attrs.colormap = xw.cmap; - xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, + root = XRootWindow(xw.dpy, xw.scr); + if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) + parent = root; + xw.win = XCreateWindow(xw.dpy, root, xw.l, xw.t, win.w, win.h, 0, xw.depth, InputOutput, xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity | CWEventMask | CWColormap, &xw.attrs); + if (parent != root) + XReparentWindow(xw.dpy, xw.win, parent, xw.l, xw.t); memset(&gcvalues, 0, sizeof(gcvalues)); gcvalues.graphics_exposures = False; + dc.gc = XCreateGC(xw.dpy, xw.win, GCGraphicsExposures, + &gcvalues); xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth); - dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues); XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); @@ -2298,6 +2304,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; @@ -2312,6 +2321,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;