Sergey Matveev [Sat, 23 May 2020 11:17:54 +0000 (14:17 +0300)]
My config
Sergey Matveev [Sun, 18 Feb 2024 15:39:51 +0000 (18:39 +0300)]
Optimisations
Sergey Matveev [Mon, 14 Apr 2025 09:37:38 +0000 (12:37 +0300)]
Do not print emojis
Sergey Matveev [Tue, 7 May 2024 10:14:45 +0000 (13:14 +0300)]
No cursor changing
Sergey Matveev [Thu, 28 Oct 2021 12:33:58 +0000 (15:33 +0300)]
Cursor blinking
Based on https://st.suckless.org/patches/blinking_cursor/st-blinking_cursor-
20200531-
a2a7044.diff
Sergey Matveev [Sat, 23 May 2020 11:17:48 +0000 (14:17 +0300)]
Coloured italics
Hiltjo Posthuma [Sat, 9 Aug 2025 12:35:14 +0000 (14:35 +0200)]
bump version to 0.9.3
Hiltjo Posthuma [Sat, 9 Aug 2025 10:57:30 +0000 (12:57 +0200)]
add a few comments
Ayman Bagabas [Fri, 8 Aug 2025 21:11:59 +0000 (17:11 -0400)]
Support OSC 110, 111, and 112 for resetting colors
This adds support for OSC 110, 111, and 112 escape sequences to reset
the foreground, background, and cursor colors in the terminal. The
changes include handling these sequences in the `strhandle` function of
`st.c`, allowing applications to reset colors to their default values.
The OSC sequences originated from Xterm control sequences and are now
widely used in terminal applications and supported by many terminal
emulators. For applications, this allows them to reset colors to
default values without needing to know the colors beforehand.
Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com>
sasha [Sun, 27 Jul 2025 05:43:47 +0000 (05:43 +0000)]
Eat up "CSI 58" sequences
This is used in the wild by systemd systemctl for example and st
misinterpreted it as "blink", because it didn't know "58", then saw "5"
as "blink", and then didn't know "245".
This should print "foo" as normal text:
printf '\e[58:5:245mfoo\n'
printf '\e[58:2:50:100:200mfoo\n'
Johannes Altmanninger [Sun, 26 Jan 2025 12:40:57 +0000 (13:40 +0100)]
Do not interpret CSI ? u as DECRC
The kitty keyboard protocol docs recommend CSI ? u to query support for
that protocol, see https://sw.kovidgoyal.net/kitty/keyboard-protocol/
For better or worse, fish shell uses this query to work around bugs
in other terminals triggered by requesting that protocol via CSI = 5 u.
Unfortunately, st interprets CSI ? u as DECRC (restore cursor
position). reproduce with 'printf "\x1b[?u"; cat'.
fish could work around this by switching to the alternate screen
before running this query; but that might cause tearing on terminals
that don't support Synchronized Output. I'm not sure.
In the meantime, let's correct our parser.
This adds a redundant else-after-return, for consistency with the
surrounding code.
Markus Rinne [Mon, 25 Nov 2024 11:31:56 +0000 (13:31 +0200)]
Clear screen: Fix edge case
With sequence \e[1J, if cursor is on second line, clear the first line.
Lucas de Sena [Fri, 9 Aug 2024 11:33:47 +0000 (13:33 +0200)]
fix BadMatch error when embedding on some windows
When embedded, st fails with BadMatch error if the embedder's window has
non-default colormap/depth/visual. This commit fixes that by creating
st's window inside root and then reparent it into embedder.
The reference window for dc.gc is also changed to match root's visuals.
A similar commit had been made for dmenu[1].
See this issue[2] on github for context.
[1]: https://git.suckless.org/dmenu/commit/
0fe460dbd469a1d5b6a7140d0e1801935e4a923b.html
[2]: https://github.com/phillbush/xfiles/issues/47
Hiltjo Posthuma [Wed, 1 May 2024 18:45:39 +0000 (20:45 +0200)]
support colons in SGR character attributes
Patch by Mikhail Kot <to@myrrc.dev>
With some modifications to behave more like xterm (see note below).
Example:
printf '\033[48;2;255:0:0mtest\n'
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
Some notes:
"CSI Pm m Character Attributes (SGR).
[...]
o xterm allows either colons (standard) or semicolons
(legacy) to separate the subparameters (but after the
first colon, colons must be used).
Hiltjo Posthuma [Fri, 5 Apr 2024 10:18:41 +0000 (12:18 +0200)]
bump version to 0.9.2
DOGMAN [Wed, 3 Apr 2024 17:48:11 +0000 (19:48 +0200)]
Reset title when an empty title string is given
With this patch, st will reset its window title when an empty string is
given as the terminal title. For example:
printf "\033]0;\007"
Some applications, like termdown, expect this functionality. xterm
implements it, but it seems that most other terminal emulators don't.
In any case, I don't see why there should ever be a case where the st
window doesn't have a title property.
Hiltjo Posthuma [Sat, 30 Mar 2024 11:30:49 +0000 (12:30 +0100)]
Revert "Fix cursor move with wide glyphs"
This reverts commit
7473a8d1a57e5f9aba41b953f4e498c35e1c9dc5.
This patch needs some more work. It caused regressions with programs that use
GNU readline, etc.
Original test-case example from Tim Culverhouse <tim@timculverhouse.com>:
printf " 😀" && sleep 2 && printf "\e[D" && sleep 2 && printf "\e[D" && sleep 2
After the patch it caused regressions, example test-case:
printf "A字\bB\n"
Hiltjo Posthuma [Tue, 19 Mar 2024 11:13:42 +0000 (12:13 +0100)]
bump version to 0.9.1
Hiltjo Posthuma [Sun, 17 Mar 2024 13:42:44 +0000 (14:42 +0100)]
config.def.h: improve latency for the default configuration
Tommi Hirvola [Mon, 4 Mar 2024 10:56:30 +0000 (12:56 +0200)]
set upper limit for REP escape sequence argument
Previously, printf 'L\033[
2147483647b' would call tputc('L') 2^31 times,
making st unresponsive. This commit allows repeating the last character
at most 65535 times in order to prevent freezing and DoS attacks.
Quentin Rameau [Sun, 25 Feb 2024 00:31:31 +0000 (01:31 +0100)]
Fix cursor move with wide glyphs
st would always move back 1 column,
even with wide glyhps (using more than a single column).
The glyph rune is set on its first column,
and the other ones are to 0,
so loop until we detect the start of the previous glyph.
Tim Culverhouse [Sun, 18 Feb 2024 12:56:49 +0000 (06:56 -0600)]
csi: check for private marker in 'S' case
The handler for 'S' final character does not check for a private
marker. This can cause a conflict with a sequence called 'XTSMGRAPHICS'
which also has an 'S' final character, but uses the private marker '?'.
Without checking for a private marker, st will perform a scroll up
operation when XTSMGRAPHICS is seen, which can cause unexpected display
artifacts.
Peter Hofmann [Sat, 7 Oct 2023 05:41:02 +0000 (07:41 +0200)]
Add terminfo entries for bracketed paste mode
Helps Vim (and hopefully others) to discover that this feature exists
without further user configuration.
Peter Hofmann [Sat, 7 Oct 2023 05:40:45 +0000 (07:40 +0200)]
Unhide cursor on RIS (\033c)
It is unclear if it's "required" to do this on RIS, but it's useful when
calling reset(1) after interactive programs have crashed and garbled up
the screen.
FWIW, other terminals do it as well (tested with XTerm, VTE, Kitty,
Alacritty, Linux VT).
Peter Hofmann [Sat, 7 Oct 2023 05:40:39 +0000 (07:40 +0200)]
Fix wide glyphs breaking "nowrap" mode
Consider the following example:
printf '\e[?7l';\
for i in $(seq $(($(tput cols) - 1))); do printf a; done;\
printf '🙈\n';\
printf '\e[?7h'
Even though MODE_WRAP has been disabled, the emoji appeared on the next
line. This patch keeps wide glyphs on the same line and moves them to
the right-most possible position.
Peter Hofmann [Sat, 7 Oct 2023 05:40:07 +0000 (07:40 +0200)]
Don't scroll selection on the other screen
Fixes garbage selections when switching to/from the alternate screen.
How to reproduce:
- Be in primary screen.
- Select something.
- Run this (switches to alternate screen, positions the cursor at the
bottom, triggers selscroll(), and then goes back to primary screen):
tput smcup; tput cup $(tput lines) 0; echo foo; tput rmcup
- Notice how the (visual) selection now covers a different line.
The reason is that selscroll() calls selnormalize() and that cannot find
the original range anymore. It's all empty lines now, so it snaps to
"select the whole line".
Peter Hofmann [Sat, 7 Oct 2023 05:39:00 +0000 (07:39 +0200)]
Fix bounds checks of dc.col
dc.collen is the length of dc.col, not the maximum index, hence if x is
equal to dc.collen, then it's an error.
With config.def.h, the last valid index is 259, so this correctly
reports "black":
$ printf '\033]4;259;?\e\\'
260 is an invalid index and this reports garbage instead of printing an
error:
$ printf '\033]4;260;?\e\\'
Hiltjo Posthuma [Fri, 22 Sep 2023 13:16:52 +0000 (15:16 +0200)]
Makefile: remove the options target
The Makefile used to suppress output (by using @), so this target made sense at
the time.
But the Makefile should be simple and make debugging with less abstractions or
fancy printing. The Makefile was made verbose and doesn't hide the build
output, so remove this target.
Prompted by a question on the mailing list about the options target.
Shi Tian [Sun, 25 Jun 2023 05:38:33 +0000 (05:38 +0000)]
Fix for wide character being incorrectly cleared on MODE_INSERT
Under insert mode, when inserting a normal character in front of
a wide character, the affected region is shifted to the right by
one cell. However, the empty cell is reset as if being a part of a
wide character, causing the following cell being mishandled as a
dummy cell.
To reproduce the bug:
printf '\033[4h' # set MODE_INSERT
printf 妳好
printf '\033[4D'
printf 'x'
printf '\033[4l\n'
Hiltjo Posthuma [Tue, 7 Feb 2023 19:00:59 +0000 (20:00 +0100)]
ignore C1 control characters in UTF-8 mode
Ignore processing and printing C1 control characters in UTF-8 mode.
These are in the range: 0x80 - 0x9f.
By default in st the mode is set to UTF-8.
This matches more the behaviour of xterm with the options -u8 or +u8 also.
Also see the xterm resource "allowC1Printable".
Let me know if this breaks something, in most cases I don't think so.
As usual a very good reference is:
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
Adam Price [Tue, 7 Feb 2023 18:54:29 +0000 (19:54 +0100)]
Add support for DSR response "OK" escape sequence
"VT100 defines an escape sequence [1] called Device Status Report (DSR). When
the DSR sequence received is `csi 5n`, an "OK" response `csi 0n` is returned.
This patch adds that "OK" response.
I encountered this missing sequence when I noticed that fzf [2] would clobber
my prompt whenever completing a find.
To test that ST doesn't currently respond to `csi 5n`, use fzf's shell
extension in ST's repo to complete the path for a file.
my-fancy-prompt $ vim **<tab>
<select a file>
st.c
Select a file with <enter>, and notice that fzf clobbers some or all of your
prompt.
After applying this patch, do the same test as above and notice that fzf has no
longer clobbered your prompt by placing the file name in the correct position
in your command.
my-fancy-prompt $ vim **<tab>
<select a file>
my-fancy prompt $ vim st.c
Thank you for considering my first patch submission.
[1] https://www.xfree86.org/current/ctlseqs.html#VT100%20Mode
[2] https://github.com/junegunn/fzf
"
Patch slightly adapted with input from the mailinglist,
Hiltjo Posthuma [Sun, 5 Feb 2023 12:29:35 +0000 (13:29 +0100)]
Fixed OSC color reset without parameter->resets all colors
Adapted from (garbled) patch by wim <wim@thinkerwim.org>
Additional notes: it should reset all the colors using xloadcols().
To reproduce: set a different (theme) color using some escape code, then reset
it:
printf '\x1b]104\x07'
Hiltjo Posthuma [Tue, 25 Oct 2022 15:11:11 +0000 (17:11 +0200)]
fix buffer overflow when handling long composed input
To reproduce the issue:
"
If you already have the multi-key enabled on your system, then add this line
to your ~/.XCompose file:
[...]
<question> <T> <E> <S> <T> <question> :
"1234567890123456789012345678901234567890123456789012345678901234567890"
"
Reported by and an initial patch by Andy Gozas <andy@gozas.me>, thanks!
Adapted the patch, for now st (like dmenu) handles a fixed amount of composed
characters, or otherwise ignores it. This is done for simplicity sake.
Hiltjo Posthuma [Tue, 4 Oct 2022 17:40:30 +0000 (19:40 +0200)]
bump version to 0.9
Hiltjo Posthuma [Fri, 16 Sep 2022 21:07:09 +0000 (23:07 +0200)]
FAQ: document the color emojis crash issue which affected some systems is fixed
It is fixed in libXft 2.3.6:
https://gitlab.freedesktop.org/xorg/lib/libxft/-/blob/libXft-2.3.5/NEWS
Tom Schwindl [Thu, 18 Aug 2022 14:55:19 +0000 (14:55 +0000)]
st: use `void' to indicate an empty parameter list
Hiltjo Posthuma [Sun, 1 May 2022 16:38:40 +0000 (18:38 +0200)]
Makefile: add manual path for OpenBSD
NRK [Fri, 7 Jan 2022 17:21:04 +0000 (23:21 +0600)]
code-golfing: cleanup osc color related code
* adds missing function prototype
* move xgetcolor() prototype to win.h (that's where all the other x.c
func prototype seems to be declared at)
* check for snprintf error/truncation
* reduces code duplication for osc 10/11/12
* unify osc_color_response() and osc4_color_response() into a single function
the latter two was suggested by Quentin Rameau in his patch review on
the hackers list.
NRK [Fri, 18 Mar 2022 11:03:34 +0000 (17:03 +0600)]
base64_digits: reduce scope, implicit zero, +1 size
the array is not accessed outside of base64dec() so it makes sense to
limit it's scope to the related function. the static-storage duration of
the array is kept intact.
this also removes unnecessary explicit zeroing from the start and end of
the array. anything that wasn't explicitly zero-ed will now be
implicitly zero-ed instead.
the validity of the new array can be easily confirmed via running this
trivial loop:
for (int i = 0; i < 255; ++i)
assert(base64_digits[i] == base64_digits_old[i]);
lastly, as pointed out by Roberto, the array needs to have 256 elements
in order to able access it as any unsigned char as an index; the
previous array had 255.
however, this array will only be accessed at indexes which are
isprint() || '=' (see `base64dec_getc()`), so reducing the size of the
array to the highest printable ascii char (127 AFAIK) + 1 might also be
a valid strategy.
NRK [Fri, 18 Mar 2022 10:20:54 +0000 (16:20 +0600)]
avoid potential UB when using isprint()
all the ctype.h functions' argument must be representable as an unsigned
char or as EOF, otherwise the behavior is undefined.
Zacchary Dempsey-Plante [Sun, 13 Mar 2022 09:44:08 +0000 (10:44 +0100)]
make underlines and strikethroughs respect `chscale`
Santtu Lakkala [Thu, 17 Feb 2022 14:00:47 +0000 (16:00 +0200)]
Delay redrawals on palette changes
Build on auto-sync and only mark window dirty on palette changes and let
the event handler do the actual draw.
Hiltjo Posthuma [Wed, 12 Jan 2022 08:44:27 +0000 (09:44 +0100)]
X10/SGR mouse: use alt as meta key instead of super/windows key
Hiltjo Posthuma [Mon, 10 Jan 2022 16:11:17 +0000 (17:11 +0100)]
LICENSE: bump year
robert [Sat, 8 Jan 2022 19:40:34 +0000 (11:40 -0800)]
Fix mousereport
This patch replaces the previous one I sent.
The following changes are made in this patch:
- Fix tracking of pressed buttons. Previously, pressing two buttons and
then releasing one would make st think no buttons are pressed, which
in particular broke MODE_MOUSEMOTION.
- Always send the lowest-numbered pressed button on motion events; when
no button is pressed for a motion event in MODE_MOUSEMANY, then send
a release. This matches the behaviour of xterm. (Previously, st sent
the most recently pressed button in the motion report.)
- Remove UB (?) access to potentially inactive struct member
e->xbutton.button of XEvent union.
- Fix (unlikely) possibility of overflow for large button numbers.
The one discrepancy I found between st and xterm is that xterm sometimes
encodes buttons with large numbers (>5) strangely. E.g., xterm reports
presses of buttons 8 and 9 as releases, whereas st properly (?) encodes
them as presses.
Hiltjo Posthuma [Fri, 7 Jan 2022 11:39:57 +0000 (12:39 +0100)]
bump version to 0.8.5
Hiltjo Posthuma [Sun, 2 Jan 2022 11:15:45 +0000 (12:15 +0100)]
FAQ: fix a typo, patch -> path
jamin [Wed, 29 Dec 2021 17:07:17 +0000 (09:07 -0800)]
Fix overtyping wide characters.
Overtyping the first half of a wide character with the
second half of a wide character results in display garbage.
This is because the trailing dummy is not cleaned up.
i.e. ATTR_WIDE, ATTR_WDUMMY, ATTR_WDUMMY
Here is a short script for demonstrating the behavior:
#!/bin/sh
alias printf=/usr/bin/printf
printf こんにちは!; sleep 2
printf '\x1b[5D'; sleep 2
printf へ; sleep 2
printf ' '; sleep 2
echo
Jochen Sprickerhof [Mon, 27 Dec 2021 10:41:42 +0000 (11:41 +0100)]
Fix null pointer access in strhandle
According to the spec the argument is optional for 104, so p can be
NULL as can be tested with printf '\x1b]104\x07'. This is a regression
of
8e31030.
Hiltjo Posthuma [Sun, 26 Dec 2021 18:00:41 +0000 (19:00 +0100)]
follow-up fix for OSC color sequences, return
Otherwise the message "erresc: unknown str" is printed.
Raheman Vaiya [Sun, 26 Dec 2021 17:57:04 +0000 (18:57 +0100)]
Add support for OSC color sequences
Hiltjo Posthuma [Tue, 24 Aug 2021 11:44:35 +0000 (13:44 +0200)]
fix possible rare crash when Xutf8TextPropertyToTextList fails
from the XmbTextListToTextProperty(3) man page:
"If insufficient memory is available for the new value string, the functions
return XNoMemory. If the current locale is not supported, the functions return
XLocaleNotSupported. In both of these error cases, the functions do not set
text_prop_return."
Reported by Steffen Nurpmeso <steffen@sdaoden.eu>, thanks!
Koichi Murase [Mon, 23 Aug 2021 21:25:05 +0000 (06:25 +0900)]
fix a problem that the standard streams are unexpectedly closed
In the current implementation, the slave PTY (assigned to the variable
`s') is always closed after duplicating it to file descriptors of
standard streams (0, 1, and 2). However, when the allocated slave PTY
`s' is already one of 0, 1, or 2, this causes unexpected closing of a
standard stream. The same problem occurs when the file descriptor of
the master PTY (the variable `m') is one of 0, 1, or 2.
In this patch, the original master PTY (m) is closed before it would
be overwritten by duplicated slave PTYs. The original slave PTY (s)
is closed only when it is not one of the stanrad streams.
Petar Kapriš [Sat, 17 Jul 2021 22:14:00 +0000 (00:14 +0200)]
Add 14th bit to XK_SWITCH_MOD bitmask
The bits of uint signal in an XKeyEvent which concern the key group (keyboard
layout) are bits 13 and 14, as documented here:
https://www.x.org/releases/X11R7.7/doc/libX11/XKB/xkblib.html#Groups_and_Shift_Levels
In the older version, only bit 13 was marked as part of XK_SWITCH_MOD, this
causes issues for users who have more than two keymaps. the 14th bit is not
in ignoremod, key sequences are not caught by match(), if they switch to a third
or fourth keyboard.
Markus F.X.J. Oberhumer [Sun, 28 Mar 2021 19:16:59 +0000 (21:16 +0200)]
Mild const-correctness improvements.
Only touch a few things, the main focus is to
improve code readability.
Hiltjo Posthuma [Fri, 19 Mar 2021 10:54:36 +0000 (11:54 +0100)]
fix: correctly encode mouse buttons >= 8 in X10 and SGR mode
These are typically mapped in X11 to the side-buttons (backward/forwards) on
the mouse. A comparison of the button numbers in SGR mode (first field):
st old:
0 1 2 64 65 66 67 68 69 70
st new (it is the same as xterm now):
0 1 2 64 65 66 67 128 129 130
A script to test and reproduce it, first argument is "h" (on) or "l" (off):
#!/bin/sh
printf '\x1b[?1000%s\x1b[?1006%s' "$1" "$1"
for n in 1 2 3 4 5 6 7 8 9 10; do
printf 'button %d\n' "$n"
xdotool click "$n"
printf '\n\n'
done
Hiltjo Posthuma [Sun, 18 Oct 2020 09:18:03 +0000 (11:18 +0200)]
remove unused variable from previous patch
John Collis [Sun, 6 Sep 2020 05:53:41 +0000 (17:53 +1200)]
ST: Add WM_ICON_NAME property support
Also added _NET_WM_ICON_NAME.
Hiltjo Posthuma [Fri, 19 Jun 2020 09:27:17 +0000 (11:27 +0200)]
bump version to 0.8.4
Hiltjo Posthuma [Wed, 17 Jun 2020 21:47:00 +0000 (23:47 +0200)]
config.mk: use PKG_CONFIG in commented OpenBSD section
Hiltjo Posthuma [Wed, 17 Jun 2020 21:44:34 +0000 (23:44 +0200)]
LICENSE: bump years
Hiltjo Posthuma [Wed, 17 Jun 2020 20:05:48 +0000 (22:05 +0200)]
remove sixel stub code
Remove stub code that was used for an experiment of adding sixel code to st
from the commit
f7398434.
Hiltjo Posthuma [Wed, 17 Jun 2020 19:35:39 +0000 (21:35 +0200)]
fix unicode glitch in DCS strings, patch by Tim Allen
Reported on the mailinglist:
"
I discovered recently that if an application running inside st tries to
send a DCS string, subsequent Unicode characters get messed up. For
example, consider the following test-case:
printf '\303\277\033P\033\\\303\277'
...where:
- \303\277 is the UTF-8 encoding of U+00FF LATIN SMALL LETTER Y WITH
DIAERESIS (ÿ).
- \033P is ESC P, the token that begins a DCS string.
- \033\\ is ESC \, a token that ends a DCS string.
- \303\277 is the same ÿ character again.
If I run the above command in a VTE-based terminal, or xterm, or
QTerminal, or pterm (PuTTY), I get the output:
ÿÿ
...which is to say, the empty DCS string is ignored. However, if I run
that command inside st (as of commit
9ba7ecf), I get:
ÿÿ
...where those last two characters are \303\277 interpreted as ISO8859-1
characters, instead of UTF-8.
I spent some time tracing through the state machines in st.c, and so far
as I can tell, this is how it works currently:
- ESC P sets the "ESC_DCS" and "ESC_STR" flags, indicating that
incoming bytes should be collected into the strescseq buffer, rather
than being interpreted.
- ESC \ sets the "ESC_STR_END" flag (when ESC is received), and then
calls strhandle() (when \ is received) to interpret the collected
bytes.
- If the collected bytes begin with 'P' (i.e. if this was a DCS
string) strhandle() sets the "ESC_DCS" flag again, confusing the
state machine.
If my understanding is correct, fixing the problem should be as easy as
removing the line that sets ESC_DCS from strhandle():
diff --git a/st.c b/st.c
index
ef8abd5..
b5b805a 100644
--- a/st.c
+++ b/st.c
@@ -1897,7 +1897,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;
I've tried the above patch and it fixes my problem, but I don't know if
it introduces any others.
"
Hiltjo Posthuma [Mon, 1 Jun 2020 12:09:46 +0000 (14:09 +0200)]
FAQ: fix single-buffer patch
rebase against master
Hiltjo Posthuma [Sat, 30 May 2020 19:56:18 +0000 (21:56 +0200)]
config.def.h: add an option allowwindowops, by default off (secure)
Similar to the xterm AllowWindowOps option, this is an option to allow or
disallow certain (non-interactive) operations that can be insecure or
exploited.
NOTE: xsettitle() is not guarded by this because st does not support printing
the window title. Else this could be exploitable (arbitrary code execution).
Similar problems have been found in the past in other terminal emulators.
The sequence for base64-encoded clipboard copy is now guarded because it allows
a sequence written to the terminal to manipulate the clipboard of the running
user non-interactively, for example:
printf '\x1b]52;0;ZWNobyBoaQ0=\a'
Hiltjo Posthuma [Sat, 30 May 2020 19:50:54 +0000 (21:50 +0200)]
FAQ: add some details about the w3m img hack
... and an example patch to switch from double-buffering to a single buffer.
Hiltjo Posthuma [Sat, 30 May 2020 19:39:49 +0000 (21:39 +0200)]
tiny style fix
Hiltjo Posthuma [Sat, 30 May 2020 19:34:57 +0000 (21:34 +0200)]
Partially add back in "support REP (repeat) escape sequence"
Add the functionality back in for xterm compatibility, but do not expose the
capability in st.info (yet).
Some notes:
It was reverted because it caused some issues with ncurses in some
configurations, namely when using BSD padding (--enable-bsdpad, BSD_TPUTS) in
ncurses it caused issues with repeating digits.
A fix has been upstreamed in ncurses since snapshot
20200523. The fix is also
backported to OpenBSD -current.
Steve Ward [Thu, 21 May 2020 02:24:55 +0000 (22:24 -0400)]
Call xsetcursor to set win.cursor in main
In xsetcursor, remove "DEFAULT(cursor, 1)" because 0 is a valid value.
Increase max allowed value of cursor from 6 to 7 (st extension).
Hiltjo Posthuma [Sat, 16 May 2020 16:06:42 +0000 (18:06 +0200)]
Revert "support REP (repeat) escape sequence"
This reverts commit
e8392b282c2eaa28725241a9612804fb55113da4.
There is currently a bug in older ncurses versions (like on OpenBSD) where a
fix for a bug with REP is not backported yet. Most likely in tty/tty_update.c:
Noticed while using lynx (which uses ncurses/curses).
To reproduce using lynx: echo "Z0000000" | lynx -stdin
or using the program:
int
main(void)
{
WINDOW *win;
win = initscr();
printw("Z0000000");
refresh();
sleep(5);
return 0;
}
This prints "ZZZZZZZ" (incorrectly).
Avi Halachmi (:avih) [Thu, 14 May 2020 15:18:07 +0000 (18:18 +0300)]
support REP (repeat) escape sequence
The sequence \e[Nb prints the last printed char N (more) times if it's
printable, and it's ignored after newline or other control chars.
This is Ecma-048/ANSI-X3.6 sequence and not DEC VT. It's supported by
xterm, and ncurses uses it when possible, e.g. when TERM is xterm* (and
with this commit also st*).
xterm supports only codepoints<=255, possibly due to internal limits.
We support any value/codepoint which was placed in a cell.
To test:
- tput rep 65 4 -> prints 'AAAA'
- printf "\342\225\246\033[4b" -> prints U+2566 1+4 times.
Roberto E. Vargas [Sat, 16 May 2020 10:42:51 +0000 (10:42 +0000)]
Add rin terminfo capability
Tianlin Qu discovered that st is missing rin (scroll back #1 lines).
k0ga [Sat, 16 May 2020 09:48:18 +0000 (09:48 +0000)]
Make shift+wheel behaves as shift+Prev/Next
St uses a very good hack where mouse wheel genereates ^Y and ^E,
that are the same keys that less and vi uses for backward and
fordward scrolling. Scroll, as many terminal emulators, use
shift+Prev/Next for scrolling, but it is also using ^E and ^Y
for scroling, characters that are reserved in the POSIX shell
in emacs mode for end of line and yanking, making scroll unsable
in st.
This patch adds a new hack, making shift+wheel returning the
same sequences than shift+Prev/Next, meaning that scroll or
any other similar program will not be able to differentiate
between them.
Jakub Leszczak [Wed, 6 May 2020 11:36:59 +0000 (13:36 +0200)]
Fix selection: selscroll
Jakub Leszczak [Wed, 6 May 2020 11:35:53 +0000 (13:35 +0200)]
Fix selection: ignore ATTR_WRAP when rectangular selection in getsel
Jakub Leszczak [Wed, 6 May 2020 11:35:06 +0000 (13:35 +0200)]
Fix selection: selclear in tputc
Hiltjo Posthuma [Sat, 9 May 2020 12:43:31 +0000 (14:43 +0200)]
code-style: add fallthrough comment
Patch by Steve Ward, thanks.
Hiltjo Posthuma [Sat, 9 May 2020 12:03:14 +0000 (14:03 +0200)]
optimize column width calculation and utf-8 encode for ASCII
In particular on OpenBSD and on glibc wcwidth() is quite expensive.
On musl there is little difference.
Hiltjo Posthuma [Sat, 9 May 2020 11:56:28 +0000 (13:56 +0200)]
fix for incorrect (partial) written sequences when libc wcwidth() == -1
Fix an issue with incorrect (partial) written sequences when libc wcwidth() ==
-1. The sequence is updated to on wcwidth(u) == -1:
c = "\357\277\275"
but len isn't.
A way to reproduce in practise:
* st -o dump.txt
* In the terminal: printf '\xcd\xb8'
- This is codepoint 888, on OpenBSD it reports wcwidth() == -1.
- Quit the terminal.
- Look in dump.txt (partial written sequence of "UTF_INVALID").
This was introduced in:
" commit
11625c7166b7e4dad414606227acec2de1c36464
Author: czarkoff@gmail.com <czarkoff@gmail.com>
Date: Tue Oct 28 12:55:28 2014 +0100
Replace character with U+FFFD if wcwidth() is -1
Helpful when new Unicode codepoints are not recognized by libc."
Change:
Remove setting the sequence. If this happens to break something, another
solution could be setting len = 3 for the sequence.
Hiltjo Posthuma [Sat, 9 May 2020 11:55:34 +0000 (13:55 +0200)]
tiny code-style and typo-fix in comment
Avi Halachmi (:avih) [Tue, 26 Feb 2019 20:37:49 +0000 (22:37 +0200)]
auto-sync: draw on idle to avoid flicker/tearing
st could easily tear/flicker with animation or other unattended
output. This commit eliminates most of the tear/flicker.
Before this commit, the display timing had two "modes":
- Interactively, st was waiting fixed `1000/xfps` ms after forwarding
the kb/mouse event to the application and before drawing.
- Unattended, and specifically with animations, the draw frequency was
throttled to `actionfps`. Animation at a higher rate would throttle
and likely tear, and at lower rates it was tearing big frames
(specifically, when one `read` didn't get a full "frame").
The interactive behavior was decent, but it was impossible to get good
unattended-draw behavior even with carefully chosen configuration.
This commit changes the behavior such that it draws on idle instead of
using fixed latency/frequency. This means that it tries to draw only
when it's very likely that the application has completed its output
(or after some duration without idle), so it mostly succeeds to avoid
tear, flicker, and partial drawing.
The config values minlatency/maxlatency replace xfps/actionfps and
define the range which the algorithm is allowed to wait from the
initial draw-trigger until the actual draw. The range enables the
flexibility to choose when to draw - when least likely to flicker.
It also unifies the interactive and unattended behavior and config
values, which makes the code simpler as well - without sacrificing
latency during interactive use, because typically interactively idle
arrives very quickly, so the wait is typically minlatency.
While it only slighly improves interactive behavior, for animations
and other unattended-drawing it improves greatly, as it effectively
adapts to any [animation] output rate without tearing, throttling,
redundant drawing, or unnecessary delays (sounds impossible, but it
works).
Jan Klemkow [Wed, 29 Apr 2020 22:10:02 +0000 (00:10 +0200)]
replace exit(3) by _exit(2) in signal handler sigchld()
exit(3) is not async-signal-safe but, _exit(2) is.
This change prevents st to crash and dump core.
Hiltjo Posthuma [Mon, 27 Apr 2020 11:56:25 +0000 (13:56 +0200)]
bump version to 0.8.3
Ivan Tham [Sun, 19 Apr 2020 17:38:39 +0000 (19:38 +0200)]
Update XIM cursor position only if changed
Updating XIM cursor position is expensive, so only update it when cursor
position changed.
Hiltjo Posthuma [Sat, 11 Apr 2020 13:45:06 +0000 (15:45 +0200)]
just remove the EOF message
Roberto E. Vargas Caballero [Sat, 11 Apr 2020 12:46:17 +0000 (14:46 +0200)]
Add st-mono terminfo entry
This entry is intended for monocolor display and it is very
helpful for color haters.
Hiltjo Posthuma [Sat, 11 Apr 2020 11:56:31 +0000 (13:56 +0200)]
config.def.h: add a comment for the scroll variable
Hiltjo Posthuma [Sat, 11 Apr 2020 11:29:48 +0000 (13:29 +0200)]
Fix small typos
Quentin Rameau [Sat, 11 Apr 2020 10:09:20 +0000 (12:09 +0200)]
Launch scroll program with the default shell
Roberto E. Vargas Caballero [Sat, 11 Apr 2020 09:52:58 +0000 (11:52 +0200)]
Update FAQ with the last modifications
Roberto E. Vargas Caballero [Fri, 10 Apr 2020 20:50:23 +0000 (22:50 +0200)]
Add terminfo entries for backspace mode
St used to use backspace as BS until the commit
230d0c8, but due
to general lack of knowledge of lusers, we moved to the most common
configuration in linux to avoid answering the same question 3 times
per month. With the most common configuration we have a backspace
that returns a DEL, and we have a Delete key that doesn't return a
DEL character neither a BS.
When dealing with devices connected using a serial line (or even
with Plan9) it is more common Backspace as BS and Delete as DEL. For
this reason, st is not always the best tool when you talk with a
serial device.
This patch adds new terminfo entries for Backspace as BS and Delete
as DEL. A patch for confg.h is also added, to make easier switch
between both configurations.
Roberto E. Vargas Caballero [Fri, 10 Apr 2020 20:26:12 +0000 (22:26 +0200)]
Fix style issue
Roberto E. Vargas Caballero [Fri, 10 Apr 2020 20:25:46 +0000 (22:25 +0200)]
ttyread: test for EOF while reading tty
When a read operation returns 0 then it means that we arrived to the end of the
file, and new reads will return 0 unless you do some other operation such as
lseek(). This case happens with USB-232 adapters when they are unplugged.
Roberto E. Vargas Caballero [Fri, 10 Apr 2020 20:06:32 +0000 (22:06 +0200)]
Add support for scroll(1)
Scroll is a program that stores all the lines of its child and be used in st as
a way of implementing scrollback.
This solution is much better than implementing the scrollback in st itself
because having a different program allows to use it in any other program
without doing modifications to those programs.
Hiltjo Posthuma [Fri, 10 Apr 2020 10:12:43 +0000 (12:12 +0200)]
make argv0 not static, fixes a warning with tcc
Reported by Aajonus, thanks!
Avi Halachmi (:avih) [Thu, 2 Apr 2020 08:43:22 +0000 (11:43 +0300)]
mouseshortcuts: fix custom modifier on release
This line didn't work at mshortcuts at config.h:
/* mask button function arg release */
{ ShiftMask, Button2, selpaste, {.i = 0}, 1 },
and now it does work.
The issue was that XButtonEvent.state is "the logical state ... just prior
to the event", which means that on release the state has the Button2Mask
bit set because button2 was down just before it was released.
The issue didn't manifest with the default shift + middle-click on release
(to override mouse mode) because its specified modifier is XK_ANY_MOD, at
which case match(...) ignores any specific bits and simply returns true.
The issue also doesn't manifest on press, because prior to the event
Button<N> was not down and its mask bit is not set.
Fix by filtering out the mask of the button which we're currently matching.
We could have said "well, that's how button events behave, you should
use ShiftMask|Button2Mask for release", but this both not obvious to
figure out, and specifically here always filtering does not prevent
configuring any useful modifiers combination. So it's a win-win.
Ivan Tham [Tue, 18 Feb 2020 15:28:47 +0000 (23:28 +0800)]
Remove explicit XNFocusWindow
XCreateIC ICValues default XNFocusWindow to XNClientWindow if not
specified, it can be omitted since it is the same.
From the documentation
https://www.x.org/releases/current/doc/libX11/libX11/libX11.html
> Focus Window
>
> The XNFocusWindow argument specifies the focus window. The primary
> purpose of the XNFocusWindow is to identify the window that will receive
> the key event when input is composed.
>
> When this XIC value is left unspecified, the input method will use the
> client window as the default focus window.
Quentin Rameau [Sun, 2 Feb 2020 20:47:19 +0000 (21:47 +0100)]
x: fix XIM handling
Do not try to set specific IM method, let the user specify it with
XMODIFIERS.
If the requested method is not available or opening fails, fallback to
the default input handler and register a handler on the new IM server
availability signal.
Do the same when the input server is closed and (re)started.
Quentin Rameau [Sun, 2 Feb 2020 16:38:36 +0000 (17:38 +0100)]
x: check we still have an XIC context before accessing it
Quentin Rameau [Sun, 2 Feb 2020 14:38:08 +0000 (15:38 +0100)]
x: do not instantiate a new nested list on each cursor move