]> git.armaanb.net Git - st.git/log
st.git
2 years agoSwitch to zenburn theme master
Armaan Bhojwani [Thu, 15 Jul 2021 20:25:42 +0000 (16:25 -0400)]
Switch to zenburn theme

2 years agoApply blinking-cursor patch
Armaan Bhojwani [Tue, 29 Jun 2021 16:14:14 +0000 (12:14 -0400)]
Apply blinking-cursor patch

2 years agoRemove config.def.h
Armaan Bhojwani [Mon, 28 Jun 2021 14:59:26 +0000 (10:59 -0400)]
Remove config.def.h

2 years agoReduce font size
Armaan Bhojwani [Fri, 18 Jun 2021 21:42:11 +0000 (17:42 -0400)]
Reduce font size

2 years agoUse Modus Operandi colors
Armaan Bhojwani [Thu, 20 May 2021 01:20:56 +0000 (21:20 -0400)]
Use Modus Operandi colors

Also don't commit config.h

2 years agoUpdate copyurl keybinding
Armaan Bhojwani [Mon, 17 May 2021 23:54:28 +0000 (19:54 -0400)]
Update copyurl keybinding

2 years agoApply copyurl patch
Armaan Bhojwani [Mon, 17 May 2021 23:49:12 +0000 (19:49 -0400)]
Apply copyurl patch

2 years agoIncrease font size
Armaan Bhojwani [Mon, 17 May 2021 02:39:42 +0000 (22:39 -0400)]
Increase font size

2 years agoApply ligatures patch
Armaan Bhojwani [Mon, 17 May 2021 02:39:14 +0000 (22:39 -0400)]
Apply ligatures patch

2 years agoAdd gitignore
Armaan Bhojwani [Mon, 17 May 2021 02:38:49 +0000 (22:38 -0400)]
Add gitignore

2 years agoMild const-correctness improvements.
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.

3 years agofix: correctly encode mouse buttons >= 8 in X10 and SGR mode
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

3 years agoremove unused variable from previous patch
Hiltjo Posthuma [Sun, 18 Oct 2020 09:18:03 +0000 (11:18 +0200)]
remove unused variable from previous patch

3 years agoST: Add WM_ICON_NAME property support
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.

3 years agobump version to 0.8.4
Hiltjo Posthuma [Fri, 19 Jun 2020 09:27:17 +0000 (11:27 +0200)]
bump version to 0.8.4

3 years agoconfig.mk: use PKG_CONFIG in commented OpenBSD section
Hiltjo Posthuma [Wed, 17 Jun 2020 21:47:00 +0000 (23:47 +0200)]
config.mk: use PKG_CONFIG in commented OpenBSD section

3 years agoLICENSE: bump years
Hiltjo Posthuma [Wed, 17 Jun 2020 21:44:34 +0000 (23:44 +0200)]
LICENSE: bump years

3 years agoremove sixel stub code
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.

3 years agofix unicode glitch in DCS strings, patch by Tim Allen
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.
"

3 years agoFAQ: fix single-buffer patch
Hiltjo Posthuma [Mon, 1 Jun 2020 12:09:46 +0000 (14:09 +0200)]
FAQ: fix single-buffer patch

rebase against master

3 years agoconfig.def.h: add an option allowwindowops, by default off (secure)
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'

3 years agoFAQ: add some details about the w3m img hack
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.

3 years agotiny style fix
Hiltjo Posthuma [Sat, 30 May 2020 19:39:49 +0000 (21:39 +0200)]
tiny style fix

3 years agoPartially add back in "support REP (repeat) escape sequence"
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.

3 years agoCall xsetcursor to set win.cursor in main
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).

3 years agoRevert "support REP (repeat) escape sequence"
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).

3 years agosupport REP (repeat) escape sequence
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.

3 years agoAdd rin terminfo capability
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).

3 years agoMake shift+wheel behaves as shift+Prev/Next
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.

3 years agoFix selection: selscroll
Jakub Leszczak [Wed, 6 May 2020 11:36:59 +0000 (13:36 +0200)]
Fix selection: selscroll

3 years agoFix selection: ignore ATTR_WRAP when rectangular selection in getsel
Jakub Leszczak [Wed, 6 May 2020 11:35:53 +0000 (13:35 +0200)]
Fix selection: ignore ATTR_WRAP when rectangular selection in getsel

3 years agoFix selection: selclear in tputc
Jakub Leszczak [Wed, 6 May 2020 11:35:06 +0000 (13:35 +0200)]
Fix selection: selclear in tputc

3 years agocode-style: add fallthrough comment
Hiltjo Posthuma [Sat, 9 May 2020 12:43:31 +0000 (14:43 +0200)]
code-style: add fallthrough comment

Patch by Steve Ward, thanks.

3 years agooptimize column width calculation and utf-8 encode for ASCII
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.

3 years agofix for incorrect (partial) written sequences when libc wcwidth() == -1
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.

3 years agotiny code-style and typo-fix in comment
Hiltjo Posthuma [Sat, 9 May 2020 11:55:34 +0000 (13:55 +0200)]
tiny code-style and typo-fix in comment

3 years agoauto-sync: draw on idle to avoid flicker/tearing
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).

3 years agoreplace exit(3) by _exit(2) in signal handler sigchld()
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.

3 years agobump version to 0.8.3
Hiltjo Posthuma [Mon, 27 Apr 2020 11:56:25 +0000 (13:56 +0200)]
bump version to 0.8.3

4 years agoUpdate XIM cursor position only if changed
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.

4 years agojust remove the EOF message
Hiltjo Posthuma [Sat, 11 Apr 2020 13:45:06 +0000 (15:45 +0200)]
just remove the EOF message

4 years agoAdd st-mono terminfo entry
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.

4 years agoconfig.def.h: add a comment for the scroll variable
Hiltjo Posthuma [Sat, 11 Apr 2020 11:56:31 +0000 (13:56 +0200)]
config.def.h: add a comment for the scroll variable

4 years agoFix small typos
Hiltjo Posthuma [Sat, 11 Apr 2020 11:29:48 +0000 (13:29 +0200)]
Fix small typos

4 years agoLaunch scroll program with the default shell
Quentin Rameau [Sat, 11 Apr 2020 10:09:20 +0000 (12:09 +0200)]
Launch scroll program with the default shell

4 years agoUpdate FAQ with the last modifications
Roberto E. Vargas Caballero [Sat, 11 Apr 2020 09:52:58 +0000 (11:52 +0200)]
Update FAQ with the last modifications

4 years agoAdd terminfo entries for backspace mode
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.

4 years agoFix style issue
Roberto E. Vargas Caballero [Fri, 10 Apr 2020 20:26:12 +0000 (22:26 +0200)]
Fix style issue

4 years agottyread: test for EOF while reading tty
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.

4 years agoAdd support for scroll(1)
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.

4 years agomake argv0 not static, fixes a warning with tcc
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!

4 years agomouseshortcuts: fix custom modifier on release
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.

4 years agoRemove explicit XNFocusWindow
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.

4 years agox: fix XIM handling
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.

4 years agox: check we still have an XIC context before accessing it
Quentin Rameau [Sun, 2 Feb 2020 16:38:36 +0000 (17:38 +0100)]
x: check we still have an XIC context before accessing it

4 years agox: do not instantiate a new nested list on each cursor move
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

4 years agox: move IME variables into XWindow ime embedded struct
Quentin Rameau [Sun, 2 Feb 2020 14:37:29 +0000 (15:37 +0100)]
x: move IME variables into XWindow ime embedded struct

4 years agoIncrease XmbLookupString buffer
Ivan Tham [Sat, 18 Jan 2020 07:52:25 +0000 (15:52 +0800)]
Increase XmbLookupString buffer

Current buffer is too short to input medium to long sentences from IME.
Input with longer text will show the wrong input, taking 64 instead of
32 bytes should be enough for most of the cases. Broken cases before,

Chinese (taken from song 也可以)
可不可以轻轻的松开自己

Japanese (taken from bootleggers rom quote)
あなたは家のように感じる

4 years agoupdate FAQ
Hiltjo Posthuma [Sun, 17 Nov 2019 19:04:52 +0000 (20:04 +0100)]
update FAQ

- add common question about the w3m image drawing hack.
- remove some bad advise about $TERM.
- change some links to https.

4 years agoOSC 52 - copy to clipboard: don't limit to 382 bytes
Avi Halachmi (:avih) [Wed, 16 Oct 2019 09:55:53 +0000 (12:55 +0300)]
OSC 52 - copy to clipboard: don't limit to 382 bytes

Strings which an application sends to the terminal in OSC, DCS, etc
are typically small (title, colors, etc) but one exception is OSC 52
which copies text to the clipboard, and is used for instance by tmux.

Previously st cropped these strings at 512 bytes, which for OSC 52
limited the copied text to 382 bytes (remaining buffer space before
base64). This made it less useful than it can be.

Now it's a dynamic growing buffer. It remains allocated after use,
resets to 512 when a new string starts, or leaked on exit.

Resetting/deallocating the buffer right after use (at strhandle) is
possible with some more code, however, it doesn't always end up used,
and to cover those cases too will require even more code, so resetting
only on new string is good enough for now.

4 years agoCSIEscape, STREscape: use size_t for buffer length
Hiltjo Posthuma [Wed, 16 Oct 2019 09:38:43 +0000 (12:38 +0300)]
CSIEscape, STREscape: use size_t for buffer length

4 years agoSTREscape: don't trim prematurely
Avi Halachmi (:avih) [Wed, 16 Oct 2019 09:19:49 +0000 (12:19 +0300)]
STREscape: don't trim prematurely

STRescape holds strings in escape sequences such as OSC and DCS, and
its buffer is 512 bytes.

If the input is too big then trailing chars are ignored, but the test
was off-by-1 such that it took 510 chars instead of 511 (before a
terminating NULL is added).

Now the full size can be utilized.

4 years agobase64dec: don't read out of bounds
Avi Halachmi (:avih) [Wed, 16 Oct 2019 08:17:23 +0000 (11:17 +0300)]
base64dec: don't read out of bounds

Previously, base64dec checked terminating input '\0' every 4 calls to
base64dec_getc, where the latter progressed one or more chars on each
call, and could read past '\0' in the way it was used.

The input to base64dec currently comes only from OSC 52 escape seq
(copy to clipboard), and reading past '\0' or even past the buffer
boundary was easy to trigger.

Also, even if we could trust external input to be valid base64, there
are different base64 standards, and not all of them require padding
to 4 bytes blocks (using trailing '=' chars).

It didn't affect short OSC 52 strings because the buffer is initialized
to 0's, so typically it did stop within the buffer, but if the string
was trimmed to fit (the buffer is 512 bytes) then it did also read past
the end of the buffer, and the decoded suffix ended up arbitrary.

This patch makes base64dec_getc not progress past '\0', and instead
produce fake trailing padding of '='.

Additionally, at base64dec, if padding is detected at the first or
second byte of a quartet, then we identify it as invalid and abort
(a valid quartet has at least two leading non-padding bytes).

4 years agoFix tmux terminfo extensions Se and Ss
Sebastian J. Bronner [Tue, 5 Nov 2019 17:16:39 +0000 (18:16 +0100)]
Fix tmux terminfo extensions Se and Ss

The tmux terminfo extensions Ss and Se are currently specified as
booleans in `st.info`. They should be strings. See
https://github.com/tmux/tmux/blob/eeedb43ae847a0a692ceea965f7556e84bca4fd0/tty-term.c
lines 254 and 265.

I have used the values from
https://invisible-island.net/ncurses/terminfo.src.html#toc-_S_I_M_P_L_E_T_E_R_M
for this patch.

4 years agoapply hints before initial mapping (ICCCM)
Ingo Lohmar [Fri, 31 May 2019 20:25:35 +0000 (22:25 +0200)]
apply hints before initial mapping (ICCCM)

For WM_CLASS this is mentioned in the ICCCM docs
https://tronche.com/gui/x/icccm/sec-4.html#s-4.1.2.5
(third sentence).

When changing the WM_CLASS from the command line, this is necessary for
window managers to pick it up before applying class-based rules.

4 years agomouse shortcuts: allow using forcemousemod (e.g. shift)
Avi Halachmi (:avih) [Thu, 24 Oct 2019 12:42:07 +0000 (15:42 +0300)]
mouse shortcuts: allow using forcemousemod (e.g. shift)

The recent mouse shurtcuts commits allow customization, but ignore
forcemousemod mask (default: shift) as a modifier, for no good reason
other than following the behavior of the KB shortcuts.

Allow using forcemousemod too, which now can be used to invoke
different shortcuts, though the automatic effect of forcemousemod will
be lost for buttons which use mask with forcemousemod.

E.g. the default is:

static uint forcemousemod = ShiftMask;
...
{ XK_ANY_MOD,           Button4, ttysend,        {.s = "\031"} },
...

where ttysend will be invoked for button4 with any mod when not in mouse
mode, and with shift when in mouse mode.

Now it's possible to do this:
{ ShiftMask,            Button4, ttysend,        {.s = "foo"} },
{ XK_ANY_MOD,           Button4, ttysend,        {.s = "\031"} },

Which will invoke ttysend("foo") while shift is held and ttysend("\031")
otherwise. Shift still overrides mouse mode, but will now send "foo".

Previously with this setup the second binding was always invoked
because the forceousemod mask was always removed from the event.

Buttons which don't use forcemousemod behave the same as before.

This is useful e.g. for the scrollback mouse patch, which wants to
configure shift+wheel for scrollback, while keeping the normal behavior
without shift.

4 years agomouse shortcuts: don't hardcode selpaste
Avi Halachmi (:avih) [Thu, 10 Oct 2019 23:26:10 +0000 (02:26 +0300)]
mouse shortcuts: don't hardcode selpaste

Because selpaste is activated on release, a release flag was added to
mouse shortcuts which controls whether activation is on press/release,
and selpaste binding to button2 was moved to config.h .

button1 remains the only hardcoded mouse button - for selection + copy.

4 years agomouse shortcuts: allow override for all shortcuts
Avi Halachmi (:avih) [Thu, 10 Oct 2019 20:42:30 +0000 (23:42 +0300)]
mouse shortcuts: allow override for all shortcuts

Allow forceselmod to override all mouse shortcuts rather than only
selection, and rename it to forcemousemod as it's now more appropriate.

This will affect mouse shortcuts which use mask other than XK_ANY_MOD.

This does not affect the default behavior because the default mouse
shortcuts (wheel) use XK_ANY_MOD, where forceselmod already activated
the override also before this change.

Previously, if a mouse shortcut was configured with a specific mod and
forceselmod was held, then the shortcut did not execute unless the
configured mod included forceselmod.

4 years agomouse shortcuts: allow same functions as kb shortcuts
Avi Halachmi (:avih) [Thu, 10 Oct 2019 20:02:26 +0000 (23:02 +0300)]
mouse shortcuts: allow same functions as kb shortcuts

Previously mouse shortcuts supported only ttywrite.

This required adding an "Arg" function ttysend - which does what the
original mouse shortcuts did.

4 years agoconfig.def.h: remove crlf value section
Hiltjo Posthuma [Mon, 26 Aug 2019 15:58:47 +0000 (17:58 +0200)]
config.def.h: remove crlf value section

this is not used anymore.

patch sent as an ed script using RFC2549 by k0ga.

4 years agoFAQ: add entry about color emoji Xft bug
Hiltjo Posthuma [Fri, 17 May 2019 11:00:10 +0000 (13:00 +0200)]
FAQ: add entry about color emoji Xft bug

This has been asked many times on IRC and the mailinglist. Make it easier to
find information about this particular Xft issue by adding it to the FAQ.

5 years agoselection: fix view to match actual selection on first cell
Avi Halachmi (:avih) [Tue, 9 Apr 2019 22:54:43 +0000 (01:54 +0300)]
selection: fix view to match actual selection on first cell

5 years agorevert part of commit add0211522737b79dad990ccd65c8af63b5cc1dd
Hiltjo Posthuma [Fri, 15 Mar 2019 19:40:16 +0000 (20:40 +0100)]
revert part of commit add0211522737b79dad990ccd65c8af63b5cc1dd

"use iswspace()/iswpunct() to find word delimiters

    this inverts the configuration logic: you no longer provide a list of
    delimiters -- all space and punctuation characters are considered
    delimiters, unless listed in extrawordchars."

Feedback from IRC and personal preference.

5 years agodont print color warning on color reset OSC 104 without parameter
Hiltjo Posthuma [Fri, 15 Mar 2019 13:44:28 +0000 (14:44 +0100)]
dont print color warning on color reset OSC 104 without parameter

also print explicitly "(null)" when printf "%s" p=NULL.

noticed when exiting mutt: printf '\x1b]104\x07'

5 years agominor code-style, initialize var at the top of function
Hiltjo Posthuma [Fri, 15 Mar 2019 13:42:50 +0000 (14:42 +0100)]
minor code-style, initialize var at the top of function

5 years agoconfig.def.h: tweak extra worddelimiters
Hiltjo Posthuma [Fri, 15 Mar 2019 11:31:54 +0000 (12:31 +0100)]
config.def.h: tweak extra worddelimiters

This changes the selection more like xterm.
To test try: "find /" and select a path.

5 years agouse iswspace()/iswpunct() to find word delimiters
Lauri Tirkkonen [Wed, 13 Mar 2019 15:15:04 +0000 (17:15 +0200)]
use iswspace()/iswpunct() to find word delimiters

this inverts the configuration logic: you no longer provide a list of
delimiters -- all space and punctuation characters are considered
delimiters, unless listed in extrawordchars.

5 years agoreplace utf8strchr with wcschr
Lauri Tirkkonen [Wed, 13 Mar 2019 17:40:52 +0000 (19:40 +0200)]
replace utf8strchr with wcschr

5 years agobe silent about explicitly unhandled mouse modes
Lauri Tirkkonen [Wed, 13 Mar 2019 15:08:50 +0000 (17:08 +0200)]
be silent about explicitly unhandled mouse modes

5 years agosimplify (greedy) font caching allocating a bit
Hiltjo Posthuma [Sun, 3 Mar 2019 10:29:43 +0000 (11:29 +0100)]
simplify (greedy) font caching allocating a bit

POSIX says:
"If ptr is a null pointer, realloc() shall be equivalent to malloc() for the
 specified size."

5 years agostyle: remove double empty newlines
Hiltjo Posthuma [Sun, 3 Mar 2019 10:23:54 +0000 (11:23 +0100)]
style: remove double empty newlines

5 years agofix use after free in font caching algorithm
magras [Thu, 28 Feb 2019 01:56:01 +0000 (04:56 +0300)]
fix use after free in font caching algorithm

Current font caching algorithm contains a use after free error. A font
removed from `frc` might be still listed in `wx.specbuf`. It will lead
to a crash inside `XftDrawGlyphFontSpec()`.

Steps to reproduce:
$ st -f 'Misc Tamsyn:scalable=false'
$ curl https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt

Of course, result depends on fonts installed on a system and fontconfig.
In my case, I'm getting consistent segfaults with different fonts.

I replaced a fixed array with a simple unbounded buffer with a constant
growth rate. Cache starts with a capacity of 0, gets increments by 16,
and never shrinks. On my machine after `cat UTF-8-demo.txt` buffer
reaches a capacity of 192. During casual use capacity stays at 0.

5 years agobetter Input Method Editor (IME) support
Ivan Tham [Tue, 12 Feb 2019 17:41:41 +0000 (18:41 +0100)]
better Input Method Editor (IME) support

Features:

- Allow input methods swap with hotkey (E.g. left ctrl + left shift).
- Over-the-spot pre-editing style, pre-edit data placed over insertion point.
- Restart IME without segmentation fault.

TODO:

- Automatically pickup IME if st started before IME

5 years agobump version to 0.8.2
Hiltjo Posthuma [Sat, 9 Feb 2019 11:48:39 +0000 (12:48 +0100)]
bump version to 0.8.2

5 years agoconfig: add Shift+Insert as selpaste() again
Hiltjo Posthuma [Thu, 10 Jan 2019 17:16:17 +0000 (18:16 +0100)]
config: add Shift+Insert as selpaste() again

This was changed before in:
commit 20f713548de451b67db3306cf8cf7b2f38fee05c on Wed Jan 25 19:17:38 2017

5 years agoLet the user specify CPPFLAGS
Paride Legovini [Thu, 10 Jan 2019 12:36:09 +0000 (13:36 +0100)]
Let the user specify CPPFLAGS

This complements the work done in d4928ed, allowing the user to specify
the preprocessor flags with the CPPFLAGS environment variable. This is
useful for example to specify preprocessor macros with -D.

CFLAGS could be used instead, but CPPFLAGS is more correct and is expected
to be honored in some cases. For example, the helper scripts to build
Debian packages make use of CPPFLAGS, but the variable is currently
being ignored unless manually appended to CFLAGS.

5 years agoSet the path of pkg-config in a variable instead of hardcoding it
Paride Legovini [Fri, 4 Jan 2019 08:48:37 +0000 (09:48 +0100)]
Set the path of pkg-config in a variable instead of hardcoding it

In this way the path of pkg-config can be overridden from the command
line. This is useful for example when cross-compiling.

5 years agoMakefile: fix dependencies on config.h
Hiltjo Posthuma [Fri, 4 Jan 2019 11:33:01 +0000 (12:33 +0100)]
Makefile: fix dependencies on config.h

patch by Younes Khoudli (changed slightly). Thanks

5 years agooutput child WEXITSTATUS/WTERMSIG on abnormal termination
Lauri Tirkkonen [Tue, 11 Dec 2018 09:43:03 +0000 (11:43 +0200)]
output child WEXITSTATUS/WTERMSIG on abnormal termination

5 years agofix memory leak in xloadcols()
Hiltjo Posthuma [Sun, 4 Nov 2018 13:35:07 +0000 (14:35 +0100)]
fix memory leak in xloadcols()

reported by Avi Halachmi (:avih)" <avihpit@yahoo.com>

patch slightly changed by me.

5 years agost: small typofix in comment
Hiltjo Posthuma [Sun, 4 Nov 2018 13:30:56 +0000 (14:30 +0100)]
st: small typofix in comment

5 years agosmall code-style fix
Hiltjo Posthuma [Tue, 11 Sep 2018 17:06:35 +0000 (19:06 +0200)]
small code-style fix

5 years agoRemove the ISO 14755 feature
Quentin Rameau [Tue, 11 Sep 2018 11:11:28 +0000 (13:11 +0200)]
Remove the ISO 14755 feature

And move it to the patches section.
Keeping it would force to add an exec pledge on OpenBSD, and some
people think it's bloated, so bye!

5 years agoRevert "Simplify cursor color handling"
Hiltjo Posthuma [Tue, 17 Jul 2018 18:01:58 +0000 (20:01 +0200)]
Revert "Simplify cursor color handling"

This reverts commit 1911c9274d9b03f3d7999c6ce26e2d5169642d26.

5 years agoRevert "Make cursor follow text color"
Hiltjo Posthuma [Tue, 17 Jul 2018 18:01:57 +0000 (20:01 +0200)]
Revert "Make cursor follow text color"

This reverts commit b51bcd5553af3db394014efbd78acf7828fa48ff.

5 years agoRevert "Fix crash when cursor color is truecolor"
Hiltjo Posthuma [Tue, 17 Jul 2018 18:01:54 +0000 (20:01 +0200)]
Revert "Fix crash when cursor color is truecolor"

This reverts commit 5535c1f04c665c05faff2a65d5558246b7748d49.

5 years agoFix crash when cursor color is truecolor
Jules Maselbas [Sun, 15 Jul 2018 11:53:37 +0000 (13:53 +0200)]
Fix crash when cursor color is truecolor

Reported-by: Ivan Tham <pickfire@riseup.net>
5 years agoMake cursor follow text color
Jules Maselbas [Sat, 14 Jul 2018 09:16:37 +0000 (11:16 +0200)]
Make cursor follow text color

5 years agoSimplify cursor color handling
Jules Maselbas [Sat, 14 Jul 2018 09:16:36 +0000 (11:16 +0200)]
Simplify cursor color handling

5 years agoFix crash on resize
Jules Maselbas [Wed, 27 Jun 2018 15:08:30 +0000 (17:08 +0200)]
Fix crash on resize

Prevent to realloc xw.specbuc with a negative number of col.
Add proper hints for the minimal size, for one character.