Compare commits

...

180 Commits
0.7 ... master

Author SHA1 Message Date
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
Roberto E. Vargas Caballero 20f713548d Change default keybindings
CTRL+SHIFT is an impossible combination in the terminal world
(0x20 | x & 0x1F), so it is perfect to be used for internals
shortcuts of terminals, and being a double combination
reduces the prossibility of having comflicts.
2017-01-25 19:17:38 +01:00
Michael Forney e2ee5ee611 Split X-specific code into x.c 2017-01-20 19:42:26 -08:00
fpqc c63a87cd93 Move column and row default numbers into config.h 2016-12-16 10:50:23 +01:00
Roberto E. Vargas Caballero e44832408b Revert "Initial font size issue."
This reverts commit 424202798b.
2016-11-24 20:21:19 +01:00
Spencer Phippen fa9a459972 Fixed 'missing glyph doesn't use fontconfig config substitutions' bug
XftFontMatch does display-specific font configuration (commit 528241a).
Nice. Unfortunately, when we switched from FcFontMatch, we also stopped
storing the post-Fc{Config,Default}Substitute FcPattern for future
lookups. The result is that if a glyph isn't found in the primary font,
secondary font lookups use the original FcPattern, not the configured
one. If you have custom fontconfig rules (like me), this can be
disappointing.

I basically just copied the guts out of XftFontMatch[1] and saved
the intermediate configured FcPattern. Could be related to the bug that
inspired commit 4242027.

[1]: https://cgit.freedesktop.org/xorg/lib/libXft/tree/src/xftfont.c
2016-11-24 20:20:45 +01:00
Manuel Tobias Schiller 740ada1447 make the various combinations of arrow keys and shift/control/meta work
When using st with screen, I've bound next, prev, new screen to
combinations like Ctrl-Alt-Right,Left,Down; xterm and (u)rxvt work fine
when this combination of modifiers is pressed, st does not seem to
transport all of them; a single modifier key is fine (e.g. Ctrl-Up,
Alt-Down etc., but combinations are not). While I'm not terribly
familiar with this, I have tried to hack config.h in a more or less
systematic way to generate the expected sequences.
2016-11-14 19:58:02 +01:00
ian@remmler.org 424202798b Initial font size issue.
Hi,

When I specify a font by point size (I'm using "Inconsolata:size=12"),
characters that are substituted from another font because they are not in the
main one appear too small.  Doing a zoom reset fixes it.  For example:

Before: http://i.imgur.com/G4Mfv4X.png
After:  http://i.imgur.com/PMDhfQA.png

I found that adding the pixel size (acquired from the initial font load) to the
pattern then reloading the font fixes the problem.  I'm not sure if this is a
proper fix, though.
2016-11-14 19:27:55 +01:00
pl@ninthfloor.org 3ca7249c86 tic -s -> tic -sx (Treat unknown capabilities as user-defined.) 2016-11-14 19:05:47 +01:00
pl@ninthfloor.org 06f8cf8ca8 Add tmux capabilities to st.info 2016-11-14 19:05:11 +01:00
pl@ninthfloor.org 902a392b90 Make strdump(), csidump(), print to stderr
The two functions strdump(), csidump() are called to show errors and
their output is introduced by a message printed to stderr. Thus, it it
more consistent to have them print to stderr.

Moreover stderr is unbuffered (at least on Linux), making problems
immediately visible.
2016-11-14 18:36:38 +01:00
Quentin Rameau 8c99915608 Do not use color when font attributes are supported
If fontconfig gives us a font without the attributes we asked for,
display an alternative color instead.
2016-10-23 17:56:46 +02:00
Quentin Rameau 7854fde1ff st.1: add an entry for ISO-14755 shortcut 2016-10-22 10:43:18 +02:00
Quentin Rameau 68bae9c7b1 Add support for iso14755
We launch dmenu for getting a codepoint, then convert it and send it to
the terminal.
2016-10-18 13:32:36 +02:00
Klemens Nanni 331033f1f6 Add missing device path to '-l' example
Also, it's ttyS0 not ttySO.
2016-10-13 17:25:17 +02:00
Roberto E. Vargas Caballero f7398434b8 Add parsing of DCS q sequences
These sequences are used to operate with sixels, but they are still
str sequences, so they are finished with \a, ST or with a C1 control
code. This patch also disables utf8 handling for the case of sixels.
2016-09-14 08:27:32 +02:00
Roberto E. Vargas Caballero f0e2d28732 Add support for enabling/disabling utf
There are some ocasions where we want to disable the enconding/decoding of utf8, mainly
because it adds an important overhead. This is partial patch for ESC % G and ESC % @,
where they modified the way that st reads and write from/to the serial line, but it does
not modifies how it interacts with the X window part.
2016-09-13 14:01:18 +02:00
Roberto E. Vargas Caballero 078337d745 Delete ncv capability from terminfo
We do not need to disable the previous ncv definition, because
there is not previous definition.
2016-09-09 13:11:06 +02:00
Quentin Rameau 5ce853a1c1 st.info: do not prevent st from displaying attributes
With ncv set to 3, we prevent st from displaying A_STANDOUT and
A_UNDERLINE with colors while our virtual terminal is capable of it.
2016-09-09 11:05:11 +02:00
Christoph Lohmann 023225ef40 Update the LICENSE.
This is for the next release.
2016-08-11 16:30:29 +02:00
13 changed files with 3170 additions and 2620 deletions

109
FAQ
View File

@ -1,12 +1,14 @@
## 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!
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 can manualy run `tic -s st.info`.
you can manually run `tic -sx st.info`.
## Nothing works, and nothing is said about an unknown terminal!
@ -15,19 +17,21 @@ you can manualy run `tic -s st.info`.
* Some programs dont complain about the lacking st description and default to
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?
Using a terminal multiplexer.
* Using a terminal multiplexer.
* `st -e tmux` using C-b [
* `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 patch of both programs in your config.h
file. You only have to modify the value of utmp and scroll variables.
* `st -e tmux` using C-b [
* `st -e screen` using C-a ESC
## 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.
## How can I use meta in 8bit mode?
St supports meta in 8bit mode, but the default terminfo entry doesn't
use this capability. If you want it, you have to use the 'st-meta' value
in TERM.
## I cannot compile st in OpenBSD
OpenBSD lacks librt, despite it being mandatory in POSIX
@ -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
included in libc on this platform.
## The Backspace Case
St is emulating the Linux way of handling backspace being delete and delete being
backspace.
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:
Well, I am going to comment why I want to change the behaviour
@ -159,9 +166,85 @@ terminal users wants its backspace to be how he feels it:
[1] http://www.ibb.net/~anne/keyboard.html
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
## But I really want the old grumpy behaviour of my terminal
Apply [1].
[1] 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.

11
LICENSE
View File

@ -1,13 +1,16 @@
MIT/X Consortium License
© 2014-2020 Hiltjo Posthuma <hiltjo at codemadness dot org>
© 2018 Devin J. Pohly <djpohly at gmail dot com>
© 2014-2017 Quentin Rameau <quinq at fifth dot space>
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
© 2009 Anselm R Garbe <garbeam at gmail dot com>
© 2012-2015 Roberto E. Vargas Caballero <k0ga at shike2 dot com>
© 2012-2015 Christoph Lohmann <20h at r-36 dot net>
© 2008-2017 Anselm R Garbe <garbeam at gmail dot com>
© 2012-2017 Roberto E. Vargas Caballero <k0ga at shike2 dot com>
© 2012-2016 Christoph Lohmann <20h at r-36 dot net>
© 2013 Eon S. Jeon <esjeon at hyunmu dot am>
© 2013 Alexander Sedov <alex0player 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-2014 Markus Teich <markus dot teich at stusta dot mhn dot de>
© 2014-2015 Laslo Hunhold <dev at frign dot de>

View File

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

2
README
View File

@ -24,7 +24,7 @@ Running st
If you did not install st with make clean install, you must compile
the st terminfo entry with the following command:
tic -s st.info
tic -sx st.info
See the man page for additional details.

22
arg.h
View File

@ -21,28 +21,30 @@ extern char *argv0;
argc--;\
break;\
}\
for (brk_ = 0, argv[0]++, argv_ = argv;\
argv[0][0] && !brk_;\
argv[0]++) {\
int i_;\
for (i_ = 1, brk_ = 0, argv_ = argv;\
argv[0][i_] && !brk_;\
i_++) {\
if (argv_ != argv)\
break;\
argc_ = argv[0][0];\
argc_ = argv[0][i_];\
switch (argc_)
#define ARGEND }\
}
#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) :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(brk_ = 1, (argv[0][i_+1] != '\0')?\
(&argv[0][i_+1]) :\
(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 :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(brk_ = 1, (argv[0][i_+1] != '\0')?\
(&argv[0][i_+1]) :\
(argc--, argv++, argv[0])))
#endif

View File

@ -5,23 +5,25 @@
*
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
*/
static char font[] = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
static int borderpx = 2;
/*
* What program is execed by st depends of these precedence rules:
* 1: program passed with -e
* 2: utmp option
* 2: scroll and/or utmp
* 3: SHELL environment variable
* 4: value of shell in /etc/passwd
* 5: value of shell in config.h
*/
static char shell[] = "/bin/sh";
static char *utmp = NULL;
static char stty_args[] = "stty raw pass8 nl -echo -iexten -cstopb 38400";
static char *shell = "/bin/sh";
char *utmp = NULL;
/* 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 */
static char vtiden[] = "\033[?6c";
char *vtiden = "\033[?6c";
/* Kerning / character bounding-box multipliers */
static float cwscale = 1.0;
@ -30,20 +32,29 @@ static float chscale = 1.0;
/*
* word delimiter string
*
* More advanced example: " `'\"()[]{}"
* More advanced example: L" `'\"()[]{}"
*/
static char worddelimiters[] = " ";
wchar_t *worddelimiters = L" ";
/* selection timeouts (in milliseconds) */
static unsigned int doubleclicktimeout = 300;
static unsigned int tripleclicktimeout = 600;
/* alt screens */
static int allowaltscreen = 1;
int allowaltscreen = 1;
/* frames per second st should at maximum draw to the screen */
static unsigned int xfps = 120;
static unsigned int actionfps = 30;
/* allow certain non-interactive (insecure) window operations such as:
setting the clipboard text */
int allowwindowops = 0;
/*
* draw latency range in ms - from new content/keypress/etc until drawing.
* within this range, st draws when content stops arriving (idle). mostly it's
* 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
@ -63,7 +74,7 @@ static unsigned int cursorthickness = 2;
static int bellvolume = 0;
/* default TERM value */
static char termname[] = "st-256color";
char *termname = "st-256color";
/*
* spaces per tab
@ -80,7 +91,7 @@ static char termname[] = "st-256color";
*
* stty tabs
*/
static unsigned int tabspaces = 8;
unsigned int tabspaces = 8;
/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
@ -116,8 +127,8 @@ static const char *colorname[] = {
* Default colors (colorname index)
* foreground, background, cursor, reverse cursor
*/
static unsigned int defaultfg = 7;
static unsigned int defaultbg = 0;
unsigned int defaultfg = 7;
unsigned int defaultbg = 0;
static unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257;
@ -130,6 +141,13 @@ static unsigned int defaultrcs = 257;
*/
static unsigned int cursorshape = 2;
/*
* Default columns and rows numbers
*/
static unsigned int cols = 80;
static unsigned int rows = 24;
/*
* Default colour and shape of the mouse cursor
*/
@ -138,25 +156,34 @@ static unsigned int mousefg = 7;
static unsigned int mousebg = 0;
/*
* 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.
* Color used to display font attributes when fontconfig selected a font which
* doesn't match the ones requested.
*/
static unsigned int defaultitalic = 11;
static unsigned int defaultunderline = 7;
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;
/*
* Internal mouse shortcuts.
* Beware that overloading Button1 will disable the selection.
*/
static MouseShortcut mshortcuts[] = {
/* button mask string */
{ Button4, XK_ANY_MOD, "\031" },
{ Button5, XK_ANY_MOD, "\005" },
/* mask button function argument release */
{ 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. */
#define MODKEY Mod1Mask
#define TERMMOD (ControlMask|ShiftMask)
static Shortcut shortcuts[] = {
/* mask keysym function argument */
@ -164,14 +191,14 @@ static Shortcut shortcuts[] = {
{ ControlMask, XK_Print, toggleprinter, {.i = 0} },
{ ShiftMask, XK_Print, printscreen, {.i = 0} },
{ XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
{ MODKEY|ShiftMask, XK_Prior, xzoom, {.f = +1} },
{ MODKEY|ShiftMask, XK_Next, xzoom, {.f = -1} },
{ MODKEY|ShiftMask, XK_Home, xzoomreset, {.f = 0} },
{ TERMMOD, XK_Prior, zoom, {.f = +1} },
{ TERMMOD, XK_Next, zoom, {.f = -1} },
{ TERMMOD, XK_Home, zoomreset, {.f = 0} },
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
{ TERMMOD, XK_V, clippaste, {.i = 0} },
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
{ MODKEY|ShiftMask, XK_Insert, clippaste, {.i = 0} },
{ MODKEY|ShiftMask, XK_C, clipcopy, {.i = 0} },
{ MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} },
{ MODKEY, XK_Num_Lock, numlock, {.i = 0} },
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
};
/*
@ -189,10 +216,6 @@ static Shortcut shortcuts[] = {
* * 0: no value
* * > 0: cursor application mode enabled
* * < 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
* this table sequentially, so any XK_ANY_MOD must be in the last
@ -211,215 +234,221 @@ static KeySym mappedkeys[] = { -1 };
*/
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.
*/
static uint forceselmod = ShiftMask;
/*
* This is the huge key array which defines all compatibility to the Linux
* world. Please decide about changes wisely.
*/
static Key key[] = {
/* keysym mask string appkey appcursor crlf */
{ XK_KP_Home, ShiftMask, "\033[2J", 0, -1, 0},
{ XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1, 0},
{ XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1, 0},
{ XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1, 0},
{ XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0, 0},
{ XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0, 0},
{ XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0, 0},
{ XK_KP_End, ControlMask, "\033[J", -1, 0, 0},
{ XK_KP_End, ControlMask, "\033[1;5F", +1, 0, 0},
{ XK_KP_End, ShiftMask, "\033[K", -1, 0, 0},
{ XK_KP_End, ShiftMask, "\033[1;2F", +1, 0, 0},
{ XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0, 0},
{ XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0, 0},
{ XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0, 0},
{ XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0, 0},
{ XK_KP_Insert, ShiftMask, "\033[4l", -1, 0, 0},
{ XK_KP_Insert, ControlMask, "\033[L", -1, 0, 0},
{ XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0, 0},
{ XK_KP_Delete, ControlMask, "\033[M", -1, 0, 0},
{ XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0, 0},
{ XK_KP_Delete, ShiftMask, "\033[2K", -1, 0, 0},
{ XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0},
{ XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0, 0},
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0, -1},
{ XK_KP_Enter, XK_ANY_MOD, "\r\n", -1, 0, +1},
{ XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0, 0},
{ XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0, 0},
{ XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0, 0},
{ XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0, 0},
{ XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0, 0},
{ XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0, 0},
{ XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0, 0},
{ XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0, 0},
{ XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0, 0},
{ XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0, 0},
{ XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0, 0},
{ XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0, 0},
{ XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0, 0},
{ XK_Up, ShiftMask, "\033[1;2A", 0, 0, 0},
{ XK_Up, ControlMask, "\033[1;5A", 0, 0, 0},
{ XK_Up, Mod1Mask, "\033[1;3A", 0, 0, 0},
{ XK_Up, XK_ANY_MOD, "\033[A", 0, -1, 0},
{ XK_Up, XK_ANY_MOD, "\033OA", 0, +1, 0},
{ XK_Down, ShiftMask, "\033[1;2B", 0, 0, 0},
{ XK_Down, ControlMask, "\033[1;5B", 0, 0, 0},
{ XK_Down, Mod1Mask, "\033[1;3B", 0, 0, 0},
{ XK_Down, XK_ANY_MOD, "\033[B", 0, -1, 0},
{ XK_Down, XK_ANY_MOD, "\033OB", 0, +1, 0},
{ XK_Left, ShiftMask, "\033[1;2D", 0, 0, 0},
{ XK_Left, ControlMask, "\033[1;5D", 0, 0, 0},
{ XK_Left, Mod1Mask, "\033[1;3D", 0, 0, 0},
{ XK_Left, XK_ANY_MOD, "\033[D", 0, -1, 0},
{ XK_Left, XK_ANY_MOD, "\033OD", 0, +1, 0},
{ XK_Right, ShiftMask, "\033[1;2C", 0, 0, 0},
{ XK_Right, ControlMask, "\033[1;5C", 0, 0, 0},
{ XK_Right, Mod1Mask, "\033[1;3C", 0, 0, 0},
{ XK_Right, XK_ANY_MOD, "\033[C", 0, -1, 0},
{ XK_Right, XK_ANY_MOD, "\033OC", 0, +1, 0},
{ XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0, 0},
{ XK_Return, Mod1Mask, "\033\r", 0, 0, -1},
{ XK_Return, Mod1Mask, "\033\r\n", 0, 0, +1},
{ XK_Return, XK_ANY_MOD, "\r", 0, 0, -1},
{ XK_Return, XK_ANY_MOD, "\r\n", 0, 0, +1},
{ XK_Insert, ShiftMask, "\033[4l", -1, 0, 0},
{ XK_Insert, ShiftMask, "\033[2;2~", +1, 0, 0},
{ XK_Insert, ControlMask, "\033[L", -1, 0, 0},
{ XK_Insert, ControlMask, "\033[2;5~", +1, 0, 0},
{ XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0, 0},
{ XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0, 0},
{ XK_Delete, ControlMask, "\033[M", -1, 0, 0},
{ XK_Delete, ControlMask, "\033[3;5~", +1, 0, 0},
{ XK_Delete, ShiftMask, "\033[2K", -1, 0, 0},
{ XK_Delete, ShiftMask, "\033[3;2~", +1, 0, 0},
{ XK_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0},
{ XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0},
{ XK_BackSpace, XK_NO_MOD, "\177", 0, 0, 0},
{ XK_BackSpace, Mod1Mask, "\033\177", 0, 0, 0},
{ XK_Home, ShiftMask, "\033[2J", 0, -1, 0},
{ XK_Home, ShiftMask, "\033[1;2H", 0, +1, 0},
{ XK_Home, XK_ANY_MOD, "\033[H", 0, -1, 0},
{ XK_Home, XK_ANY_MOD, "\033[1~", 0, +1, 0},
{ XK_End, ControlMask, "\033[J", -1, 0, 0},
{ XK_End, ControlMask, "\033[1;5F", +1, 0, 0},
{ XK_End, ShiftMask, "\033[K", -1, 0, 0},
{ XK_End, ShiftMask, "\033[1;2F", +1, 0, 0},
{ XK_End, XK_ANY_MOD, "\033[4~", 0, 0, 0},
{ XK_Prior, ControlMask, "\033[5;5~", 0, 0, 0},
{ XK_Prior, ShiftMask, "\033[5;2~", 0, 0, 0},
{ XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0, 0},
{ XK_Next, ControlMask, "\033[6;5~", 0, 0, 0},
{ XK_Next, ShiftMask, "\033[6;2~", 0, 0, 0},
{ XK_Next, XK_ANY_MOD, "\033[6~", 0, 0, 0},
{ XK_F1, XK_NO_MOD, "\033OP" , 0, 0, 0},
{ XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0, 0},
{ XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0, 0},
{ XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0, 0},
{ XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0, 0},
{ XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0, 0},
{ XK_F2, XK_NO_MOD, "\033OQ" , 0, 0, 0},
{ XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0, 0},
{ XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0, 0},
{ XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0, 0},
{ XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0, 0},
{ XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0, 0},
{ XK_F3, XK_NO_MOD, "\033OR" , 0, 0, 0},
{ XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0, 0},
{ XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0, 0},
{ XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0, 0},
{ XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0, 0},
{ XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0, 0},
{ XK_F4, XK_NO_MOD, "\033OS" , 0, 0, 0},
{ XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0, 0},
{ XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0, 0},
{ XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0, 0},
{ XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0, 0},
{ XK_F5, XK_NO_MOD, "\033[15~", 0, 0, 0},
{ XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0, 0},
{ XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0, 0},
{ XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0, 0},
{ XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0, 0},
{ XK_F6, XK_NO_MOD, "\033[17~", 0, 0, 0},
{ XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0, 0},
{ XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0, 0},
{ XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0, 0},
{ XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0, 0},
{ XK_F7, XK_NO_MOD, "\033[18~", 0, 0, 0},
{ XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0, 0},
{ XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0, 0},
{ XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0, 0},
{ XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0, 0},
{ XK_F8, XK_NO_MOD, "\033[19~", 0, 0, 0},
{ XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0, 0},
{ XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0, 0},
{ XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0, 0},
{ XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0, 0},
{ XK_F9, XK_NO_MOD, "\033[20~", 0, 0, 0},
{ XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0, 0},
{ XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0, 0},
{ XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0, 0},
{ XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0, 0},
{ XK_F10, XK_NO_MOD, "\033[21~", 0, 0, 0},
{ XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0, 0},
{ XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0, 0},
{ XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0, 0},
{ XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0, 0},
{ XK_F11, XK_NO_MOD, "\033[23~", 0, 0, 0},
{ XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0, 0},
{ XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0, 0},
{ XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0, 0},
{ XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0, 0},
{ XK_F12, XK_NO_MOD, "\033[24~", 0, 0, 0},
{ XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0, 0},
{ XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0, 0},
{ XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0, 0},
{ XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0, 0},
{ XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0, 0},
{ XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0, 0},
{ XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0, 0},
{ XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0, 0},
{ XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0, 0},
{ XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0, 0},
{ XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0, 0},
{ XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0, 0},
{ XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0, 0},
{ XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0, 0},
{ XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0, 0},
{ XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0, 0},
{ XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0, 0},
{ XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0, 0},
{ XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0, 0},
{ XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0, 0},
{ XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0, 0},
{ XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0, 0},
{ XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0, 0},
{ XK_F32, XK_NO_MOD, "\033[19;5~", 0, 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},
/* keysym mask string appkey appcursor */
{ XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
{ XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
{ XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
{ XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{ XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
{ XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
{ XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
{ XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
{ XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
{ XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
{ XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
{ XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
{ XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
{ XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
{ XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
{ XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
{ XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
{ XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{ XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
{ XK_KP_End, ControlMask, "\033[J", -1, 0},
{ XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
{ XK_KP_End, ShiftMask, "\033[K", -1, 0},
{ XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
{ XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
{ XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
{ XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{ XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
{ XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
{ XK_KP_Insert, ControlMask, "\033[L", -1, 0},
{ XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{ XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{ XK_KP_Delete, ControlMask, "\033[M", -1, 0},
{ XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{ XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
{ XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
{ XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
{ XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
{ XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
{ XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
{ XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
{ XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
{ XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
{ XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
{ XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
{ XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
{ XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
{ XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
{ XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
{ XK_Up, ShiftMask, "\033[1;2A", 0, 0},
{ XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
{ XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
{ XK_Up, ControlMask, "\033[1;5A", 0, 0},
{ XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
{ XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
{ XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
{ XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
{ XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
{ XK_Down, ShiftMask, "\033[1;2B", 0, 0},
{ XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
{ XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
{ XK_Down, ControlMask, "\033[1;5B", 0, 0},
{ XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
{ XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
{ XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
{ XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
{ XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
{ XK_Left, ShiftMask, "\033[1;2D", 0, 0},
{ XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
{ XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
{ XK_Left, ControlMask, "\033[1;5D", 0, 0},
{ XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
{ XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
{ XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
{ XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
{ XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
{ XK_Right, ShiftMask, "\033[1;2C", 0, 0},
{ XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
{ XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
{ XK_Right, ControlMask, "\033[1;5C", 0, 0},
{ XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
{ XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
{ XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
{ XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
{ XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
{ XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
{ XK_Return, Mod1Mask, "\033\r", 0, 0},
{ XK_Return, XK_ANY_MOD, "\r", 0, 0},
{ XK_Insert, ShiftMask, "\033[4l", -1, 0},
{ XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
{ XK_Insert, ControlMask, "\033[L", -1, 0},
{ XK_Insert, ControlMask, "\033[2;5~", +1, 0},
{ XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
{ XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
{ XK_Delete, ControlMask, "\033[M", -1, 0},
{ XK_Delete, ControlMask, "\033[3;5~", +1, 0},
{ XK_Delete, ShiftMask, "\033[2K", -1, 0},
{ XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
{ XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
{ XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
{ XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
{ XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
{ XK_Home, ShiftMask, "\033[2J", 0, -1},
{ XK_Home, ShiftMask, "\033[1;2H", 0, +1},
{ XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
{ XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
{ XK_End, ControlMask, "\033[J", -1, 0},
{ XK_End, ControlMask, "\033[1;5F", +1, 0},
{ XK_End, ShiftMask, "\033[K", -1, 0},
{ XK_End, ShiftMask, "\033[1;2F", +1, 0},
{ XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
{ XK_Prior, ControlMask, "\033[5;5~", 0, 0},
{ XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
{ XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
{ XK_Next, ControlMask, "\033[6;5~", 0, 0},
{ XK_Next, ShiftMask, "\033[6;2~", 0, 0},
{ XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
{ XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
{ XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
{ XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
{ XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
{ XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
{ XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
{ XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
{ XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
{ XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
{ XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
{ XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
{ XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
{ XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
{ XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
{ XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
{ XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
{ XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
{ XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
{ XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
{ XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
{ XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
{ XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
{ XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
{ XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
{ XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
{ XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
{ XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
{ XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
{ XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
{ XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
{ XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
{ XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
{ XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
{ XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
{ XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
{ XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
{ XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
{ XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
{ XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
{ XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
{ XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
{ XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
{ XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
{ XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
{ XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
{ XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
{ XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
{ XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
{ XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
{ XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
{ XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
{ XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
{ XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
{ XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
{ XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
{ XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
{ XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
{ XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
{ XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
{ XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
{ XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
{ XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
{ XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
{ XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
{ XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
{ XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
{ XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
{ XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
{ XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
{ XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
{ XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
{ XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
{ XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
{ XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
{ XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
{ XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
{ XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
{ XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
{ XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
{ XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
{ XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
{ XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
{ XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
{ XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
{ XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
{ XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
};
/*
@ -441,4 +470,3 @@ static char ascii_printable[] =
" !\"#$%&'()*+,-./0123456789:;<=>?"
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
"`abcdefghijklmnopqrstuvwxyz{|}~";

View File

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

28
st.1
View File

@ -96,18 +96,18 @@ use a tty
.I line
instead of a pseudo terminal.
.I line
should be a (pseudo-)serial device (e.g. /dev/ttySO on Linux for serial port
should be a (pseudo-)serial device (e.g. /dev/ttyS0 on Linux for serial port
0).
When this flag is given
remaining arguments are used as flags for
.BR stty(1).
By default st initializes the serial line to 8 bits, no parity, 1 stop bit
and a 38400 baud rate. The speed is set by appending it as last argument
(e.g. 'st -l 115200'). Arguments before the last one are
(e.g. 'st -l /dev/ttyS0 115200'). Arguments before the last one are
.BR stty(1)
flags. If you want to set odd parity on 115200 baud use for example 'st -l
parenb parodd 115200'. Set the number of bits by using for example 'st -l cs7
115200'. See
/dev/ttyS0 parenb parodd 115200'. Set the number of bits by using for
example 'st -l /dev/ttyS0 cs7 115200'. See
.BR stty(1)
for more arguments and cases.
.TP
@ -120,7 +120,7 @@ st executes
instead of the shell. If this is used it
.B must be the last option
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
even without it.
.SH SHORTCUTS
@ -142,25 +142,22 @@ Print the full screen to the
Print the selection to the
.I iofile.
.TP
.B Alt-Shift-Page Up
.B Ctrl-Shift-Page Up
Increase font size.
.TP
.B Alt-Shift-Page Down
.B Ctrl-Shift-Page Down
Decrease font size.
.TP
.B Alt-Shift-Home
.B Ctrl-Shift-Home
Reset to default font size.
.TP
.B Shift-Insert
.B Ctrl-Shift-y
Paste from primary selection (middle mouse button).
.TP
.B Alt-Shift-Insert
Paste from clipboard selection.
.TP
.B Alt-Shift-c
.B Ctrl-Shift-c
Copy the selected text to the clipboard selection.
.TP
.B Alt-Shift-v
.B Ctrl-Shift-v
Paste from the clipboard selection.
.SH CUSTOMIZATION
.B st
@ -173,7 +170,8 @@ See the LICENSE file for the terms of redistribution.
.SH SEE ALSO
.BR tabbed (1),
.BR utmp (1),
.BR stty (1)
.BR stty (1),
.BR scroll (1)
.SH BUGS
See the TODO file in the distribution.

2755
st.c

File diff suppressed because it is too large Load Diff

125
st.h Normal file
View File

@ -0,0 +1,125 @@
/* See LICENSE for license details. */
#include <stdint.h>
#include <sys/types.h>
/* macros */
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a) / sizeof(a)[0])
#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
#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 ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \
(a).bg != (b).bg)
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
(t1.tv_nsec-t2.tv_nsec)/1E6)
#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
#define IS_TRUECOL(x) (1 << 24 & (x))
enum glyph_attribute {
ATTR_NULL = 0,
ATTR_BOLD = 1 << 0,
ATTR_FAINT = 1 << 1,
ATTR_ITALIC = 1 << 2,
ATTR_UNDERLINE = 1 << 3,
ATTR_BLINK = 1 << 4,
ATTR_REVERSE = 1 << 5,
ATTR_INVISIBLE = 1 << 6,
ATTR_STRUCK = 1 << 7,
ATTR_WRAP = 1 << 8,
ATTR_WIDE = 1 << 9,
ATTR_WDUMMY = 1 << 10,
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
};
enum selection_mode {
SEL_IDLE = 0,
SEL_EMPTY = 1,
SEL_READY = 2
};
enum selection_type {
SEL_REGULAR = 1,
SEL_RECTANGULAR = 2
};
enum selection_snap {
SNAP_WORD = 1,
SNAP_LINE = 2
};
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned short ushort;
typedef uint_least32_t Rune;
#define Glyph Glyph_
typedef struct {
Rune u; /* character code */
ushort mode; /* attribute flags */
uint32_t fg; /* foreground */
uint32_t bg; /* background */
} Glyph;
typedef Glyph *Line;
typedef union {
int i;
uint ui;
float f;
const void *v;
const char *s;
} Arg;
void die(const char *, ...);
void redraw(void);
void draw(void);
void printscreen(const Arg *);
void printsel(const Arg *);
void sendbreak(const Arg *);
void toggleprinter(const Arg *);
int tattrset(int);
void tnew(int, int);
void tresize(int, int);
void tsetdirtattr(int);
void ttyhangup(void);
int ttynew(char *, char *, char *, char **);
size_t ttyread(void);
void ttyresize(int, int);
void ttywrite(const char *, size_t, int);
void resettitle(void);
void selclear(void);
void selinit(void);
void selstart(int, int, int);
void selextend(int, int, int, int);
int selected(int, int);
char *getsel(void);
size_t utf8encode(Rune, char *);
void *xmalloc(size_t);
void *xrealloc(void *, size_t);
char *xstrdup(char *);
/* config.h globals */
extern char *utmp;
extern char *scroll;
extern char *stty_args;
extern char *vtiden;
extern wchar_t *worddelimiters;
extern int allowaltscreen;
extern int allowwindowops;
extern char *termname;
extern unsigned int tabspaces;
extern unsigned int defaultfg;
extern unsigned int defaultbg;

46
st.info
View File

@ -1,4 +1,4 @@
st| simpleterm,
st-mono| simpleterm monocolor,
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
am,
bce,
@ -10,7 +10,7 @@ st| simpleterm,
civis=\E[?25l,
clear=\E[H\E[2J,
cnorm=\E[?12l\E[?25h,
colors#8,
colors#2,
cols#80,
cr=^M,
csr=\E[%i%p1%d;%p2%dr,
@ -25,6 +25,7 @@ st| simpleterm,
cuu=\E[%p1%dA,
dch=\E[%p1%dP,
dch1=\E[P,
dim=\E[2m,
dl=\E[%p1%dM,
dl1=\E[M,
ech=\E[%p1%dX,
@ -142,14 +143,12 @@ st| simpleterm,
khome=\E[1~,
kil1=\E[2;5~,
krmir=\E[2;2~,
kich1=\E[2~,
knp=\E[6~,
kmous=\E[M,
kpp=\E[5~,
lines#24,
mir,
msgr,
ncv#3,
npc,
op=\E[39;49m,
pairs#64,
@ -159,6 +158,7 @@ st| simpleterm,
rc=\E8,
rev=\E[7m,
ri=\EM,
rin=\E[%p1%dT,
ritm=\E[23m,
rmacs=\E(B,
rmcup=\E[?1049l,
@ -169,13 +169,8 @@ st| simpleterm,
rs1=\Ec,
rs2=\E[4l\E>\E[?1034l,
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,
sgr0=\E[0m,
smacs=\E(0,
smcup=\E[?1049h,
smir=\E[4h,
@ -186,13 +181,34 @@ st| simpleterm,
tsl=\E]0;,
xenl,
vpa=\E[%i%p1%dd,
# XTerm extensions
rmxx=\E[29m,
smxx=\E[9m,
# disabled rep for now: causes some issues with older ncurses versions.
# rep=%p1%c\E[%p2%{1}%-%db,
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
Tc,
Ms=\E]52;%p1%s;%p2%s\007,
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,
use=st,
ccc,
colors#256,
oc=\E]104\007,
pairs#32767,
# 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,
setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
@ -211,3 +227,13 @@ st-meta-256color| simpleterm with meta key and 256 colors,
smm=\E[?1034h,
rs2=\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,

39
win.h Normal file
View File

@ -0,0 +1,39 @@
/* See LICENSE for license details. */
enum win_mode {
MODE_VISIBLE = 1 << 0,
MODE_FOCUSED = 1 << 1,
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,
};
void xbell(void);
void xclipcopy(void);
void xdrawcursor(int, int, Glyph, int, int, Glyph);
void xdrawline(Line, int, int, int);
void xfinishdraw(void);
void xloadcols(void);
int xsetcolorname(int, const char *);
void xsettitle(char *);
int xsetcursor(int);
void xsetmode(int, unsigned int);
void xsetpointermotion(int);
void xsetsel(char *);
int xstartdraw(void);
void xximspot(int, int);

2049
x.c Normal file

File diff suppressed because it is too large Load Diff