summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-08-04 22:09:40 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-08-04 22:11:23 +0200
commit52fe157384f9a493b7f96f9e1374a56cc7369280 (patch)
tree237bd75b2b916dd7df3540b75b6e01f4399397e6
parent4c01cfd24e5f32beb00abaed8d110856559610b0 (diff)
parentfa253f077f19b3220c7655b81bd91e52f4367803 (diff)
downloadst-52fe157384f9a493b7f96f9e1374a56cc7369280.tar.gz
st-52fe157384f9a493b7f96f9e1374a56cc7369280.tar.bz2
st-52fe157384f9a493b7f96f9e1374a56cc7369280.zip
Merge remote-tracking branch 'suckless/master'
-rw-r--r--FAQ59
-rw-r--r--LICENSE2
-rw-r--r--config.def.h6
-rw-r--r--config.h10
-rw-r--r--config.mk6
-rw-r--r--st.c42
-rw-r--r--st.h1
-rw-r--r--st.info3
-rw-r--r--x.c9
9 files changed, 97 insertions, 41 deletions
diff --git a/FAQ b/FAQ
index 85534a4..0f9609d 100644
--- a/FAQ
+++ b/FAQ
@@ -2,12 +2,14 @@
Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task.
+
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
It means that st doesn’t have any terminfo entry on your system. Chances are
you did not `make install`. If you just want to test it without installing it,
you can manually run `tic -sx st.info`.
+
## Nothing works, and nothing is said about an unknown terminal!
* Some programs just assume they’re running in xterm i.e. they don’t rely on
@@ -15,6 +17,7 @@ you can manually run `tic -sx st.info`.
* Some programs don’t complain about the lacking st description and default to
another terminal. In that case see the question about terminfo.
+
## How do I scroll back up?
* Using a terminal multiplexer.
@@ -23,11 +26,13 @@ you can manually run `tic -sx st.info`.
* Using the excellent tool of [scroll](https://git.suckless.org/scroll/).
* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/).
+
## I would like to have utmp and/or scroll functionality by default
You can add the absolute patch of both programs in your config.h
file. You only have to modify the value of utmp and scroll variables.
+
## Why doesn't the Del key work in some programs?
Taken from the terminfo manpage:
@@ -83,12 +88,14 @@ If you are using zsh, then read the zsh FAQ
Putting these lines into your .zshrc will fix the problems.
+
## How can I use meta in 8bit mode?
St supports meta in 8bit mode, but the default terminfo entry doesn't
use this capability. If you want it, you have to use the 'st-meta' value
in TERM.
+
## I cannot compile st in OpenBSD
OpenBSD lacks librt, despite it being mandatory in POSIX
@@ -97,6 +104,7 @@ If you want to compile st for OpenBSD you have to remove -lrt from config.mk, an
st will compile without any loss of functionality, because all the functions are
included in libc on this platform.
+
## The Backspace Case
St is emulating the Linux way of handling backspace being delete and delete being
@@ -158,19 +166,60 @@ terminal users wants its backspace to be how he feels it:
[1] http://www.ibb.net/~anne/keyboard.html
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
+
## But I really want the old grumpy behaviour of my terminal
Apply [1].
[1] https://st.suckless.org/patches/delkey
-## Why do images not work in st (in programs such as w3m)?
-This is a terrible hack that overdraws an image on top of the terminal emulator
-window. It also relies on a very specific way the terminal draws it's contents.
+## Why do images not work in st using the w3m image hack?
+
+w3mimg uses a hack that draws an image on top of the terminal emulator Drawable
+window. The hack relies on the terminal to use a single buffer to draw its
+contents directly.
+
+st uses double-buffered drawing so the image is quickly replaced and may show a
+short flicker effect.
+
+Below is a patch example to change st double-buffering to a single Drawable
+buffer.
+
+diff --git a/x.c b/x.c
+--- a/x.c
++++ b/x.c
+@@ -732,10 +732,6 @@ xresize(int col, int row)
+ win.tw = col * win.cw;
+ win.th = row * win.ch;
+
+- XFreePixmap(xw.dpy, xw.buf);
+- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
+- DefaultDepth(xw.dpy, xw.scr));
+- XftDrawChange(xw.draw, xw.buf);
+ xclear(0, 0, win.w, win.h);
+
+ /* resize to new width */
+@@ -1148,8 +1144,7 @@ xinit(int cols, int rows)
+ gcvalues.graphics_exposures = False;
+ dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
+ &gcvalues);
+- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
+- DefaultDepth(xw.dpy, xw.scr));
++ xw.buf = xw.win;
+ XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
+ XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
+
+@@ -1632,8 +1627,6 @@ xdrawline(Line line, int x1, int y1, int x2)
+ void
+ xfinishdraw(void)
+ {
+- XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w,
+- win.h, 0, 0);
+ XSetForeground(xw.dpy, dc.gc,
+ dc.col[IS_SET(MODE_REVERSE)?
+ defaultfg : defaultbg].pixel);
-A more proper (but limited way) would be using sixels. Which st doesn't
-support.
## BadLength X error in Xft when trying to render emoji
diff --git a/LICENSE b/LICENSE
index c356c39..d80eb47 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT/X Consortium License
-© 2014-2018 Hiltjo Posthuma <hiltjo at codemadness dot org>
+© 2014-2020 Hiltjo Posthuma <hiltjo at codemadness dot org>
© 2018 Devin J. Pohly <djpohly at gmail dot com>
© 2014-2017 Quentin Rameau <quinq at fifth dot space>
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
diff --git a/config.def.h b/config.def.h
index 29dda06..aecbe46 100644
--- a/config.def.h
+++ b/config.def.h
@@ -43,6 +43,10 @@ static unsigned int tripleclicktimeout = 600;
/* alt screens */
int allowaltscreen = 1;
+/* allow certain non-interactive (insecure) window operations such as:
+ setting the clipboard text */
+int allowwindowops = 0;
+
/*
* draw latency range in ms - from new content/keypress/etc until drawing.
* within this range, st draws when content stops arriving (idle). mostly it's
@@ -165,7 +169,9 @@ static MouseShortcut mshortcuts[] = {
{ XK_ANY_MOD, Button4, kscrollup, {.i = 3} },
{ XK_ANY_MOD, Button5, kscrolldown, {.i = 3} },
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
+ { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
+ { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
};
diff --git a/config.h b/config.h
index bf8f775..aecbe46 100644
--- a/config.h
+++ b/config.h
@@ -43,6 +43,10 @@ static unsigned int tripleclicktimeout = 600;
/* alt screens */
int allowaltscreen = 1;
+/* allow certain non-interactive (insecure) window operations such as:
+ setting the clipboard text */
+int allowwindowops = 0;
+
/*
* draw latency range in ms - from new content/keypress/etc until drawing.
* within this range, st draws when content stops arriving (idle). mostly it's
@@ -162,10 +166,12 @@ static uint forcemousemod = ShiftMask;
*/
static MouseShortcut mshortcuts[] = {
/* mask button function argument release */
- { XK_ANY_MOD, Button4, kscrollup, {.i = 2} },
- { XK_ANY_MOD, Button5, kscrolldown, {.i = 2} },
+ { XK_ANY_MOD, Button4, kscrollup, {.i = 3} },
+ { XK_ANY_MOD, Button5, kscrolldown, {.i = 3} },
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
+ { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
+ { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
};
diff --git a/config.mk b/config.mk
index ef19587..70ecea1 100644
--- a/config.mk
+++ b/config.mk
@@ -1,5 +1,5 @@
# st version
-VERSION = 0.8.3
+VERSION = 0.8.4
# Customize below to fit your system
@@ -32,8 +32,8 @@ STLDFLAGS = $(LIBS) $(LDFLAGS)
# OpenBSD:
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
-# `pkg-config --libs fontconfig` \
-# `pkg-config --libs freetype2`
+# `$(PKG_CONFIG) --libs fontconfig` \
+# `$(PKG_CONFIG) --libs freetype2`
# compiler and linker
# CC = c99
diff --git a/st.c b/st.c
index 18cdc95..ea13c13 100644
--- a/st.c
+++ b/st.c
@@ -55,7 +55,6 @@ enum term_mode {
MODE_ECHO = 1 << 4,
MODE_PRINT = 1 << 5,
MODE_UTF8 = 1 << 6,
- MODE_SIXEL = 1 << 7,
};
enum cursor_movement {
@@ -82,12 +81,11 @@ enum charset {
enum escape_state {
ESC_START = 1,
ESC_CSI = 2,
- ESC_STR = 4, /* OSC, PM, APC */
+ ESC_STR = 4, /* DCS, OSC, PM, APC */
ESC_ALTCHARSET = 8,
ESC_STR_END = 16, /* a final string was encountered */
ESC_TEST = 32, /* Enter in test mode */
ESC_UTF8 = 64,
- ESC_DCS =128,
};
typedef struct {
@@ -136,6 +134,7 @@ typedef struct {
int charset; /* current charset */
int icharset; /* selected charset for sequence */
int *tabs;
+ Rune lastc; /* last printed char outside of sequence, 0 if control */
} Term;
/* CSI Escape sequence structs */
@@ -849,7 +848,6 @@ ttyread(void)
if (buflen > 0)
memmove(buf, buf + written, buflen);
return ret;
-
}
}
@@ -1710,6 +1708,12 @@ csihandle(void)
if (csiescseq.arg[0] == 0)
ttywrite(vtiden, strlen(vtiden), 0);
break;
+ case 'b': /* REP -- if last char is printable print it <n> more times */
+ DEFAULT(csiescseq.arg[0], 1);
+ if (term.lastc)
+ while (csiescseq.arg[0]-- > 0)
+ tputc(term.lastc);
+ break;
case 'C': /* CUF -- Cursor <n> Forward */
case 'a': /* HPR -- Cursor <n> Forward */
DEFAULT(csiescseq.arg[0], 1);
@@ -1833,7 +1837,7 @@ csihandle(void)
break;
case 'n': /* DSR – Device Status Report (cursor position) */
if (csiescseq.arg[0] == 6) {
- len = snprintf(buf, sizeof(buf),"\033[%i;%iR",
+ len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
term.c.y+1, term.c.x+1);
ttywrite(buf, len, 0);
}
@@ -1917,7 +1921,7 @@ strhandle(void)
xsettitle(strescseq.args[1]);
return;
case 52:
- if (narg > 2) {
+ if (narg > 2 && allowwindowops) {
dec = base64dec(strescseq.args[2]);
if (dec) {
xsetsel(dec);
@@ -1953,7 +1957,6 @@ strhandle(void)
xsettitle(strescseq.args[0]);
return;
case 'P': /* DCS -- Device Control String */
- term.mode |= ESC_DCS;
case '_': /* APC -- Application Program Command */
case '^': /* PM -- Privacy Message */
return;
@@ -2147,12 +2150,9 @@ tdectest(char c)
void
tstrsequence(uchar c)
{
- strreset();
-
switch (c) {
case 0x90: /* DCS -- Device Control String */
c = 'P';
- term.esc |= ESC_DCS;
break;
case 0x9f: /* APC -- Application Program Command */
c = '_';
@@ -2164,6 +2164,7 @@ tstrsequence(uchar c)
c = ']';
break;
}
+ strreset();
strescseq.type = c;
term.esc |= ESC_STR;
}
@@ -2361,7 +2362,7 @@ tputc(Rune u)
Glyph *gp;
control = ISCONTROL(u);
- if (u < 127 || !IS_SET(MODE_UTF8 | MODE_SIXEL)) {
+ if (u < 127 || !IS_SET(MODE_UTF8)) {
c[0] = u;
width = len = 1;
} else {
@@ -2382,23 +2383,11 @@ tputc(Rune u)
if (term.esc & ESC_STR) {
if (u == '\a' || u == 030 || u == 032 || u == 033 ||
ISCONTROLC1(u)) {
- term.esc &= ~(ESC_START|ESC_STR|ESC_DCS);
- if (IS_SET(MODE_SIXEL)) {
- /* TODO: render sixel */;
- term.mode &= ~MODE_SIXEL;
- return;
- }
+ term.esc &= ~(ESC_START|ESC_STR);
term.esc |= ESC_STR_END;
goto check_control_code;
}
- if (IS_SET(MODE_SIXEL)) {
- /* TODO: implement sixel mode */
- return;
- }
- if (term.esc&ESC_DCS && strescseq.len == 0 && u == 'q')
- term.mode |= MODE_SIXEL;
-
if (strescseq.len+len >= strescseq.siz) {
/*
* Here is a bug in terminals. If the user never sends
@@ -2435,6 +2424,8 @@ check_control_code:
/*
* control codes are not shown ever
*/
+ if (!term.esc)
+ term.lastc = 0;
return;
} else if (term.esc & ESC_START) {
if (term.esc & ESC_CSI) {
@@ -2484,6 +2475,7 @@ check_control_code:
}
tsetchar(u, &term.c.attr, term.c.x, term.c.y);
+ term.lastc = u;
if (width == 2) {
gp->mode |= ATTR_WIDE;
@@ -2507,7 +2499,7 @@ twrite(const char *buf, int buflen, int show_ctrl)
int n;
for (n = 0; n < buflen; n += charsize) {
- if (IS_SET(MODE_UTF8) && !IS_SET(MODE_SIXEL)) {
+ if (IS_SET(MODE_UTF8)) {
/* process a complete utf8 char */
charsize = utf8decode(buf + n, &u, buflen - n);
if (charsize == 0)
diff --git a/st.h b/st.h
index b49b84a..00c796c 100644
--- a/st.h
+++ b/st.h
@@ -122,6 +122,7 @@ extern char *stty_args;
extern char *vtiden;
extern wchar_t *worddelimiters;
extern int allowaltscreen;
+extern int allowwindowops;
extern char *termname;
extern unsigned int tabspaces;
extern unsigned int defaultfg;
diff --git a/st.info b/st.info
index e2abc98..8201ad6 100644
--- a/st.info
+++ b/st.info
@@ -158,6 +158,7 @@ st-mono| simpleterm monocolor,
rc=\E8,
rev=\E[7m,
ri=\EM,
+ rin=\E[%p1%dT,
ritm=\E[23m,
rmacs=\E(B,
rmcup=\E[?1049l,
@@ -183,6 +184,8 @@ st-mono| simpleterm monocolor,
# XTerm extensions
rmxx=\E[29m,
smxx=\E[9m,
+# 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)
Tc,
Ms=\E]52;%p1%s;%p2%s\007,
diff --git a/x.c b/x.c
index 761cd76..7bf04e9 100644
--- a/x.c
+++ b/x.c
@@ -1536,8 +1536,8 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le
/* draw the new one */
if (IS_SET(MODE_FOCUSED)) {
switch (win.cursor) {
- case 7: /* st extension: snowman (U+2603) */
- g.u = 0x2603;
+ case 7: /* st extension */
+ g.u = 0x2603; /* snowman (U+2603) */
/* FALLTHROUGH */
case 0: /* Blinking Block */
case 1: /* Blinking Block (Default) */
@@ -1700,8 +1700,7 @@ xsetmode(int set, unsigned int flags)
int
xsetcursor(int cursor)
{
- DEFAULT(cursor, 1);
- if (!BETWEEN(cursor, 0, 6))
+ if (!BETWEEN(cursor, 0, 7)) /* 7: st extension */
return 1;
win.cursor = cursor;
return 0;
@@ -1993,7 +1992,7 @@ main(int argc, char *argv[])
{
xw.l = xw.t = 0;
xw.isfixed = False;
- win.cursor = cursorshape;
+ xsetcursor(cursorshape);
ARGBEGIN {
case 'a':