Compare commits

...

202 Commits

Author SHA1 Message Date
3454623c49
Adding ligature patch
https://st.suckless.org/patches/ligatures/
-> st-ligatures-alpha-scrollback-0.9
2023-12-31 14:12:55 +01:00
aleks
94cd9d4927
Create a desktop-entry for st
Enables to find st in a graphical menu and to display it with a nice
icon.

If some applications still are not displaying an icon for st try the patch
[netwmicon](../netwmicon/). Programs like tint2 and alttab rely on a hardcoded
icon which has to be stored by st in the \_NET\_WM\_ICON window-property.
2023-10-18 15:10:21 +02:00
Benji Encalada Mora
628bd144f8
fix: replace xfps and actionfps variables 2023-06-18 21:30:41 +02:00
Santtu Lakkala
77ce1529ac
Loop through urls on screen and copy to clipboard
Replace url detection heuristics with a DFA, enabling urls that span
multiple lines. Also fix the selection not to use snapping so that urls
are selected exactly.
2023-04-13 00:15:36 +02:00
Debucquoy
5bfe4b3592
dracula theme + bg and fg modification 2023-04-03 17:53:38 +02:00
asparagii
5ad60325b9
st-scrollback-mouse
Signed-off-by: Debucquoy <debucqquoy.anthony@gmail.com>
2023-04-03 16:43:26 +02:00
Debucquoy
62b2a7eb60
ScrollBack patch
This apply shift + pageUp/pageDown to scroll up or down
2023-04-03 16:38:41 +02:00
Kipras Melnikovas
785b3a4666
refactor dynamic-cursor-color patch
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
Signed-off-by: Debucquoy <debucqquoy.anthony@gmail.com>
2023-04-03 15:42:16 +02:00
Bakkeby
74e2cea30d
Adding anysize patch
Signed-off-by: Debucquoy <debucqquoy.anthony@gmail.com>
2023-04-03 14:55:40 +02:00
Debucquoy
010407757e
Adding config.h to gitignore 2023-04-03 14:50:29 +02:00
Debucquoy
840e3a234c
Adding alpha
Also delete config.h because it should only be modified when all patches
are applied.
2023-04-03 14:42:12 +02:00
Debucquoy
8e3a174ce2
first config 2023-04-03 14:27:44 +02:00
Hiltjo Posthuma
211964d56e 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
2023-02-07 20:00:59 +01:00
Adam Price
f17abd25b3 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,
2023-02-07 19:57:34 +01:00
Hiltjo Posthuma
7e8050cc62 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'
2023-02-05 13:29:35 +01:00
Hiltjo Posthuma
e5e959835b 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.
2022-10-25 17:11:11 +02:00
Hiltjo Posthuma
68d1ad9b54 bump version to 0.9 2022-10-04 19:40:30 +02:00
Hiltjo Posthuma
0008519903 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
2022-09-16 23:07:09 +02:00
Tom Schwindl
72fd32736a st: use `void' to indicate an empty parameter list 2022-08-18 17:14:10 +02:00
Hiltjo Posthuma
baa9357e96 Makefile: add manual path for OpenBSD 2022-05-01 18:38:40 +02:00
NRK
8629d9a1da 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.
2022-04-19 11:43:37 +02:00
NRK
ef0551932f 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.
2022-03-18 12:20:27 +01:00
NRK
af3bb68add 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.
2022-03-18 12:11:27 +01:00
Zacchary Dempsey-Plante
2aefa348ba make underlines and strikethroughs respect chscale 2022-03-13 10:45:34 +01:00
Santtu Lakkala
e823e2308f 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.
2022-02-18 13:03:37 +01:00
Hiltjo Posthuma
2c5edf28ec X10/SGR mouse: use alt as meta key instead of super/windows key 2022-01-12 09:44:27 +01:00
Hiltjo Posthuma
b1d97fec47 LICENSE: bump year 2022-01-10 17:11:17 +01:00
robert
ea7cd7b62f 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.
2022-01-10 17:04:01 +01:00
Hiltjo Posthuma
7fb0c0cc68 bump version to 0.8.5 2022-01-07 12:39:57 +01:00
Hiltjo Posthuma
7e1c68f25d FAQ: fix a typo, patch -> path 2022-01-02 12:16:57 +01:00
jamin
65f1dc4283 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
2021-12-30 18:37:17 +01:00
Jochen Sprickerhof
a0467c802d 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.
2021-12-27 13:07:11 +01:00
Hiltjo Posthuma
273db5ceaf follow-up fix for OSC color sequences, return
Otherwise the message "erresc: unknown str" is printed.
2021-12-26 19:00:41 +01:00
Raheman Vaiya
8e31030390 Add support for OSC color sequences 2021-12-26 18:57:44 +01:00
Hiltjo Posthuma
2f6e597ed8 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!
2021-08-24 13:44:35 +02:00
Koichi Murase
1d3142da96 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.
2021-08-24 13:30:11 +02:00
Petar Kapriš
2ec571a30c 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.
2021-07-18 11:44:56 +02:00
Markus F.X.J. Oberhumer
4536f46cff Mild const-correctness improvements.
Only touch a few things, the main focus is to
improve code readability.
2021-05-06 18:21:10 +02:00
Hiltjo Posthuma
9e68fdbcdb 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
2021-03-19 11:58:59 +01:00
Hiltjo Posthuma
4ef0cbd8b9 remove unused variable from previous patch 2020-10-18 11:18:03 +02:00
John Collis
28b4c822c5 ST: Add WM_ICON_NAME property support
Also added _NET_WM_ICON_NAME.
2020-10-18 11:17:11 +02:00
Hiltjo Posthuma
fa253f077f bump version to 0.8.4 2020-06-19 11:27:17 +02:00
Hiltjo Posthuma
b27a383a3a config.mk: use PKG_CONFIG in commented OpenBSD section 2020-06-17 23:49:40 +02:00
Hiltjo Posthuma
81067c65ea LICENSE: bump years 2020-06-17 23:49:40 +02:00
Hiltjo Posthuma
f74a9df6e1 remove sixel stub code
Remove stub code that was used for an experiment of adding sixel code to st
from the commit f7398434.
2020-06-17 23:49:22 +02:00
Hiltjo Posthuma
818ec746f4 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.
"
2020-06-17 21:35:39 +02:00
Hiltjo Posthuma
9ba7ecf7b1 FAQ: fix single-buffer patch
rebase against master
2020-06-01 14:09:46 +02:00
Hiltjo Posthuma
a2a704492b 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'
2020-05-30 22:06:15 +02:00
Hiltjo Posthuma
0f8b40652b FAQ: add some details about the w3m img hack
... and an example patch to switch from double-buffering to a single buffer.
2020-05-30 22:05:17 +02:00
Hiltjo Posthuma
e6e2c6199f tiny style fix 2020-05-30 22:05:17 +02:00
Hiltjo Posthuma
94b8ec0021 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.
2020-05-30 22:04:28 +02:00
Steve Ward
dec6b530a4 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).
2020-05-24 13:45:42 +02:00
Hiltjo Posthuma
475a0a36cb Revert "support REP (repeat) escape sequence"
This reverts commit e8392b282c.

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).
2020-05-16 21:06:13 +02:00
Avi Halachmi (:avih)
e8392b282c 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.
2020-05-16 14:08:10 +02:00
Roberto E. Vargas
f8afebdfa0 Add rin terminfo capability
Tianlin Qu discovered that st is missing rin (scroll back #1 lines).
2020-05-16 14:07:31 +02:00
k0ga
bda9c9ffa6 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.
2020-05-16 12:37:14 +02:00
Jakub Leszczak
045a0fab4f Fix selection: selscroll 2020-05-12 15:38:17 +02:00
Jakub Leszczak
9c30066e73 Fix selection: ignore ATTR_WRAP when rectangular selection in getsel 2020-05-12 15:38:02 +02:00
Jakub Leszczak
8304d4f059 Fix selection: selclear in tputc 2020-05-12 15:37:59 +02:00
Hiltjo Posthuma
914fb825df code-style: add fallthrough comment
Patch by Steve Ward, thanks.
2020-05-09 14:43:31 +02:00
Hiltjo Posthuma
cde480c693 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.
2020-05-09 14:11:25 +02:00
Hiltjo Posthuma
8211e36d28 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 11625c7166
	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.
2020-05-09 14:07:52 +02:00
Hiltjo Posthuma
87545c612e tiny code-style and typo-fix in comment 2020-05-09 14:05:04 +02:00
Avi Halachmi (:avih)
1d59091065 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).
2020-05-09 13:53:50 +02:00
Jan Klemkow
d6ea0a1a61 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.
2020-04-30 01:21:21 +02:00
Hiltjo Posthuma
43a395ae91 bump version to 0.8.3 2020-04-27 13:56:25 +02:00
Ivan Tham
72e3f6c7c0 Update XIM cursor position only if changed
Updating XIM cursor position is expensive, so only update it when cursor
position changed.
2020-04-19 19:39:48 +02:00
Hiltjo Posthuma
33a9a45664 just remove the EOF message 2020-04-11 15:45:06 +02:00
Roberto E. Vargas Caballero
771bc401f7 Add st-mono terminfo entry
This entry is intended for monocolor display and it is very
helpful for color haters.
2020-04-11 15:23:23 +02:00
Hiltjo Posthuma
d66bd405c0 config.def.h: add a comment for the scroll variable 2020-04-11 15:23:23 +02:00
Hiltjo Posthuma
e997303502 Fix small typos 2020-04-11 15:23:23 +02:00
Quentin Rameau
c1145268f6 Launch scroll program with the default shell 2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero
0b73612c0d Update FAQ with the last modifications 2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero
019449a7e6 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.
2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero
fbae700a3f Fix style issue 2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero
e52319cc7d 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.
2020-04-11 15:23:23 +02:00
Roberto E. Vargas Caballero
21e0d6e8b8 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.
2020-04-11 15:23:20 +02:00
Hiltjo Posthuma
5703aa0390 make argv0 not static, fixes a warning with tcc
Reported by Aajonus, thanks!
2020-04-10 12:12:43 +02:00
Avi Halachmi (:avih)
28ad288399 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.
2020-04-02 14:41:03 +02:00
Ivan Tham
51e19ea11d 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.
2020-02-19 00:46:20 +01:00
Quentin Rameau
26cdfebf31 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.
2020-02-02 22:56:51 +01:00
Quentin Rameau
cd785755f2 x: check we still have an XIC context before accessing it 2020-02-02 22:56:51 +01:00
Quentin Rameau
2cb539142b x: do not instantiate a new nested list on each cursor move 2020-02-02 22:56:51 +01:00
Quentin Rameau
99de333951 x: move IME variables into XWindow ime embedded struct 2020-02-02 22:56:51 +01:00
Ivan Tham
895e5b50a8 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)
あなたは家のように感じる
2020-01-18 14:21:50 +01:00
Hiltjo Posthuma
384830110b update FAQ
- add common question about the w3m image drawing hack.
- remove some bad advise about $TERM.
- change some links to https.
2019-11-17 20:04:52 +01:00
Avi Halachmi (:avih)
2e54a21b5a 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.
2019-11-10 22:45:54 +01:00
Hiltjo Posthuma
289c52b7aa CSIEscape, STREscape: use size_t for buffer length 2019-11-10 22:45:54 +01:00
Avi Halachmi (:avih)
7ceb3d1f72 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.
2019-11-10 22:45:54 +01:00
Avi Halachmi (:avih)
ea4d933ed9 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).
2019-11-10 22:45:54 +01:00
Sebastian J. Bronner
83866428de 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
eeedb43ae8/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.
2019-11-05 19:51:35 +01:00
Ingo Lohmar
1f09f0b0bb 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.
2019-10-26 11:47:24 +02:00
Avi Halachmi (:avih)
a2c479c4c8 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.
2019-10-24 15:34:25 +02:00
Avi Halachmi (:avih)
d2b75db8d7 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.
2019-10-13 21:46:31 +02:00
Avi Halachmi (:avih)
b6d280de6d 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.
2019-10-13 21:46:31 +02:00
Avi Halachmi (:avih)
ba7f4d69af 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.
2019-10-13 21:46:31 +02:00
Hiltjo Posthuma
2b8333f553 config.def.h: remove crlf value section
this is not used anymore.

patch sent as an ed script using RFC2549 by k0ga.
2019-08-26 17:58:47 +02:00
Hiltjo Posthuma
caa1d8fbea 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.
2019-05-17 13:00:10 +02:00
Avi Halachmi (:avih)
f1546cf9c1 selection: fix view to match actual selection on first cell 2019-04-14 13:50:20 +02:00
Hiltjo Posthuma
21367a040f revert part of commit add0211522
"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.
2019-03-15 20:40:16 +01:00
Hiltjo Posthuma
b650256044 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'
2019-03-15 14:47:08 +01:00
Hiltjo Posthuma
9acec468fb minor code-style, initialize var at the top of function 2019-03-15 14:42:50 +01:00
Hiltjo Posthuma
927621f6da config.def.h: tweak extra worddelimiters
This changes the selection more like xterm.
To test try: "find /" and select a path.
2019-03-15 12:31:54 +01:00
Lauri Tirkkonen
add0211522 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.
2019-03-15 12:25:13 +01:00
Lauri Tirkkonen
d5efd256aa replace utf8strchr with wcschr 2019-03-15 12:24:13 +01:00
Lauri Tirkkonen
75b4ba4b4b be silent about explicitly unhandled mouse modes 2019-03-13 17:51:58 +01:00
Hiltjo Posthuma
ed68fe7dce 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."
2019-03-03 11:29:43 +01:00
Hiltjo Posthuma
4e0135afec style: remove double empty newlines 2019-03-03 11:23:54 +01:00
magras
a8cb8e9454 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.
2019-03-03 11:18:31 +01:00
Ivan Tham
e85b6b6466 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
2019-02-12 18:45:15 +01:00
Hiltjo Posthuma
75f92eb348 bump version to 0.8.2 2019-02-09 12:48:39 +01:00
Hiltjo Posthuma
3be4cf11d7 config: add Shift+Insert as selpaste() again
This was changed before in:
commit 20f713548d on Wed Jan 25 19:17:38 2017
2019-01-10 18:16:17 +01:00
Paride Legovini
16d98738e7 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.
2019-01-10 18:13:13 +01:00
Paride Legovini
e23acb9188 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.
2019-01-04 16:00:54 +01:00
Hiltjo Posthuma
7e19e11676 Makefile: fix dependencies on config.h
patch by Younes Khoudli (changed slightly). Thanks
2019-01-04 12:33:01 +01:00
Lauri Tirkkonen
096b125db7 output child WEXITSTATUS/WTERMSIG on abnormal termination 2018-12-11 18:36:02 +01:00
Hiltjo Posthuma
d7bf023b2f fix memory leak in xloadcols()
reported by Avi Halachmi (:avih)" <avihpit@yahoo.com>

patch slightly changed by me.
2018-11-04 14:35:07 +01:00
Hiltjo Posthuma
b4d68d4daa st: small typofix in comment 2018-11-04 14:30:56 +01:00
Hiltjo Posthuma
30ec9a3dc3 small code-style fix 2018-09-11 19:06:35 +02:00
Quentin Rameau
67d0cb65d0 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!
2018-09-11 19:05:55 +02:00
Hiltjo Posthuma
4f4bccd162 Revert "Simplify cursor color handling"
This reverts commit 1911c9274d.
2018-07-17 20:01:58 +02:00
Hiltjo Posthuma
8ed7a4b3b7 Revert "Make cursor follow text color"
This reverts commit b51bcd5553.
2018-07-17 20:01:57 +02:00
Hiltjo Posthuma
732be223ee Revert "Fix crash when cursor color is truecolor"
This reverts commit 5535c1f04c.
2018-07-17 20:01:54 +02:00
Jules Maselbas
5535c1f04c Fix crash when cursor color is truecolor
Reported-by: Ivan Tham <pickfire@riseup.net>
2018-07-15 18:16:52 +02:00
Jules Maselbas
b51bcd5553 Make cursor follow text color 2018-07-14 12:49:37 +02:00
Jules Maselbas
1911c9274d Simplify cursor color handling 2018-07-14 12:49:35 +02:00
Jules Maselbas
29f341da7c 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.
2018-06-30 20:51:46 +02:00
Hiltjo Posthuma
dc3b5babf1 config.mk: remove extra newline before EOF 2018-06-02 17:11:14 +02:00
Hiltjo Posthuma
235a783e03 code-style for pledge(2)
feedback from Klemens, thanks
2018-05-25 13:04:09 +02:00
Hiltjo Posthuma
30ce2cc002 Pledge on OpenBSD 2018-05-25 11:59:28 +02:00
Hiltjo Posthuma
041912a791 error message style and use strerror in a few places 2018-03-29 18:30:05 +02:00
Hiltjo Posthuma
bd3f7fd842 st -v: remove years and copyright text 2018-03-29 18:18:30 +02:00
Daniel Tameling
74cff67bd7 set sel.alt in selstart instead of selextend 2018-03-29 18:15:29 +02:00
Hiltjo Posthuma
6f0f2b7ec3 bump version to 0.8.1 2018-03-20 21:29:10 +01:00
Hiltjo Posthuma
f4020b2cc4 fix regression by selecting clipboard text
"restore the old behaviour that the primary doesn't get deleted by a simple
left click"

Patch by Daniel Tameling <tamelingdaniel@gmail.com>, thanks!
2018-03-20 21:25:30 +01:00
Hiltjo Posthuma
a5a928bfc1 don't modify argv, use a counter
on some platforms (OpenBSD) this changes the exposed argv in tools using
the kvm_* interface, such as ps and pgrep.
2018-03-20 21:22:27 +01:00
Hiltjo Posthuma
6ac8c8aa50 selextend: clarify: !sel.mode == SEL_IDLE 2018-03-17 13:48:29 +01:00
Hiltjo Posthuma
5345db3c9b clipcopy: no need to check for free(NULL), set to NULL after free 2018-03-17 13:48:10 +01:00
Hiltjo Posthuma
7648697f71 minor code-style: whitespace fixes 2018-03-16 16:45:58 +01:00
Quentin Rameau
0b507bb731 Fix title initialization 2018-03-16 16:44:30 +01:00
Quentin Rameau
e7ef3c4ce9 Fix regression from 69e32a6 when setting title. 2018-03-16 16:44:30 +01:00
Hiltjo Posthuma
8ab629031b LICENSE: fix a few years 2018-03-14 20:08:00 +01:00
Hiltjo Posthuma
a712c2dd18 update LICENSE: major contributors 2018-03-14 20:00:35 +01:00
Hiltjo Posthuma
0f245dfeb9 Makefile: add all files to make dist 2018-03-14 19:54:50 +01:00
Hiltjo Posthuma
49a4f91fc5 bump version to 0.8 2018-03-14 19:50:37 +01:00
Hiltjo Posthuma
c5ba9c025b use math.h for ceilf 2018-03-09 15:36:38 +01:00
Hiltjo Posthuma
b81888ee7d xhints: no need to initialize sizeh 2018-03-09 15:36:25 +01:00
Hiltjo Posthuma
8b8255ac0e regression: include termios.h for tcsendbreak etc 2018-03-09 15:35:34 +01:00
Devin J. Pohly
20e0da7f14 General cleanup
Simplifies logic in a couple places and removes a redundant function
call.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly
403c57ebb5 Clean up #includes
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly
e0215d5377 Reduce visibility wherever possible
When possible, declare functions/variables static and move struct
definitions out of headers.  In order to allow utf8decode to become
internal, use codepoint for DECSCUSR extension directly.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly
30683c70ab Limit usage of extern to config.h globals
Prefer passing arguments to declaring external global variables.  The
only remaining usage of extern is for config.h variables which are
needed in st.c instead of x.c (where it is now included).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly
a3beb626d2 Remove x.c dependency on term
The xinit function only needs to the rows/cols, so pass those in rather
than accessing term directly.  With a bit of arithmetic, we are able to
avoid the need for term.row and term.col in x2col, y2row, and
xdrawglyphfontspecs as well, completing the removal.

Term is now fully internal to st.c.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly
a5dc1b4697 Pull term references out of xdrawcursor
Gradually reducing x.c dependency on Term object.  Old and new cursor
glyph/position are passed to xdrawcursor.  (There may be an opportunity
to refactor further if we can unify "clear old cursor" and "draw new
cursor" functionality.)

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly
88d8293fb4 Move win-agnostic parts of draw/drawregion to st.c
Introduces three functions to encapsulate X-specific behavior:
 * xdrawline: draws a portion of a single line (used by drawregion)
 * xbegindraw: called to prepare for drawing (will be useful for e.g.
   Wayland) and returns true if drawing should happen
 * xfinishdraw: called to finish drawing (used by draw)

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly
05c66cb37d Split mode bits between Term and TermWindow
Moves the mode bits used by x.c from Term to TermWindow, absorbing
UI/input-related mode bits (visible/focused/numlock) along the way.

This is gradually reducing external references to Term.  Since
TermWindow is already internal to x.c, we add xsetmode() to allow st to
modify window bits in accordance with escape sequences.

IS_SET() is redefined accordingly (term.mode in st.c, win.mode in x.c).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:56:26 -06:00
Devin J. Pohly
33201ac65f Move CRLF input processing into ttywrite
This also allows us to remove the crlf field from the Key struct, since
the only difference it made was converting "\r" to "\r\n" (which is now
done automatically in ttywrite).  In addition, MODE_CRLF is no longer
referenced from x.c.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
52d6fb1ab1 Move terminal echo logic into st.c
The only thing differentiating ttywrite and ttysend was the potential
for echo; make this a parameter and remove ttysend.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
cfc7acdfd9 Move remaining selection mode logic into selextend
The "done" parameter indicates a change which finalizes the selection
(e.g. a mouse button release as opposed to motion).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
bcb5d3adbe Move terminal-related selection logic into st.c
The front-end determines information about mouse clicks and motion, and
the terminal handles the actual selection start/extend/dirty logic by
row and column.

While we're in the neighborhood, we'll also rename getbuttoninfo() to
mousesel() which is, at least, less wrong.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
5683b1f80c Move X-specific selection info into XSelection
Data about PRIMARY/CLIPBOARD and clicks are part of the front-end, not
the terminal.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
138caf294e Have selected() check whether selection exists
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
d84f3f4bd1 Rely on ttyresize to set tty size
This removes ttynew's dependency on cresize being called first, and then
allows us to absorb the ttyresize call into cresize (which always
precedes it).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
8b564c1a3f Remove X and fontconfig from st.c
None of the X-related includes are needed any longer.  In addition, move
the X modifier defines into x.c, as they are not used outside.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
3bb900cd6c Remove Time argument from xsetsel
This is an X type and should be internal to x.c.

The selcopy() function was a single line and only used in one place, so
it was inlined to reduce LOC.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
323d38da20 Make win variable internal to x.c
There was only a single reference to the `win` variable in st.c, so
exporting that to x.c allows us to rid ourselves of another extern.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
416dd25727 Move X-related config.h types into x.c
No need to expose Shortcut, MouseShortcut, and Key anymore.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
75c9a0ee1d Remove unneeded array-length variables
These were only used in x.c, which now has direct visibility of the
config.h arrays.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
428f01969a Inline clipboard functions
No need to keep a function that only calls another function in the same
file.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
65976c1a29 Move config.h include from st.c to x.c
config.h includes references to KeySyms and other X stuff.  Until we
come up with a cleaner way to separate configuration, it is simpler
(leads to more code removal) to have this here.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
32d3b1d00f Factor out equivalent code from ttyread/ttysend
The echo-to-terminal portions of ttyread and ttysend were actually doing
the same thing.  New function twrite() now handles this.  The parameter
show_ctrl determines whether control characters are shown as "^A".  This
was the only difference between tputc and techo, and techo is now unused
and removed.

(This commit should not change st's behaviour.)

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
69e32a61df Move opt_* into same file as main()/run()
This commit is purely about reducing externs and LOC.  If the main and
run functions ever move elsewhere (which will probably make sense
eventually), these should come along with them.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
ed132e1127 Move key-matching functions into x.c
Modifiers and keysyms are specific to X, and the functions match and
kmap are only used in x.c.  Needed to global-ize the key arrays and
lengths from config.h (for now).

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
dbe8676d7d Pass new dimensions into ttyresize
This removes another reference to TermWindow from st.c.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
a8314643b1 Move window-manipulating functions into x.c
xresize is now internal to x.c

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
a09138afa5 Move font/fontspec variables into x.c and XWindow
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
626b0ae40c Move window urgency handling entirely into x.c
This allows us to make xseturgency internal.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
d5275012b4 Move zoom functions into x.c
This makes x(un)loadfonts internal to x.c.  Needed to reorder includes
and move a typedef to keep the compiler happy.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
3518dba2a5 Move usage() to be with run() in x.c
run/usage/xinit are now all internal to x.c

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Devin J. Pohly
3e44ee5569 Call xsetenv() in main process instead of child
This makes xsetenv internal to x.c, and allows iso14755's external
command to use $WINDOWID instead of having to snprintf it again.  (The
same benefit will apply to the externalpipe patch.)  The xwinid function
is no longer needed.

Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
2018-02-25 21:53:24 -06:00
Benno Fünfstück
1f24bde82b Fix color with FAINT attribute
The alpha value needs to be initialized as well.
2017-12-26 22:54:44 +01:00
Benno Fünfstück
e829e13bb1 Apply ATTR_REVERSE after ATTR_FAINT
An example where the new behaviour makes more sense:

Suppose some text is formatted with ATTR_FAINT for red for the foreground, so it
is rendered in a dark red. In that case, when selected with the mouse, the
intended behaviour is that foreground and background color are swapped: so the
selection should be rendered in dark red and the text in the default background
color.

Before this patch, what happened was that the selection would be in normal red
and the text in the darkened background color, making it almost unreadable.

For an example application that uses the FAINT attribute, try dmesg from
util-linux with color support, it uses FAINT for segfault messages.
2017-12-26 22:54:06 +01:00
George Ornbo
c1d23afa9c Fix FAQ typo 2017-12-21 19:17:40 +01:00
Paride Legovini
0ac685fc01 Fix manpage typo
Signed-off-by: Paride Legovini <pl@ninthfloor.org>
2017-10-10 18:08:42 +02:00
Gary Allen Vollink
b1338e91ed Add an error for XftFontOpenPattern failure. 2017-09-15 11:27:13 +02:00
Hiltjo Posthuma
b2ac917753 Revert "Revert "fixed STLDFLAG order in broken st Makefile""
This reverts commit 274d46ace0.

Sorry, the original commit was correct after all. It allows has the
correct link order and supports static-linking also.

Just a reminder: it is important to give a (brief) rationale of the
patch intentions.
2017-09-15 11:16:37 +02:00
Suraj N. Kurapati
ee5cc8e903 base64dec: skip non-printable characters like \r\n
Non-printable characters, such as line breaks, in a base64 encoded
string violate the "string length must be a multiple of four" rule.

This patch pads the result buffer by one extra unit of four bytes,
and skips over non-printable characters found in the input string.
2017-09-15 11:13:17 +02:00
Hiltjo Posthuma
274d46ace0 Revert "fixed STLDFLAG order in broken st Makefile"
This reverts commit 7f990328e4.

this was wrong as pointed out by k0ga:
"STLDFLAGS is about flags to the linker, for example -L
not about -l for that reason it must go before the object list".
2017-09-13 22:40:36 +02:00
Hiltjo Posthuma
9c61f29bb7 Revert "make clipboard patch obsolete"
This reverts commit 77c51c5a6b.

Having multiple clipboards are useful, for example for plumber scripts.
I've discussed this on IRC and it is useful to have.
2017-09-02 13:52:33 +02:00
Anselm R Garbe
77c51c5a6b make clipboard patch obsolete 2017-09-01 09:48:24 +02:00
Anselm R Garbe
7f990328e4 fixed STLDFLAG order in broken st Makefile 2017-07-23 11:17:26 +02:00
Quentin Rameau
8dacdfbab1 Revert "Add bold off SGR"
This reverts commit 6cb6d61525.
This wasn't a useful thing after all.
2017-07-12 13:29:31 +02:00
Quentin Rameau
c0882f2ed1 Add dim/smxx/rmxx to terminfo, remove duplicate kich1 2017-07-12 13:29:30 +02:00
Quentin Rameau
d4928edba0 Let the user specify C and LD FLAGS 2017-07-12 00:28:11 +02:00
Quentin Rameau
fabd4602b3 Do not obfuscate what make is doing.
Change some styling too while we're at it.
2017-07-12 00:28:10 +02:00
Marc André Tanner
b331da550b Add color change terminfo capabilities 2017-06-03 22:28:35 +02:00
Quentin Rameau
6cb6d61525 Add bold off SGR 2017-06-03 22:28:35 +02:00
greg.reagle@umbc.edu
5a10aca702 st.1: modify man page to accurately reflect default keybindings
Attached.

===> 2/ (text/x-patch) [file]
	cp /mail/fs/mbox/298/2/body /usr/k0ga/0001-st.1-modify-man-page-to-accurately-reflect-default-k.patch

From 265db94b1eca5850d484f86b7db4af8e57822cfe Mon Sep 17 00:00:00 2001
From: Greg Reagle <greg.reagle@umbc.edu>
Date: Sun, 9 Apr 2017 23:05:47 -0400
Subject: [PATCH] st.1: modify man page to accurately reflect default
 keybindings
2017-04-10 18:32:10 +02:00
Quentin Rameau
745c40f8b0 Simplify how we keep ATTRs under cursor
Thanks to tarug0 for the suggestion/patch.
2017-04-04 18:23:45 +02:00
Alexander Krotov
149c0d3aed Fix commented out code 2017-03-29 18:46:20 +02:00
Nils Reuße
f2bfd513b1 keep some glyph modes for the cursor
st currently does not keep any mode for the cursor that was active
in the underlying glyph (e.g. italic text), the mode is always
ATTR_NULL [1].  At [2] you can find a screenshot that shows the
implications.  Other terminals (at least vte-based, such as
XFCE-terminal) keep some modes for the cursor.  I find the current
behaviour very disruptive, so here is a patch that keeps a few
(arbitrarily chosen) modes for the cursor.

[1] http://git.suckless.org/st/tree/st.c#n3963
[2] http://i.imgur.com/R2yCEaC.png
2017-03-29 18:39:21 +02:00
osandov@osandov.com
e7ed326d2e Support xterm Ms feature to set clipboard
This is used by, e.g., tmux.
2017-03-19 20:32:22 +01:00
16 changed files with 2528 additions and 1637 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
config.h
*.o
st

110
FAQ
View File

@ -1,12 +1,14 @@
## Why does st not handle utmp entries? ## Why does st not handle utmp entries?
Use the excellent tool of [utmp](http://git.suckless.org/utmp/) for this task. 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! ## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
It means that st doesnt have any terminfo entry on your system. Chances are It means that st doesnt 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 did not `make install`. If you just want to test it without installing it,
you can manualy run `tic -sx st.info`. you can manually run `tic -sx st.info`.
## Nothing works, and nothing is said about an unknown terminal! ## Nothing works, and nothing is said about an unknown terminal!
@ -15,19 +17,21 @@ you can manualy run `tic -sx st.info`.
* Some programs dont complain about the lacking st description and default to * Some programs dont complain about the lacking st description and default to
another terminal. In that case see the question about terminfo. another terminal. In that case see the question about terminfo.
## I get some weird glitches/visual bug on _random program_!
Try launching it with a different TERM: $ TERM=xterm myapp. toe(1) will give
you a list of available terminals, but youll most likely switch between xterm,
st or st-256color. The default value for TERM can be changed in config.h
(TNAME).
## How do I scroll back up? ## How do I scroll back up?
Using a terminal multiplexer. * Using a terminal multiplexer.
* `st -e tmux` using C-b [ * `st -e tmux` using C-b [
* `st -e screen` using C-a ESC * `st -e screen` using C-a ESC
* 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 path 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? ## Why doesn't the Del key work in some programs?
@ -84,12 +88,14 @@ If you are using zsh, then read the zsh FAQ
Putting these lines into your .zshrc will fix the problems. Putting these lines into your .zshrc will fix the problems.
## How can I use meta in 8bit mode? ## How can I use meta in 8bit mode?
St supports meta in 8bit mode, but the default terminfo entry doesn't 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 use this capability. If you want it, you have to use the 'st-meta' value
in TERM. in TERM.
## I cannot compile st in OpenBSD ## I cannot compile st in OpenBSD
OpenBSD lacks librt, despite it being mandatory in POSIX OpenBSD lacks librt, despite it being mandatory in POSIX
@ -98,13 +104,14 @@ 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 st will compile without any loss of functionality, because all the functions are
included in libc on this platform. included in libc on this platform.
## The Backspace Case ## The Backspace Case
St is emulating the Linux way of handling backspace being delete and delete being St is emulating the Linux way of handling backspace being delete and delete being
backspace. backspace.
This is an issue that was discussed in suckless mailing list This is an issue that was discussed in suckless mailing list
<http://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy <https://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
terminal users wants its backspace to be how he feels it: terminal users wants its backspace to be how he feels it:
Well, I am going to comment why I want to change the behaviour Well, I am going to comment why I want to change the behaviour
@ -159,9 +166,88 @@ terminal users wants its backspace to be how he feels it:
[1] http://www.ibb.net/~anne/keyboard.html [1] http://www.ibb.net/~anne/keyboard.html
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html [2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
## But I really want the old grumpy behaviour of my terminal ## But I really want the old grumpy behaviour of my terminal
Apply [1]. Apply [1].
[1] http://st.suckless.org/patches/delkey [1] https://st.suckless.org/patches/delkey
## 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);
## BadLength X error in Xft when trying to render emoji
Xft makes st crash when rendering color emojis with the following error:
"X Error of failed request: BadLength (poly request too large or internal Xlib length error)"
Major opcode of failed request: 139 (RENDER)
Minor opcode of failed request: 20 (RenderAddGlyphs)
Serial number of failed request: 1595
Current serial number in output stream: 1818"
This is a known bug in Xft (not st) which happens on some platforms and
combination of particular fonts and fontconfig settings.
See also:
https://gitlab.freedesktop.org/xorg/lib/libxft/issues/6
https://bugs.freedesktop.org/show_bug.cgi?id=107534
https://bugzilla.redhat.com/show_bug.cgi?id=1498269
The solution is to remove color emoji fonts or disable this in the fontconfig
XML configuration. As an ugly workaround (which may work only on newer
fontconfig versions (FC_COLOR)), the following code can be used to mask color
fonts:
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
Please don't bother reporting this bug to st, but notify the upstream Xft
developers about fixing this bug.
As of 2022-09-05 this now seems to be finally fixed in libXft 2.3.5:
https://gitlab.freedesktop.org/xorg/lib/libxft/-/blob/libXft-2.3.5/NEWS

View File

@ -1,13 +1,16 @@
MIT/X Consortium License MIT/X Consortium License
© 2014-2022 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> © 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
© 2009 Anselm R Garbe <garbeam at gmail dot com> © 2008-2017 Anselm R Garbe <garbeam at gmail dot com>
© 2012-2016 Roberto E. Vargas Caballero <k0ga at shike2 dot com> © 2012-2017 Roberto E. Vargas Caballero <k0ga at shike2 dot com>
© 2012-2016 Christoph Lohmann <20h at r-36 dot net> © 2012-2016 Christoph Lohmann <20h at r-36 dot net>
© 2013 Eon S. Jeon <esjeon at hyunmu dot am> © 2013 Eon S. Jeon <esjeon at hyunmu dot am>
© 2013 Alexander Sedov <alex0player at gmail dot com> © 2013 Alexander Sedov <alex0player at gmail dot com>
© 2013 Mark Edgar <medgar123 at gmail dot com> © 2013 Mark Edgar <medgar123 at gmail dot com>
© 2013 Eric Pruitt <eric.pruitt at gmail dot com> © 2013-2014 Eric Pruitt <eric.pruitt at gmail dot com>
© 2013 Michael Forney <mforney at mforney dot org> © 2013 Michael Forney <mforney at mforney dot org>
© 2013-2014 Markus Teich <markus dot teich at stusta dot mhn dot de> © 2013-2014 Markus Teich <markus dot teich at stusta dot mhn dot de>
© 2014-2015 Laslo Hunhold <dev at frign dot de> © 2014-2015 Laslo Hunhold <dev at frign dot de>

View File

@ -1,63 +1,61 @@
# st - simple terminal # st - simple terminal
# See LICENSE file for copyright and license details. # See LICENSE file for copyright and license details.
.POSIX:
include config.mk include config.mk
SRC = st.c x.c SRC = st.c x.c hb.c
OBJ = ${SRC:.c=.o} OBJ = $(SRC:.c=.o)
all: options st all: options st
options: options:
@echo st build options: @echo st build options:
@echo "CFLAGS = ${CFLAGS}" @echo "CFLAGS = $(STCFLAGS)"
@echo "LDFLAGS = ${LDFLAGS}" @echo "LDFLAGS = $(STLDFLAGS)"
@echo "CC = ${CC}" @echo "CC = $(CC)"
config.h: config.h:
cp config.def.h config.h cp config.def.h config.h
.c.o: .c.o:
@echo CC $< $(CC) $(STCFLAGS) -c $<
@${CC} -c ${CFLAGS} $<
st.o: config.h st.h win.h st.o: config.h st.h win.h
x.o: arg.h st.h win.h x.o: arg.h config.h st.h win.h hb.h
hb.o: st.h
${OBJ}: config.h config.mk $(OBJ): config.h config.mk
st: ${OBJ} st: $(OBJ)
@echo CC -o $@ $(CC) -o $@ $(OBJ) $(STLDFLAGS)
@${CC} -o $@ ${OBJ} ${LDFLAGS}
clean: clean:
@echo cleaning rm -f st $(OBJ) st-$(VERSION).tar.gz
@rm -f st ${OBJ} st-${VERSION}.tar.gz
dist: clean dist: clean
@echo creating dist tarball mkdir -p st-$(VERSION)
@mkdir -p st-${VERSION} cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\
@cp -R LICENSE Makefile README config.mk config.def.h st.info st.1 arg.h ${SRC} st-${VERSION} config.def.h st.info st.1 arg.h st.h win.h $(SRC)\
@tar -cf st-${VERSION}.tar st-${VERSION} st-$(VERSION)
@gzip st-${VERSION}.tar tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz
@rm -rf st-${VERSION} rm -rf st-$(VERSION)
install: all install: st
@echo installing executable file to ${DESTDIR}${PREFIX}/bin mkdir -p $(DESTDIR)$(PREFIX)/bin
@mkdir -p ${DESTDIR}${PREFIX}/bin cp -f st $(DESTDIR)$(PREFIX)/bin
@cp -f st ${DESTDIR}${PREFIX}/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/st
@chmod 755 ${DESTDIR}${PREFIX}/bin/st mkdir -p $(DESTDIR)$(MANPREFIX)/man1
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
@mkdir -p ${DESTDIR}${MANPREFIX}/man1 chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
@sed "s/VERSION/${VERSION}/g" < st.1 > ${DESTDIR}${MANPREFIX}/man1/st.1 tic -sx st.info
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/st.1
@echo Please see the README file regarding the terminfo entry of st. @echo Please see the README file regarding the terminfo entry of st.
@tic -sx st.info mkdir -p $(DESTDIR)$(APPPREFIX)
cp -f st.desktop $(DESTDIR)$(APPPREFIX)
uninstall: uninstall:
@echo removing executable file from ${DESTDIR}${PREFIX}/bin rm -f $(DESTDIR)$(PREFIX)/bin/st
@rm -f ${DESTDIR}${PREFIX}/bin/st rm -f $(DESTDIR)$(APPPREFIX)/st.desktop
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1 rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
@rm -f ${DESTDIR}${MANPREFIX}/man1/st.1
.PHONY: all options clean dist install uninstall .PHONY: all options clean dist install uninstall

22
arg.h
View File

@ -21,28 +21,30 @@ extern char *argv0;
argc--;\ argc--;\
break;\ break;\
}\ }\
for (brk_ = 0, argv[0]++, argv_ = argv;\ int i_;\
argv[0][0] && !brk_;\ for (i_ = 1, brk_ = 0, argv_ = argv;\
argv[0]++) {\ argv[0][i_] && !brk_;\
i_++) {\
if (argv_ != argv)\ if (argv_ != argv)\
break;\ break;\
argc_ = argv[0][0];\ argc_ = argv[0][i_];\
switch (argc_) switch (argc_)
#define ARGEND }\ #define ARGEND }\
} }
#define ARGC() argc_ #define ARGC() argc_
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\ #define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
((x), abort(), (char *)0) :\ ((x), abort(), (char *)0) :\
(brk_ = 1, (argv[0][1] != '\0')?\ (brk_ = 1, (argv[0][i_+1] != '\0')?\
(&argv[0][1]) :\ (&argv[0][i_+1]) :\
(argc--, argv++, argv[0]))) (argc--, argv++, argv[0])))
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\ #define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
(char *)0 :\ (char *)0 :\
(brk_ = 1, (argv[0][1] != '\0')?\ (brk_ = 1, (argv[0][i_+1] != '\0')?\
(&argv[0][1]) :\ (&argv[0][i_+1]) :\
(argc--, argv++, argv[0]))) (argc--, argv++, argv[0])))
#endif #endif

View File

@ -5,56 +5,67 @@
* *
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/ */
char font[] = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; static char *font = "Fira Code:pixelsize=14:antialias=true:autohint=true";
int borderpx = 2; static int borderpx = 2;
/* /*
* What program is execed by st depends of these precedence rules: * What program is execed by st depends of these precedence rules:
* 1: program passed with -e * 1: program passed with -e
* 2: utmp option * 2: scroll and/or utmp
* 3: SHELL environment variable * 3: SHELL environment variable
* 4: value of shell in /etc/passwd * 4: value of shell in /etc/passwd
* 5: value of shell in config.h * 5: value of shell in config.h
*/ */
static char shell[] = "/bin/sh"; static char *shell = "/bin/sh";
static char *utmp = NULL; char *utmp = NULL;
static char stty_args[] = "stty raw pass8 nl -echo -iexten -cstopb 38400"; /* scroll program: to enable use a string like "scroll" */
char *scroll = NULL;
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
/* identification sequence returned in DA and DECID */ /* identification sequence returned in DA and DECID */
static char vtiden[] = "\033[?6c"; char *vtiden = "\033[?6c";
/* Kerning / character bounding-box multipliers */ /* Kerning / character bounding-box multipliers */
float cwscale = 1.0; static float cwscale = 1.0;
float chscale = 1.0; static float chscale = 1.0;
/* /*
* word delimiter string * word delimiter string
* *
* More advanced example: " `'\"()[]{}" * More advanced example: L" `'\"()[]{}"
*/ */
static char worddelimiters[] = " "; wchar_t *worddelimiters = L" ";
/* selection timeouts (in milliseconds) */ /* selection timeouts (in milliseconds) */
unsigned int doubleclicktimeout = 300; static unsigned int doubleclicktimeout = 300;
unsigned int tripleclicktimeout = 600; static unsigned int tripleclicktimeout = 600;
/* alt screens */ /* alt screens */
int allowaltscreen = 1; int allowaltscreen = 1;
/* frames per second st should at maximum draw to the screen */ /* allow certain non-interactive (insecure) window operations such as:
unsigned int xfps = 120; setting the clipboard text */
unsigned int actionfps = 30; 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
* near minlatency, but it waits longer for slow updates to avoid partial draw.
* low minlatency will tear/flicker more, as it can "detect" idle too early.
*/
static double minlatency = 8;
static double maxlatency = 33;
/* /*
* blinking timeout (set to 0 to disable blinking) for the terminal blinking * blinking timeout (set to 0 to disable blinking) for the terminal blinking
* attribute. * attribute.
*/ */
unsigned int blinktimeout = 800; static unsigned int blinktimeout = 800;
/* /*
* thickness of underline and bar cursors * thickness of underline and bar cursors
*/ */
unsigned int cursorthickness = 2; static unsigned int cursorthickness = 2;
/* /*
* bell volume. It must be a value between -100 and 100. Use 0 for disabling * bell volume. It must be a value between -100 and 100. Use 0 for disabling
@ -63,7 +74,7 @@ unsigned int cursorthickness = 2;
static int bellvolume = 0; static int bellvolume = 0;
/* default TERM value */ /* default TERM value */
char termname[] = "st-256color"; char *termname = "st-256color";
/* /*
* spaces per tab * spaces per tab
@ -80,46 +91,61 @@ char termname[] = "st-256color";
* *
* stty tabs * stty tabs
*/ */
static unsigned int tabspaces = 8; unsigned int tabspaces = 8;
/* bg opacity */
float alpha = 0.8;
/* Terminal colors (16 first used in escape sequence) */ /* Terminal colors (16 first used in escape sequence) */
const char *colorname[] = { static const char *colorname[] = {
/* 8 normal colors */ /* 8 normal colors */
"black", [0] = "#000000", /* black */
"red3", [1] = "#ff5555", /* red */
"green3", [2] = "#50fa7b", /* green */
"yellow3", [3] = "#f1fa8c", /* yellow */
"blue2", [4] = "#bd93f9", /* blue */
"magenta3", [5] = "#ff79c6", /* magenta */
"cyan3", [6] = "#8be9fd", /* cyan */
"gray90", [7] = "#bbbbbb", /* white */
/* 8 bright colors */ /* 8 bright colors */
"gray50", [8] = "#44475a", /* black */
"red", [9] = "#ff5555", /* red */
"green", [10] = "#50fa7b", /* green */
"yellow", [11] = "#f1fa8c", /* yellow */
"#5c5cff", [12] = "#bd93f9", /* blue */
"magenta", [13] = "#ff79c6", /* magenta */
"cyan", [14] = "#8be9fd", /* cyan */
"white", [15] = "#ffffff", /* white */
[255] = 0, /* special colors */
[256] = "#222222", /* background */
[257] = "#ffffff", /* foreground */
/* more colors can be added after 255 to use with DefaultXX */ /* more colors can be added after 255 to use with DefaultXX */
"#cccccc", "#cccccc",
"#555555", "#555555",
"gray90", /* default foreground colour */
"black", /* default background colour */
}; };
/* /*
* Default colors (colorname index) * Default colors (colorname index)
* foreground, background, cursor, reverse cursor * foreground, background, cursor
*/ */
unsigned int defaultfg = 7; unsigned int defaultfg = 257;
unsigned int defaultbg = 0; unsigned int defaultbg = 256;
unsigned int defaultcs = 256; unsigned int defaultcs = 257;
unsigned int defaultrcs = 257; static unsigned int defaultrcs = 257;
/*
* Colors used, when the specific fg == defaultfg. So in reverse mode this
* will reverse too. Another logic would only make the simple feature too
* complex.
*/
unsigned int defaultitalic = 7;
unsigned int defaultunderline = 7;
/* /*
* Default shape of cursor * Default shape of cursor
@ -128,43 +154,91 @@ unsigned int defaultrcs = 257;
* 6: Bar ("|") * 6: Bar ("|")
* 7: Snowman ("") * 7: Snowman ("")
*/ */
unsigned int cursorshape = 2; static unsigned int cursorshape = 2;
/* /*
* Default columns and rows numbers * Default columns and rows numbers
*/ */
unsigned int cols = 80; static unsigned int cols = 80;
unsigned int rows = 24; static unsigned int rows = 24;
/* /*
* Default colour and shape of the mouse cursor * Default colour and shape of the mouse cursor
*/ */
unsigned int mouseshape = XC_xterm; static unsigned int mouseshape = XC_xterm;
unsigned int mousefg = 7; static unsigned int mousefg = 7;
unsigned int mousebg = 0; static unsigned int mousebg = 0;
/* /*
* Color used to display font attributes when fontconfig selected a font which * Color used to display font attributes when fontconfig selected a font which
* doesn't match the ones requested. * doesn't match the ones requested.
*/ */
unsigned int defaultattr = 11; static unsigned int defaultattr = 11;
/*
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
* Note that if you want to use ShiftMask with selmasks, set this to an other
* modifier, set to 0 to not use it.
*/
static uint forcemousemod = ShiftMask;
/*
* Xresources preferences to load at startup
*/
ResourcePref resources[] = {
{ "font", STRING, &font },
{ "color0", STRING, &colorname[0] },
{ "color1", STRING, &colorname[1] },
{ "color2", STRING, &colorname[2] },
{ "color3", STRING, &colorname[3] },
{ "color4", STRING, &colorname[4] },
{ "color5", STRING, &colorname[5] },
{ "color6", STRING, &colorname[6] },
{ "color7", STRING, &colorname[7] },
{ "color8", STRING, &colorname[8] },
{ "color9", STRING, &colorname[9] },
{ "color10", STRING, &colorname[10] },
{ "color11", STRING, &colorname[11] },
{ "color12", STRING, &colorname[12] },
{ "color13", STRING, &colorname[13] },
{ "color14", STRING, &colorname[14] },
{ "color15", STRING, &colorname[15] },
{ "background", STRING, &colorname[256] },
{ "foreground", STRING, &colorname[257] },
{ "cursorColor", STRING, &colorname[258] },
{ "termname", STRING, &termname },
{ "shell", STRING, &shell },
{ "minlatency", INTEGER, &minlatency },
{ "maxlatency", INTEGER, &maxlatency },
{ "blinktimeout", INTEGER, &blinktimeout },
{ "bellvolume", INTEGER, &bellvolume },
{ "tabspaces", INTEGER, &tabspaces },
{ "borderpx", INTEGER, &borderpx },
{ "cwscale", FLOAT, &cwscale },
{ "chscale", FLOAT, &chscale },
};
/* /*
* Internal mouse shortcuts. * Internal mouse shortcuts.
* Beware that overloading Button1 will disable the selection. * Beware that overloading Button1 will disable the selection.
*/ */
MouseShortcut mshortcuts[] = { static MouseShortcut mshortcuts[] = {
/* button mask string */ /* mask button function argument release */
{ Button4, XK_ANY_MOD, "\031" }, { ShiftMask, Button4, kscrollup, {.i = 1} },
{ Button5, XK_ANY_MOD, "\005" }, { ShiftMask, Button5, kscrolldown, {.i = 1} },
{ 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"} },
}; };
/* Internal keyboard shortcuts. */ /* Internal keyboard shortcuts. */
#define MODKEY Mod1Mask #define MODKEY Mod1Mask
#define TERMMOD (ControlMask|ShiftMask) #define TERMMOD (ControlMask|ShiftMask)
Shortcut shortcuts[] = { static Shortcut shortcuts[] = {
/* mask keysym function argument */ /* mask keysym function argument */
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} }, { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
{ ControlMask, XK_Print, toggleprinter, {.i = 0} }, { ControlMask, XK_Print, toggleprinter, {.i = 0} },
@ -176,8 +250,11 @@ Shortcut shortcuts[] = {
{ TERMMOD, XK_C, clipcopy, {.i = 0} }, { TERMMOD, XK_C, clipcopy, {.i = 0} },
{ TERMMOD, XK_V, clippaste, {.i = 0} }, { TERMMOD, XK_V, clippaste, {.i = 0} },
{ TERMMOD, XK_Y, selpaste, {.i = 0} }, { TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
{ TERMMOD, XK_I, iso14755, {.i = 0} }, { MODKEY, XK_l, copyurl, {.i = 0} },
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
}; };
/* /*
@ -195,10 +272,6 @@ Shortcut shortcuts[] = {
* * 0: no value * * 0: no value
* * > 0: cursor application mode enabled * * > 0: cursor application mode enabled
* * < 0: cursor application mode disabled * * < 0: cursor application mode disabled
* crlf value
* * 0: no value
* * > 0: crlf mode is enabled
* * < 0: crlf mode is disabled
* *
* Be careful with the order of the definitions because st searches in * Be careful with the order of the definitions because st searches in
* this table sequentially, so any XK_ANY_MOD must be in the last * this table sequentially, so any XK_ANY_MOD must be in the last
@ -217,231 +290,221 @@ static KeySym mappedkeys[] = { -1 };
*/ */
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD; static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
/*
* Override mouse-select while mask is active (when MODE_MOUSE is set).
* Note that if you want to use ShiftMask with selmasks, set this to an other
* modifier, set to 0 to not use it.
*/
uint forceselmod = ShiftMask;
/* /*
* This is the huge key array which defines all compatibility to the Linux * This is the huge key array which defines all compatibility to the Linux
* world. Please decide about changes wisely. * world. Please decide about changes wisely.
*/ */
static Key key[] = { static Key key[] = {
/* keysym mask string appkey appcursor crlf */ /* keysym mask string appkey appcursor */
{ XK_KP_Home, ShiftMask, "\033[2J", 0, -1, 0}, { XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
{ XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1, 0}, { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
{ XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1, 0}, { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
{ XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1, 0}, { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{ XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0, 0}, { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1, 0}, { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
{ XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1, 0}, { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
{ XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0, 0}, { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1, 0}, { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
{ XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1, 0}, { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
{ XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0, 0}, { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1, 0}, { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
{ XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1, 0}, { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
{ XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0, 0}, { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1, 0}, { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
{ XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1, 0}, { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
{ XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0, 0}, { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
{ XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0, 0}, { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{ XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0, 0}, { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
{ XK_KP_End, ControlMask, "\033[J", -1, 0, 0}, { XK_KP_End, ControlMask, "\033[J", -1, 0},
{ XK_KP_End, ControlMask, "\033[1;5F", +1, 0, 0}, { XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
{ XK_KP_End, ShiftMask, "\033[K", -1, 0, 0}, { XK_KP_End, ShiftMask, "\033[K", -1, 0},
{ XK_KP_End, ShiftMask, "\033[1;2F", +1, 0, 0}, { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
{ XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0, 0}, { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
{ XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0, 0}, { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
{ XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0, 0}, { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{ XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0, 0}, { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
{ XK_KP_Insert, ShiftMask, "\033[4l", -1, 0, 0}, { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
{ XK_KP_Insert, ControlMask, "\033[L", -1, 0, 0}, { XK_KP_Insert, ControlMask, "\033[L", -1, 0},
{ XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0, 0}, { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0, 0}, { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0, 0}, { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{ XK_KP_Delete, ControlMask, "\033[M", -1, 0, 0}, { XK_KP_Delete, ControlMask, "\033[M", -1, 0},
{ XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0, 0}, { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_KP_Delete, ShiftMask, "\033[2K", -1, 0, 0}, { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{ XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0, 0}, { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0, 0}, { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0, 0}, { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0, -1}, { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\r\n", -1, 0, +1}, { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
{ XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0, 0}, { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
{ XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0, 0}, { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
{ XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0, 0}, { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
{ XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0, 0}, { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
{ XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0, 0}, { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
{ XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0, 0}, { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
{ XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0, 0}, { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
{ XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0, 0}, { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
{ XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0, 0}, { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
{ XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0, 0}, { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
{ XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0, 0}, { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
{ XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0, 0}, { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
{ XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0, 0}, { XK_Up, ShiftMask, "\033[1;2A", 0, 0},
{ XK_Up, ShiftMask, "\033[1;2A", 0, 0, 0}, { XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
{ XK_Up, Mod1Mask, "\033[1;3A", 0, 0, 0}, { XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
{ XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0, 0}, { XK_Up, ControlMask, "\033[1;5A", 0, 0},
{ XK_Up, ControlMask, "\033[1;5A", 0, 0, 0}, { XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
{ XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0, 0}, { XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
{ XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0, 0}, { XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
{ XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0, 0}, { XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
{ XK_Up, XK_ANY_MOD, "\033[A", 0, -1, 0}, { XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
{ XK_Up, XK_ANY_MOD, "\033OA", 0, +1, 0}, { XK_Down, ShiftMask, "\033[1;2B", 0, 0},
{ XK_Down, ShiftMask, "\033[1;2B", 0, 0, 0}, { XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
{ XK_Down, Mod1Mask, "\033[1;3B", 0, 0, 0}, { XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
{ XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0, 0}, { XK_Down, ControlMask, "\033[1;5B", 0, 0},
{ XK_Down, ControlMask, "\033[1;5B", 0, 0, 0}, { XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
{ XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0, 0}, { XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
{ XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0, 0}, { XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
{ XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0, 0}, { XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
{ XK_Down, XK_ANY_MOD, "\033[B", 0, -1, 0}, { XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
{ XK_Down, XK_ANY_MOD, "\033OB", 0, +1, 0}, { XK_Left, ShiftMask, "\033[1;2D", 0, 0},
{ XK_Left, ShiftMask, "\033[1;2D", 0, 0, 0}, { XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
{ XK_Left, Mod1Mask, "\033[1;3D", 0, 0, 0}, { XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
{ XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0, 0}, { XK_Left, ControlMask, "\033[1;5D", 0, 0},
{ XK_Left, ControlMask, "\033[1;5D", 0, 0, 0}, { XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
{ XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0, 0}, { XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
{ XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0, 0}, { XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
{ XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0, 0}, { XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
{ XK_Left, XK_ANY_MOD, "\033[D", 0, -1, 0}, { XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
{ XK_Left, XK_ANY_MOD, "\033OD", 0, +1, 0}, { XK_Right, ShiftMask, "\033[1;2C", 0, 0},
{ XK_Right, ShiftMask, "\033[1;2C", 0, 0, 0}, { XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
{ XK_Right, Mod1Mask, "\033[1;3C", 0, 0, 0}, { XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
{ XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0, 0}, { XK_Right, ControlMask, "\033[1;5C", 0, 0},
{ XK_Right, ControlMask, "\033[1;5C", 0, 0, 0}, { XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
{ XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0, 0}, { XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
{ XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0, 0}, { XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
{ XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0, 0}, { XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
{ XK_Right, XK_ANY_MOD, "\033[C", 0, -1, 0}, { XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
{ XK_Right, XK_ANY_MOD, "\033OC", 0, +1, 0}, { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
{ XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0, 0}, { XK_Return, Mod1Mask, "\033\r", 0, 0},
{ XK_Return, Mod1Mask, "\033\r", 0, 0, -1}, { XK_Return, XK_ANY_MOD, "\r", 0, 0},
{ XK_Return, Mod1Mask, "\033\r\n", 0, 0, +1}, { XK_Insert, ShiftMask, "\033[4l", -1, 0},
{ XK_Return, XK_ANY_MOD, "\r", 0, 0, -1}, { XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
{ XK_Return, XK_ANY_MOD, "\r\n", 0, 0, +1}, { XK_Insert, ControlMask, "\033[L", -1, 0},
{ XK_Insert, ShiftMask, "\033[4l", -1, 0, 0}, { XK_Insert, ControlMask, "\033[2;5~", +1, 0},
{ XK_Insert, ShiftMask, "\033[2;2~", +1, 0, 0}, { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{ XK_Insert, ControlMask, "\033[L", -1, 0, 0}, { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{ XK_Insert, ControlMask, "\033[2;5~", +1, 0, 0}, { XK_Delete, ControlMask, "\033[M", -1, 0},
{ XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0, 0}, { XK_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0, 0}, { XK_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_Delete, ControlMask, "\033[M", -1, 0, 0}, { XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
{ XK_Delete, ControlMask, "\033[3;5~", +1, 0, 0}, { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_Delete, ShiftMask, "\033[2K", -1, 0, 0}, { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{ XK_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, { XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
{ XK_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, { XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
{ XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, { XK_Home, ShiftMask, "\033[2J", 0, -1},
{ XK_BackSpace, XK_NO_MOD, "\177", 0, 0, 0}, { XK_Home, ShiftMask, "\033[1;2H", 0, +1},
{ XK_BackSpace, Mod1Mask, "\033\177", 0, 0, 0}, { XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
{ XK_Home, ShiftMask, "\033[2J", 0, -1, 0}, { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{ XK_Home, ShiftMask, "\033[1;2H", 0, +1, 0}, { XK_End, ControlMask, "\033[J", -1, 0},
{ XK_Home, XK_ANY_MOD, "\033[H", 0, -1, 0}, { XK_End, ControlMask, "\033[1;5F", +1, 0},
{ XK_Home, XK_ANY_MOD, "\033[1~", 0, +1, 0}, { XK_End, ShiftMask, "\033[K", -1, 0},
{ XK_End, ControlMask, "\033[J", -1, 0, 0}, { XK_End, ShiftMask, "\033[1;2F", +1, 0},
{ XK_End, ControlMask, "\033[1;5F", +1, 0, 0}, { XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
{ XK_End, ShiftMask, "\033[K", -1, 0, 0}, { XK_Prior, ControlMask, "\033[5;5~", 0, 0},
{ XK_End, ShiftMask, "\033[1;2F", +1, 0, 0}, { XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
{ XK_End, XK_ANY_MOD, "\033[4~", 0, 0, 0}, { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{ XK_Prior, ControlMask, "\033[5;5~", 0, 0, 0}, { XK_Next, ControlMask, "\033[6;5~", 0, 0},
{ XK_Prior, ShiftMask, "\033[5;2~", 0, 0, 0}, { XK_Next, ShiftMask, "\033[6;2~", 0, 0},
{ XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0, 0}, { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{ XK_Next, ControlMask, "\033[6;5~", 0, 0, 0}, { XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
{ XK_Next, ShiftMask, "\033[6;2~", 0, 0, 0}, { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
{ XK_Next, XK_ANY_MOD, "\033[6~", 0, 0, 0}, { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
{ XK_F1, XK_NO_MOD, "\033OP" , 0, 0, 0}, { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
{ XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0, 0}, { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
{ XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0, 0}, { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
{ XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0, 0}, { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
{ XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0, 0}, { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
{ XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0, 0}, { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
{ XK_F2, XK_NO_MOD, "\033OQ" , 0, 0, 0}, { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
{ XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0, 0}, { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
{ XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0, 0}, { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
{ XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0, 0}, { XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
{ XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0, 0}, { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
{ XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0, 0}, { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
{ XK_F3, XK_NO_MOD, "\033OR" , 0, 0, 0}, { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
{ XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0, 0}, { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
{ XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0, 0}, { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
{ XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0, 0}, { XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
{ XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0, 0}, { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
{ XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0, 0}, { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
{ XK_F4, XK_NO_MOD, "\033OS" , 0, 0, 0}, { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
{ XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0, 0}, { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
{ XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0, 0}, { XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
{ XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0, 0}, { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
{ XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0, 0}, { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
{ XK_F5, XK_NO_MOD, "\033[15~", 0, 0, 0}, { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
{ XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0, 0}, { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
{ XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0, 0}, { XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
{ XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0, 0}, { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
{ XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0, 0}, { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
{ XK_F6, XK_NO_MOD, "\033[17~", 0, 0, 0}, { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
{ XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0, 0}, { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
{ XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0, 0}, { XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
{ XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0, 0}, { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
{ XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0, 0}, { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
{ XK_F7, XK_NO_MOD, "\033[18~", 0, 0, 0}, { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
{ XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0, 0}, { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
{ XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0, 0}, { XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
{ XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0, 0}, { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
{ XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0, 0}, { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
{ XK_F8, XK_NO_MOD, "\033[19~", 0, 0, 0}, { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
{ XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0, 0}, { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
{ XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0, 0}, { XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
{ XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0, 0}, { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
{ XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0, 0}, { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
{ XK_F9, XK_NO_MOD, "\033[20~", 0, 0, 0}, { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
{ XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0, 0}, { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
{ XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0, 0}, { XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
{ XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0, 0}, { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
{ XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0, 0}, { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
{ XK_F10, XK_NO_MOD, "\033[21~", 0, 0, 0}, { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
{ XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0, 0}, { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
{ XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0, 0}, { XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
{ XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0, 0}, { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
{ XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0, 0}, { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
{ XK_F11, XK_NO_MOD, "\033[23~", 0, 0, 0}, { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
{ XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0, 0}, { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
{ XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0, 0}, { XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
{ XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0, 0}, { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
{ XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0, 0}, { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
{ XK_F12, XK_NO_MOD, "\033[24~", 0, 0, 0}, { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
{ XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0, 0}, { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
{ XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0, 0}, { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
{ XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0, 0}, { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
{ XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0, 0}, { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
{ XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0, 0}, { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
{ XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0, 0}, { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
{ XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0, 0}, { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
{ XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0, 0}, { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
{ XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0, 0}, { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
{ XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0, 0}, { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
{ XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0, 0}, { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
{ XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0, 0}, { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
{ XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0, 0}, { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
{ XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0, 0}, { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
{ XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0, 0}, { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
{ XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0, 0}, { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
{ XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0, 0}, { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
{ XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0, 0}, { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
{ XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0, 0}, { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
{ XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0, 0}, { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
{ XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0, 0}, { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
{ XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0, 0}, { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
{ XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0, 0}, { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
{ XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0, 0}, { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
{ XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0, 0},
{ XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0, 0},
{ XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0, 0},
}; };
/* /*
@ -451,7 +514,7 @@ static Key key[] = {
* ButtonRelease and MotionNotify. * ButtonRelease and MotionNotify.
* If no match is found, regular selection is used. * If no match is found, regular selection is used.
*/ */
uint selmasks[] = { static uint selmasks[] = {
[SEL_RECTANGULAR] = Mod1Mask, [SEL_RECTANGULAR] = Mod1Mask,
}; };
@ -459,8 +522,7 @@ uint selmasks[] = {
* Printable characters in ASCII, used to estimate the advance width * Printable characters in ASCII, used to estimate the advance width
* of single wide characters. * of single wide characters.
*/ */
char ascii_printable[] = static char ascii_printable[] =
" !\"#$%&'()*+,-./0123456789:;<=>?" " !\"#$%&'()*+,-./0123456789:;<=>?"
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
"`abcdefghijklmnopqrstuvwxyz{|}~"; "`abcdefghijklmnopqrstuvwxyz{|}~";

View File

@ -1,28 +1,39 @@
# st version # st version
VERSION = 0.7 VERSION = 0.9
# Customize below to fit your system # Customize below to fit your system
# paths # paths
PREFIX = /usr/local PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man APPPREFIX = $(PREFIX)/share/applications
MANPREFIX = $(PREFIX)/share/man
X11INC = /usr/X11R6/include X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib X11LIB = /usr/X11R6/lib
PKG_CONFIG = pkg-config
# includes and libs # includes and libs
INCS = -I. -I/usr/include -I${X11INC} \ INCS = -I$(X11INC) \
`pkg-config --cflags fontconfig` \ `$(PKG_CONFIG) --cflags fontconfig` \
`pkg-config --cflags freetype2` `$(PKG_CONFIG) --cflags freetype2` \
LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXft \ `$(PKG_CONFIG) --cflags harfbuzz`
`pkg-config --libs fontconfig` \ LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender \
`pkg-config --libs freetype2` `$(PKG_CONFIG) --libs fontconfig` \
`$(PKG_CONFIG) --libs freetype2` \
`$(PKG_CONFIG) --libs harfbuzz`
# flags # flags
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_XOPEN_SOURCE=600 STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
CFLAGS += -g -std=c99 -pedantic -Wall -Wvariadic-macros -Os ${INCS} ${CPPFLAGS} STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
LDFLAGS += -g ${LIBS} 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`
#MANPREFIX = ${PREFIX}/man
# compiler and linker # compiler and linker
# CC = cc # CC = c99

124
hb.c Normal file
View File

@ -0,0 +1,124 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <X11/Xft/Xft.h>
#include <X11/cursorfont.h>
#include <hb.h>
#include <hb-ft.h>
#include "st.h"
#include "hb.h"
#define FEATURE(c1,c2,c3,c4) { .tag = HB_TAG(c1,c2,c3,c4), .value = 1, .start = HB_FEATURE_GLOBAL_START, .end = HB_FEATURE_GLOBAL_END }
#define BUFFER_STEP 256
hb_font_t *hbfindfont(XftFont *match);
typedef struct {
XftFont *match;
hb_font_t *font;
} HbFontMatch;
typedef struct {
size_t capacity;
HbFontMatch *fonts;
} HbFontCache;
static HbFontCache hbfontcache = { 0, NULL };
typedef struct {
size_t capacity;
Rune *runes;
} RuneBuffer;
static RuneBuffer hbrunebuffer = { 0, NULL };
/*
* Poplulate the array with a list of font features, wrapped in FEATURE macro,
* e. g.
* FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
*/
hb_feature_t features[] = { };
void
hbunloadfonts()
{
for (int i = 0; i < hbfontcache.capacity; i++) {
hb_font_destroy(hbfontcache.fonts[i].font);
XftUnlockFace(hbfontcache.fonts[i].match);
}
if (hbfontcache.fonts != NULL) {
free(hbfontcache.fonts);
hbfontcache.fonts = NULL;
}
hbfontcache.capacity = 0;
}
hb_font_t *
hbfindfont(XftFont *match)
{
for (int i = 0; i < hbfontcache.capacity; i++) {
if (hbfontcache.fonts[i].match == match)
return hbfontcache.fonts[i].font;
}
/* Font not found in cache, caching it now. */
hbfontcache.fonts = realloc(hbfontcache.fonts, sizeof(HbFontMatch) * (hbfontcache.capacity + 1));
FT_Face face = XftLockFace(match);
hb_font_t *font = hb_ft_font_create(face, NULL);
if (font == NULL)
die("Failed to load Harfbuzz font.");
hbfontcache.fonts[hbfontcache.capacity].match = match;
hbfontcache.fonts[hbfontcache.capacity].font = font;
hbfontcache.capacity += 1;
return font;
}
void hbtransform(HbTransformData *data, XftFont *xfont, const Glyph *glyphs, int start, int length) {
ushort mode = USHRT_MAX;
unsigned int glyph_count;
int rune_idx, glyph_idx, end = start + length;
hb_font_t *font = hbfindfont(xfont);
if (font == NULL)
return;
hb_buffer_t *buffer = hb_buffer_create();
hb_buffer_set_direction(buffer, HB_DIRECTION_LTR);
/* Resize the buffer if required length is larger. */
if (hbrunebuffer.capacity < length) {
hbrunebuffer.capacity = (length / BUFFER_STEP + 1) * BUFFER_STEP;
hbrunebuffer.runes = realloc(hbrunebuffer.runes, hbrunebuffer.capacity * sizeof(Rune));
}
/* Fill buffer with codepoints. */
for (rune_idx = 0, glyph_idx = start; glyph_idx < end; glyph_idx++, rune_idx++) {
hbrunebuffer.runes[rune_idx] = glyphs[glyph_idx].u;
mode = glyphs[glyph_idx].mode;
if (mode & ATTR_WDUMMY)
hbrunebuffer.runes[rune_idx] = 0x0020;
}
hb_buffer_add_codepoints(buffer, hbrunebuffer.runes, length, 0, length);
/* Shape the segment. */
hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
/* Get new glyph info. */
hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, &glyph_count);
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions(buffer, &glyph_count);
/* Fill the output. */
data->buffer = buffer;
data->glyphs = info;
data->positions = pos;
data->count = glyph_count;
}
void hbcleanup(HbTransformData *data) {
hb_buffer_destroy(data->buffer);
memset(data, 0, sizeof(HbTransformData));
}

14
hb.h Normal file
View File

@ -0,0 +1,14 @@
#include <X11/Xft/Xft.h>
#include <hb.h>
#include <hb-ft.h>
typedef struct {
hb_buffer_t *buffer;
hb_glyph_info_t *glyphs;
hb_glyph_position_t *positions;
unsigned int count;
} HbTransformData;
void hbunloadfonts();
void hbtransform(HbTransformData *, XftFont *, const Glyph *, int, int);
void hbcleanup(HbTransformData *);

24
st.1
View File

@ -120,7 +120,7 @@ st executes
instead of the shell. If this is used it instead of the shell. If this is used it
.B must be the last option .B must be the last option
on the command line, as in xterm / rxvt. on the command line, as in xterm / rxvt.
This option is only intended for compability, This option is only intended for compatibility,
and all the remaining arguments are used as a command and all the remaining arguments are used as a command
even without it. even without it.
.SH SHORTCUTS .SH SHORTCUTS
@ -142,30 +142,23 @@ Print the full screen to the
Print the selection to the Print the selection to the
.I iofile. .I iofile.
.TP .TP
.B Alt-Shift-Page Up .B Ctrl-Shift-Page Up
Increase font size. Increase font size.
.TP .TP
.B Alt-Shift-Page Down .B Ctrl-Shift-Page Down
Decrease font size. Decrease font size.
.TP .TP
.B Alt-Shift-Home .B Ctrl-Shift-Home
Reset to default font size. Reset to default font size.
.TP .TP
.B Shift-Insert .B Ctrl-Shift-y
Paste from primary selection (middle mouse button). Paste from primary selection (middle mouse button).
.TP .TP
.B Alt-Shift-Insert .B Ctrl-Shift-c
Paste from clipboard selection.
.TP
.B Alt-Shift-c
Copy the selected text to the clipboard selection. Copy the selected text to the clipboard selection.
.TP .TP
.B Alt-Shift-v .B Ctrl-Shift-v
Paste from the clipboard selection. Paste from the clipboard selection.
.TP
.B Alt-Ctrl
Launch dmenu to enter a unicode codepoint and send the corresponding glyph
to st.
.SH CUSTOMIZATION .SH CUSTOMIZATION
.B st .B st
can be customized by creating a custom config.h and (re)compiling the source can be customized by creating a custom config.h and (re)compiling the source
@ -177,7 +170,8 @@ See the LICENSE file for the terms of redistribution.
.SH SEE ALSO .SH SEE ALSO
.BR tabbed (1), .BR tabbed (1),
.BR utmp (1), .BR utmp (1),
.BR stty (1) .BR stty (1),
.BR scroll (1)
.SH BUGS .SH BUGS
See the TODO file in the distribution. See the TODO file in the distribution.

1234
st.c

File diff suppressed because it is too large Load Diff

12
st.desktop Normal file
View File

@ -0,0 +1,12 @@
[Desktop Entry]
Type=Application
Exec=st
TryExec=st
Icon=utilities-terminal
Terminal=false
Categories=System;TerminalEmulator;
Name=st
GenericName=Terminal
Comment=st is a simple terminal implementation for X
StartupWMClass=st-256color

209
st.h
View File

@ -1,7 +1,7 @@
/* See LICENSE for license details. */ /* See LICENSE for license details. */
/* Arbitrary sizes */ #include <stdint.h>
#define UTF_SIZ 4 #include <sys/types.h>
/* macros */ /* macros */
#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b))
@ -9,10 +9,11 @@
#define LEN(a) (sizeof(a) / sizeof(a)[0]) #define LEN(a) (sizeof(a) / sizeof(a)[0])
#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \ #define ATTRCMP(a, b) (((a).mode & (~ATTR_WRAP)) != ((b).mode & (~ATTR_WRAP)) || \
(a).fg != (b).fg || \
(a).bg != (b).bg) (a).bg != (b).bg)
#define IS_SET(flag) ((term.mode & (flag)) != 0)
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \ #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
(t1.tv_nsec-t2.tv_nsec)/1E6) (t1.tv_nsec-t2.tv_nsec)/1E6)
#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit))) #define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
@ -36,34 +37,6 @@ enum glyph_attribute {
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
}; };
enum term_mode {
MODE_WRAP = 1 << 0,
MODE_INSERT = 1 << 1,
MODE_APPKEYPAD = 1 << 2,
MODE_ALTSCREEN = 1 << 3,
MODE_CRLF = 1 << 4,
MODE_MOUSEBTN = 1 << 5,
MODE_MOUSEMOTION = 1 << 6,
MODE_REVERSE = 1 << 7,
MODE_KBDLOCK = 1 << 8,
MODE_HIDE = 1 << 9,
MODE_ECHO = 1 << 10,
MODE_APPCURSOR = 1 << 11,
MODE_MOUSESGR = 1 << 12,
MODE_8BIT = 1 << 13,
MODE_BLINK = 1 << 14,
MODE_FBLINK = 1 << 15,
MODE_FOCUS = 1 << 16,
MODE_MOUSEX10 = 1 << 17,
MODE_MOUSEMANY = 1 << 18,
MODE_BRCKTPASTE = 1 << 19,
MODE_PRINT = 1 << 20,
MODE_UTF8 = 1 << 21,
MODE_SIXEL = 1 << 22,
MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
|MODE_MOUSEMANY,
};
enum selection_mode { enum selection_mode {
SEL_IDLE = 0, SEL_IDLE = 0,
SEL_EMPTY = 1, SEL_EMPTY = 1,
@ -80,11 +53,6 @@ enum selection_snap {
SNAP_LINE = 2 SNAP_LINE = 2
}; };
enum window_state {
WIN_VISIBLE = 1,
WIN_FOCUSED = 2
};
typedef unsigned char uchar; typedef unsigned char uchar;
typedef unsigned int uint; typedef unsigned int uint;
typedef unsigned long ulong; typedef unsigned long ulong;
@ -92,6 +60,7 @@ typedef unsigned short ushort;
typedef uint_least32_t Rune; typedef uint_least32_t Rune;
#define Glyph Glyph_
typedef struct { typedef struct {
Rune u; /* character code */ Rune u; /* character code */
ushort mode; /* attribute flags */ ushort mode; /* attribute flags */
@ -101,172 +70,62 @@ typedef struct {
typedef Glyph *Line; typedef Glyph *Line;
typedef struct {
Glyph attr; /* current char attributes */
int x;
int y;
char state;
} TCursor;
/* Internal representation of the screen */
typedef struct {
int row; /* nb row */
int col; /* nb col */
Line *line; /* screen */
Line *alt; /* alternate screen */
int *dirty; /* dirtyness of lines */
GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
TCursor c; /* cursor */
int top; /* top scroll limit */
int bot; /* bottom scroll limit */
int mode; /* terminal mode flags */
int esc; /* escape state flags */
char trantbl[4]; /* charset table translation */
int charset; /* current charset */
int icharset; /* selected charset for sequence */
int numlock; /* lock numbers in keyboard */
int *tabs;
} Term;
/* Purely graphic info */
typedef struct {
int tw, th; /* tty width and height */
int w, h; /* window width and height */
int ch; /* char height */
int cw; /* char width */
char state; /* focus, redraw, visible */
int cursor; /* cursor style */
} TermWindow;
typedef struct {
uint b;
uint mask;
char *s;
} MouseShortcut;
typedef struct {
int mode;
int type;
int snap;
/*
* Selection variables:
* nb normalized coordinates of the beginning of the selection
* ne normalized coordinates of the end of the selection
* ob original coordinates of the beginning of the selection
* oe original coordinates of the end of the selection
*/
struct {
int x, y;
} nb, ne, ob, oe;
char *primary, *clipboard;
int alt;
struct timespec tclick1;
struct timespec tclick2;
//Atom xtarget;
} Selection;
typedef union { typedef union {
int i; int i;
uint ui; uint ui;
float f; float f;
const void *v; const void *v;
const char *s;
} Arg; } Arg;
typedef struct {
uint mod;
KeySym keysym;
void (*func)(const Arg *);
const Arg arg;
} Shortcut;
void die(const char *, ...); void die(const char *, ...);
void redraw(void); void redraw(void);
void draw(void);
void kscrolldown(const Arg *);
void kscrollup(const Arg *);
void printscreen(const Arg *);
void printsel(const Arg *);
void sendbreak(const Arg *);
void toggleprinter(const Arg *);
void copyurl(const Arg *);
int tattrset(int); int tattrset(int);
void tnew(int, int); void tnew(int, int);
void tsetdirt(int, int); void tresize(int, int);
void tsetdirtattr(int); void tsetdirtattr(int);
int match(uint, uint); void ttyhangup(void);
void ttynew(void); int ttynew(const char *, char *, const char *, char **);
size_t ttyread(void); size_t ttyread(void);
void ttyresize(void); void ttyresize(int, int);
void ttysend(char *, size_t); void ttywrite(const char *, size_t, int);
void ttywrite(const char *, size_t);
void resettitle(void); void resettitle(void);
char *kmap(KeySym, uint);
void cresize(int, int);
void selclear(void); void selclear(void);
void selinit(void); void selinit(void);
void selnormalize(void); void selstart(int, int, int);
void selextend(int, int, int, int);
int selected(int, int); int selected(int, int);
char *getsel(void); char *getsel(void);
int x2col(int);
int y2row(int);
size_t utf8decode(char *, Rune *, size_t);
size_t utf8encode(Rune, char *); size_t utf8encode(Rune, char *);
void *xmalloc(size_t); void *xmalloc(size_t);
char *xstrdup(char *); void *xrealloc(void *, size_t);
char *xstrdup(const char *);
void usage(void);
/* Globals */
extern TermWindow win;
extern Term term;
extern Selection sel;
extern int cmdfd;
extern pid_t pid;
extern char **opt_cmd;
extern char *opt_class;
extern char *opt_embed;
extern char *opt_font;
extern char *opt_io;
extern char *opt_line;
extern char *opt_name;
extern char *opt_title;
extern int oldbutton;
extern char *usedfont;
extern double usedfontsize;
extern double defaultfontsize;
/* config.h globals */ /* config.h globals */
extern char font[]; extern char *utmp;
extern int borderpx; extern char *scroll;
extern float cwscale; extern char *stty_args;
extern float chscale; extern char *vtiden;
extern unsigned int doubleclicktimeout; extern wchar_t *worddelimiters;
extern unsigned int tripleclicktimeout;
extern int allowaltscreen; extern int allowaltscreen;
extern unsigned int xfps; extern int allowwindowops;
extern unsigned int actionfps; extern char *termname;
extern unsigned int cursorthickness; extern unsigned int tabspaces;
extern unsigned int blinktimeout;
extern char termname[];
extern const char *colorname[];
extern size_t colornamelen;
extern unsigned int defaultfg; extern unsigned int defaultfg;
extern unsigned int defaultbg; extern unsigned int defaultbg;
extern unsigned int defaultcs; extern unsigned int defaultcs;
extern unsigned int defaultrcs; extern float alpha;
extern unsigned int cursorshape;
extern unsigned int cols;
extern unsigned int rows;
extern unsigned int mouseshape;
extern unsigned int mousefg;
extern unsigned int mousebg;
extern unsigned int defaultattr;
extern MouseShortcut mshortcuts[];
extern size_t mshortcutslen;
extern Shortcut shortcuts[];
extern size_t shortcutslen;
extern uint forceselmod;
extern uint selmasks[];
extern size_t selmaskslen;
extern char ascii_printable[];

48
st.info
View File

@ -1,4 +1,4 @@
st| simpleterm, st-mono| simpleterm monocolor,
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
am, am,
bce, bce,
@ -10,7 +10,7 @@ st| simpleterm,
civis=\E[?25l, civis=\E[?25l,
clear=\E[H\E[2J, clear=\E[H\E[2J,
cnorm=\E[?12l\E[?25h, cnorm=\E[?12l\E[?25h,
colors#8, colors#2,
cols#80, cols#80,
cr=^M, cr=^M,
csr=\E[%i%p1%d;%p2%dr, csr=\E[%i%p1%d;%p2%dr,
@ -25,6 +25,7 @@ st| simpleterm,
cuu=\E[%p1%dA, cuu=\E[%p1%dA,
dch=\E[%p1%dP, dch=\E[%p1%dP,
dch1=\E[P, dch1=\E[P,
dim=\E[2m,
dl=\E[%p1%dM, dl=\E[%p1%dM,
dl1=\E[M, dl1=\E[M,
ech=\E[%p1%dX, ech=\E[%p1%dX,
@ -142,7 +143,6 @@ st| simpleterm,
khome=\E[1~, khome=\E[1~,
kil1=\E[2;5~, kil1=\E[2;5~,
krmir=\E[2;2~, krmir=\E[2;2~,
kich1=\E[2~,
knp=\E[6~, knp=\E[6~,
kmous=\E[M, kmous=\E[M,
kpp=\E[5~, kpp=\E[5~,
@ -158,6 +158,7 @@ st| simpleterm,
rc=\E8, rc=\E8,
rev=\E[7m, rev=\E[7m,
ri=\EM, ri=\EM,
rin=\E[%p1%dT,
ritm=\E[23m, ritm=\E[23m,
rmacs=\E(B, rmacs=\E(B,
rmcup=\E[?1049l, rmcup=\E[?1049l,
@ -168,13 +169,8 @@ st| simpleterm,
rs1=\Ec, rs1=\Ec,
rs2=\E[4l\E>\E[?1034l, rs2=\E[4l\E>\E[?1034l,
sc=\E7, sc=\E7,
setab=\E[4%p1%dm,
setaf=\E[3%p1%dm,
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
sgr0=\E[0m,
sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
sitm=\E[3m, sitm=\E[3m,
sgr0=\E[0m,
smacs=\E(0, smacs=\E(0,
smcup=\E[?1049h, smcup=\E[?1049h,
smir=\E[4h, smir=\E[4h,
@ -185,16 +181,34 @@ st| simpleterm,
tsl=\E]0;, tsl=\E]0;,
xenl, xenl,
vpa=\E[%i%p1%dd, vpa=\E[%i%p1%dd,
# Tmux unofficial extensions, see TERMINFO EXTENSIONS in tmux(1) # XTerm extensions
Se, rmxx=\E[29m,
Ss, 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, Tc,
Ms=\E]52;%p1%s;%p2%s\007,
Se=\E[2 q,
Ss=\E[%p1%d q,
st| simpleterm,
use=st-mono,
colors#8,
setab=\E[4%p1%dm,
setaf=\E[3%p1%dm,
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
st-256color| simpleterm with 256 colors, st-256color| simpleterm with 256 colors,
use=st, use=st,
ccc,
colors#256, colors#256,
oc=\E]104\007,
pairs#32767, pairs#32767,
# Nicked from xterm-256color # Nicked from xterm-256color
initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m, setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m, setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
@ -213,3 +227,13 @@ st-meta-256color| simpleterm with meta key and 256 colors,
smm=\E[?1034h, smm=\E[?1034h,
rs2=\E[4l\E>\E[?1034h, rs2=\E[4l\E>\E[?1034h,
is2=\E[4l\E>\E[?1034h, is2=\E[4l\E>\E[?1034h,
st-bs| simpleterm with backspace as backspace,
use=st,
kbs=\010,
kdch1=\177,
st-bs-256color| simpleterm with backspace as backspace and 256colors,
use=st-256color,
kbs=\010,
kdch1=\177,

54
win.h
View File

@ -1,29 +1,41 @@
/* See LICENSE for license details. */ /* See LICENSE for license details. */
/* X modifiers */ enum win_mode {
#define XK_ANY_MOD UINT_MAX MODE_VISIBLE = 1 << 0,
#define XK_NO_MOD 0 MODE_FOCUSED = 1 << 1,
#define XK_SWITCH_MOD (1<<13) MODE_APPKEYPAD = 1 << 2,
MODE_MOUSEBTN = 1 << 3,
MODE_MOUSEMOTION = 1 << 4,
MODE_REVERSE = 1 << 5,
MODE_KBDLOCK = 1 << 6,
MODE_HIDE = 1 << 7,
MODE_APPCURSOR = 1 << 8,
MODE_MOUSESGR = 1 << 9,
MODE_8BIT = 1 << 10,
MODE_BLINK = 1 << 11,
MODE_FBLINK = 1 << 12,
MODE_FOCUS = 1 << 13,
MODE_MOUSEX10 = 1 << 14,
MODE_MOUSEMANY = 1 << 15,
MODE_BRCKTPASTE = 1 << 16,
MODE_NUMLOCK = 1 << 17,
MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
|MODE_MOUSEMANY,
};
typedef XftGlyphFontSpec GlyphFontSpec; void xbell(void);
void draw(void);
void drawregion(int, int, int, int);
void run(void);
void xbell(int);
void xclipcopy(void); void xclipcopy(void);
void xclippaste(void); void xdrawcursor(int, int, Glyph, int, int, Glyph, Line, int);
void xhints(void); void xdrawline(Line, int, int, int);
void xinit(void); void xfinishdraw(void);
void xloadcols(void); void xloadcols(void);
int xsetcolorname(int, const char *); int xsetcolorname(int, const char *);
void xloadfonts(char *, double); int xgetcolor(int, unsigned char *, unsigned char *, unsigned char *);
void xsetenv(void); void xseticontitle(char *);
void xsettitle(char *); void xsettitle(char *);
int xsetcursor(int);
void xsetmode(int, unsigned int);
void xsetpointermotion(int); void xsetpointermotion(int);
void xseturgency(int); void xsetsel(char *);
void xunloadfonts(void); int xstartdraw(void);
void xresize(int, int); void xximspot(int, int);
void xselpaste(void);
unsigned long xwinid(void);

1399
x.c

File diff suppressed because it is too large Load Diff