Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with ST #167

Merged
merged 16 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# st - simple terminal
# xst - xresources simple terminal
# See LICENSE file for copyright and license details.
.POSIX:

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
Expand Down
20 changes: 15 additions & 5 deletions st.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 == '?') {
Expand All @@ -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++;
}
Expand Down Expand Up @@ -1773,7 +1776,7 @@ csihandle(void)
ttywrite(vtiden, strlen(vtiden), 0);
break;
case 'b': /* REP -- if last char is printable print it <n> more times */
DEFAULT(csiescseq.arg[0], 1);
LIMIT(csiescseq.arg[0], 1, 65535);
if (term.lastc)
while (csiescseq.arg[0]-- > 0)
tputc(term.lastc);
Expand Down Expand Up @@ -1858,6 +1861,7 @@ csihandle(void)
}
break;
case 'S': /* SU -- Scroll <n> line up */
if (csiescseq.priv) break;
DEFAULT(csiescseq.arg[0], 1);
tscrollup(term.top, csiescseq.arg[0], 0);
break;
Expand Down Expand Up @@ -2513,6 +2517,7 @@ eschandle(uchar ascii)
treset();
resettitle();
xloadcols();
xsetmode(0, MODE_HIDE);
break;
case '=': /* DECPAM -- Application keypad */
xsetmode(1, MODE_APPKEYPAD);
Expand Down Expand Up @@ -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];
}

Expand Down
4 changes: 4 additions & 0 deletions st.info
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 17 additions & 5 deletions x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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))
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading