mirror of
git://git.suckless.org/st
synced 2025-04-20 03:44:46 +01:00
Compare commits
No commits in common. "master" and "0.9" have entirely different histories.
10
Makefile
10
Makefile
@ -7,7 +7,13 @@ include config.mk
|
|||||||
SRC = st.c x.c
|
SRC = st.c x.c
|
||||||
OBJ = $(SRC:.c=.o)
|
OBJ = $(SRC:.c=.o)
|
||||||
|
|
||||||
all: st
|
all: options st
|
||||||
|
|
||||||
|
options:
|
||||||
|
@echo st build options:
|
||||||
|
@echo "CFLAGS = $(STCFLAGS)"
|
||||||
|
@echo "LDFLAGS = $(STLDFLAGS)"
|
||||||
|
@echo "CC = $(CC)"
|
||||||
|
|
||||||
config.h:
|
config.h:
|
||||||
cp config.def.h config.h
|
cp config.def.h config.h
|
||||||
@ -48,4 +54,4 @@ uninstall:
|
|||||||
rm -f $(DESTDIR)$(PREFIX)/bin/st
|
rm -f $(DESTDIR)$(PREFIX)/bin/st
|
||||||
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||||
|
|
||||||
.PHONY: all clean dist install uninstall
|
.PHONY: all options clean dist install uninstall
|
||||||
|
@ -53,7 +53,7 @@ int allowwindowops = 0;
|
|||||||
* near minlatency, but it waits longer for slow updates to avoid partial draw.
|
* 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.
|
* low minlatency will tear/flicker more, as it can "detect" idle too early.
|
||||||
*/
|
*/
|
||||||
static double minlatency = 2;
|
static double minlatency = 8;
|
||||||
static double maxlatency = 33;
|
static double maxlatency = 33;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# st version
|
# st version
|
||||||
VERSION = 0.9.2
|
VERSION = 0.9
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
42
st.c
42
st.c
@ -1097,7 +1097,7 @@ tscrollup(int orig, int n)
|
|||||||
void
|
void
|
||||||
selscroll(int orig, int n)
|
selscroll(int orig, int n)
|
||||||
{
|
{
|
||||||
if (sel.ob.x == -1 || sel.alt != IS_SET(MODE_ALTSCREEN))
|
if (sel.ob.x == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (BETWEEN(sel.nb.y, orig, term.bot) != BETWEEN(sel.ne.y, orig, term.bot)) {
|
if (BETWEEN(sel.nb.y, orig, term.bot) != BETWEEN(sel.ne.y, orig, term.bot)) {
|
||||||
@ -1132,7 +1132,6 @@ csiparse(void)
|
|||||||
{
|
{
|
||||||
char *p = csiescseq.buf, *np;
|
char *p = csiescseq.buf, *np;
|
||||||
long int v;
|
long int v;
|
||||||
int sep = ';'; /* colon or semi-colon, but not both */
|
|
||||||
|
|
||||||
csiescseq.narg = 0;
|
csiescseq.narg = 0;
|
||||||
if (*p == '?') {
|
if (*p == '?') {
|
||||||
@ -1150,9 +1149,7 @@ csiparse(void)
|
|||||||
v = -1;
|
v = -1;
|
||||||
csiescseq.arg[csiescseq.narg++] = v;
|
csiescseq.arg[csiescseq.narg++] = v;
|
||||||
p = np;
|
p = np;
|
||||||
if (sep == ';' && *p == ':')
|
if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ)
|
||||||
sep = ':'; /* allow override to colon once */
|
|
||||||
if (*p != sep || csiescseq.narg == ESC_ARG_SIZ)
|
|
||||||
break;
|
break;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@ -1646,7 +1643,7 @@ csihandle(void)
|
|||||||
ttywrite(vtiden, strlen(vtiden), 0);
|
ttywrite(vtiden, strlen(vtiden), 0);
|
||||||
break;
|
break;
|
||||||
case 'b': /* REP -- if last char is printable print it <n> more times */
|
case 'b': /* REP -- if last char is printable print it <n> more times */
|
||||||
LIMIT(csiescseq.arg[0], 1, 65535);
|
DEFAULT(csiescseq.arg[0], 1);
|
||||||
if (term.lastc)
|
if (term.lastc)
|
||||||
while (csiescseq.arg[0]-- > 0)
|
while (csiescseq.arg[0]-- > 0)
|
||||||
tputc(term.lastc);
|
tputc(term.lastc);
|
||||||
@ -1705,7 +1702,7 @@ csihandle(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1: /* above */
|
case 1: /* above */
|
||||||
if (term.c.y > 0)
|
if (term.c.y > 1)
|
||||||
tclearregion(0, 0, term.col-1, term.c.y-1);
|
tclearregion(0, 0, term.col-1, term.c.y-1);
|
||||||
tclearregion(0, term.c.y, term.c.x, term.c.y);
|
tclearregion(0, term.c.y, term.c.x, term.c.y);
|
||||||
break;
|
break;
|
||||||
@ -1731,7 +1728,6 @@ csihandle(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'S': /* SU -- Scroll <n> line up */
|
case 'S': /* SU -- Scroll <n> line up */
|
||||||
if (csiescseq.priv) break;
|
|
||||||
DEFAULT(csiescseq.arg[0], 1);
|
DEFAULT(csiescseq.arg[0], 1);
|
||||||
tscrollup(term.top, csiescseq.arg[0]);
|
tscrollup(term.top, csiescseq.arg[0]);
|
||||||
break;
|
break;
|
||||||
@ -1773,18 +1769,11 @@ csihandle(void)
|
|||||||
case 'm': /* SGR -- Terminal attribute (color) */
|
case 'm': /* SGR -- Terminal attribute (color) */
|
||||||
tsetattr(csiescseq.arg, csiescseq.narg);
|
tsetattr(csiescseq.arg, csiescseq.narg);
|
||||||
break;
|
break;
|
||||||
case 'n': /* DSR -- Device Status Report */
|
case 'n': /* DSR – Device Status Report (cursor position) */
|
||||||
switch (csiescseq.arg[0]) {
|
if (csiescseq.arg[0] == 6) {
|
||||||
case 5: /* Status Report "OK" `0n` */
|
|
||||||
ttywrite("\033[0n", sizeof("\033[0n") - 1, 0);
|
|
||||||
break;
|
|
||||||
case 6: /* Report Cursor Position (CPR) "<row>;<column>R" */
|
|
||||||
len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
|
len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
|
||||||
term.c.y+1, term.c.x+1);
|
term.c.y+1, term.c.x+1);
|
||||||
ttywrite(buf, len, 0);
|
ttywrite(buf, len, 0);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto unknown;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'r': /* DECSTBM -- Set Scrolling Region */
|
case 'r': /* DECSTBM -- Set Scrolling Region */
|
||||||
@ -1801,11 +1790,7 @@ csihandle(void)
|
|||||||
tcursor(CURSOR_SAVE);
|
tcursor(CURSOR_SAVE);
|
||||||
break;
|
break;
|
||||||
case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
|
case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
|
||||||
if (csiescseq.priv) {
|
|
||||||
goto unknown;
|
|
||||||
} else {
|
|
||||||
tcursor(CURSOR_LOAD);
|
tcursor(CURSOR_LOAD);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
switch (csiescseq.mode[1]) {
|
switch (csiescseq.mode[1]) {
|
||||||
@ -1947,10 +1932,8 @@ strhandle(void)
|
|||||||
if (p && !strcmp(p, "?")) {
|
if (p && !strcmp(p, "?")) {
|
||||||
osc_color_response(j, 0, 1);
|
osc_color_response(j, 0, 1);
|
||||||
} else if (xsetcolorname(j, p)) {
|
} else if (xsetcolorname(j, p)) {
|
||||||
if (par == 104 && narg <= 1) {
|
if (par == 104 && narg <= 1)
|
||||||
xloadcols();
|
|
||||||
return; /* color reset without parameter */
|
return; /* color reset without parameter */
|
||||||
}
|
|
||||||
fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
|
fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
|
||||||
j, p ? p : "(null)");
|
j, p ? p : "(null)");
|
||||||
} else {
|
} else {
|
||||||
@ -2338,7 +2321,6 @@ eschandle(uchar ascii)
|
|||||||
treset();
|
treset();
|
||||||
resettitle();
|
resettitle();
|
||||||
xloadcols();
|
xloadcols();
|
||||||
xsetmode(0, MODE_HIDE);
|
|
||||||
break;
|
break;
|
||||||
case '=': /* DECPAM -- Application keypad */
|
case '=': /* DECPAM -- Application keypad */
|
||||||
xsetmode(1, MODE_APPKEYPAD);
|
xsetmode(1, MODE_APPKEYPAD);
|
||||||
@ -2431,9 +2413,6 @@ check_control_code:
|
|||||||
* they must not cause conflicts with sequences.
|
* they must not cause conflicts with sequences.
|
||||||
*/
|
*/
|
||||||
if (control) {
|
if (control) {
|
||||||
/* in UTF-8 mode ignore handling C1 control characters */
|
|
||||||
if (IS_SET(MODE_UTF8) && ISCONTROLC1(u))
|
|
||||||
return;
|
|
||||||
tcontrolcode(u);
|
tcontrolcode(u);
|
||||||
/*
|
/*
|
||||||
* control codes are not shown ever
|
* control codes are not shown ever
|
||||||
@ -2480,16 +2459,11 @@ check_control_code:
|
|||||||
gp = &term.line[term.c.y][term.c.x];
|
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));
|
memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph));
|
||||||
gp->mode &= ~ATTR_WIDE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (term.c.x+width > term.col) {
|
if (term.c.x+width > term.col) {
|
||||||
if (IS_SET(MODE_WRAP))
|
|
||||||
tnewline(1);
|
tnewline(1);
|
||||||
else
|
|
||||||
tmoveto(term.col - width, term.c.y);
|
|
||||||
gp = &term.line[term.c.y][term.c.x];
|
gp = &term.line[term.c.y][term.c.x];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
st.info
4
st.info
@ -184,10 +184,6 @@ st-mono| simpleterm monocolor,
|
|||||||
# XTerm extensions
|
# XTerm extensions
|
||||||
rmxx=\E[29m,
|
rmxx=\E[29m,
|
||||||
smxx=\E[9m,
|
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.
|
# disabled rep for now: causes some issues with older ncurses versions.
|
||||||
# rep=%p1%c\E[%p2%{1}%-%db,
|
# rep=%p1%c\E[%p2%{1}%-%db,
|
||||||
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
|
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
|
||||||
|
30
x.c
30
x.c
@ -818,7 +818,7 @@ xloadcols(void)
|
|||||||
int
|
int
|
||||||
xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b)
|
xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b)
|
||||||
{
|
{
|
||||||
if (!BETWEEN(x, 0, dc.collen - 1))
|
if (!BETWEEN(x, 0, dc.collen))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
*r = dc.col[x].color.red >> 8;
|
*r = dc.col[x].color.red >> 8;
|
||||||
@ -833,7 +833,7 @@ xsetcolorname(int x, const char *name)
|
|||||||
{
|
{
|
||||||
Color ncolor;
|
Color ncolor;
|
||||||
|
|
||||||
if (!BETWEEN(x, 0, dc.collen - 1))
|
if (!BETWEEN(x, 0, dc.collen))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!xloadcolor(x, name, &ncolor))
|
if (!xloadcolor(x, name, &ncolor))
|
||||||
@ -1131,7 +1131,7 @@ xinit(int cols, int rows)
|
|||||||
{
|
{
|
||||||
XGCValues gcvalues;
|
XGCValues gcvalues;
|
||||||
Cursor cursor;
|
Cursor cursor;
|
||||||
Window parent, root;
|
Window parent;
|
||||||
pid_t thispid = getpid();
|
pid_t thispid = getpid();
|
||||||
XColor xmousefg, xmousebg;
|
XColor xmousefg, xmousebg;
|
||||||
|
|
||||||
@ -1168,19 +1168,16 @@ xinit(int cols, int rows)
|
|||||||
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
|
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
|
||||||
xw.attrs.colormap = xw.cmap;
|
xw.attrs.colormap = xw.cmap;
|
||||||
|
|
||||||
root = XRootWindow(xw.dpy, xw.scr);
|
|
||||||
if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
|
if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
|
||||||
parent = root;
|
parent = XRootWindow(xw.dpy, xw.scr);
|
||||||
xw.win = XCreateWindow(xw.dpy, root, xw.l, xw.t,
|
xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
|
||||||
win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
|
win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
|
||||||
xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
|
xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
|
||||||
| CWEventMask | CWColormap, &xw.attrs);
|
| CWEventMask | CWColormap, &xw.attrs);
|
||||||
if (parent != root)
|
|
||||||
XReparentWindow(xw.dpy, xw.win, parent, xw.l, xw.t);
|
|
||||||
|
|
||||||
memset(&gcvalues, 0, sizeof(gcvalues));
|
memset(&gcvalues, 0, sizeof(gcvalues));
|
||||||
gcvalues.graphics_exposures = False;
|
gcvalues.graphics_exposures = False;
|
||||||
dc.gc = XCreateGC(xw.dpy, xw.win, GCGraphicsExposures,
|
dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
|
||||||
&gcvalues);
|
&gcvalues);
|
||||||
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
||||||
DefaultDepth(xw.dpy, xw.scr));
|
DefaultDepth(xw.dpy, xw.scr));
|
||||||
@ -1620,9 +1617,6 @@ xseticontitle(char *p)
|
|||||||
XTextProperty prop;
|
XTextProperty prop;
|
||||||
DEFAULT(p, opt_title);
|
DEFAULT(p, opt_title);
|
||||||
|
|
||||||
if (p[0] == '\0')
|
|
||||||
p = opt_title;
|
|
||||||
|
|
||||||
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
|
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
|
||||||
&prop) != Success)
|
&prop) != Success)
|
||||||
return;
|
return;
|
||||||
@ -1637,9 +1631,6 @@ xsettitle(char *p)
|
|||||||
XTextProperty prop;
|
XTextProperty prop;
|
||||||
DEFAULT(p, opt_title);
|
DEFAULT(p, opt_title);
|
||||||
|
|
||||||
if (p[0] == '\0')
|
|
||||||
p = opt_title;
|
|
||||||
|
|
||||||
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
|
if (Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
|
||||||
&prop) != Success)
|
&prop) != Success)
|
||||||
return;
|
return;
|
||||||
@ -1842,7 +1833,7 @@ void
|
|||||||
kpress(XEvent *ev)
|
kpress(XEvent *ev)
|
||||||
{
|
{
|
||||||
XKeyEvent *e = &ev->xkey;
|
XKeyEvent *e = &ev->xkey;
|
||||||
KeySym ksym = NoSymbol;
|
KeySym ksym;
|
||||||
char buf[64], *customkey;
|
char buf[64], *customkey;
|
||||||
int len;
|
int len;
|
||||||
Rune c;
|
Rune c;
|
||||||
@ -1852,13 +1843,10 @@ kpress(XEvent *ev)
|
|||||||
if (IS_SET(MODE_KBDLOCK))
|
if (IS_SET(MODE_KBDLOCK))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (xw.ime.xic) {
|
if (xw.ime.xic)
|
||||||
len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
|
len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
|
||||||
if (status == XBufferOverflow)
|
else
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
|
len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
|
||||||
}
|
|
||||||
/* 1. shortcuts */
|
/* 1. shortcuts */
|
||||||
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
|
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
|
||||||
if (ksym == bp->keysym && match(bp->mod, e->state)) {
|
if (ksym == bp->keysym && match(bp->mod, e->state)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user