Skip to content

Commit c8ec27a

Browse files
committed
initial create
0 parents  commit c8ec27a

File tree

15 files changed

+6001
-0
lines changed

15 files changed

+6001
-0
lines changed

FAQ

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
## Why does st not handle utmp entries?
2+
3+
Use the excellent tool of [utmp](http://git.suckless.org/utmp/) for this task.
4+
5+
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
6+
7+
It means that st doesn’t have any terminfo entry on your system. Chances are
8+
you did not `make install`. If you just want to test it without installing it,
9+
you can manually run `tic -sx st.info`.
10+
11+
## Nothing works, and nothing is said about an unknown terminal!
12+
13+
* Some programs just assume they’re running in xterm i.e. they don’t rely on
14+
terminfo. What you see is the current state of the “xterm compliance”.
15+
* Some programs don’t complain about the lacking st description and default to
16+
another terminal. In that case see the question about terminfo.
17+
18+
## I get some weird glitches/visual bug on _random program_!
19+
20+
Try launching it with a different TERM: $ TERM=xterm myapp. toe(1) will give
21+
you a list of available terminals, but you’ll most likely switch between xterm,
22+
st or st-256color. The default value for TERM can be changed in config.h
23+
(TNAME).
24+
25+
## How do I scroll back up?
26+
27+
Using a terminal multiplexer.
28+
29+
* `st -e tmux` using C-b [
30+
* `st -e screen` using C-a ESC
31+
32+
## Why doesn't the Del key work in some programs?
33+
34+
Taken from the terminfo manpage:
35+
36+
If the terminal has a keypad that transmits codes when the keys
37+
are pressed, this information can be given. Note that it is not
38+
possible to handle terminals where the keypad only works in
39+
local (this applies, for example, to the unshifted HP 2621 keys).
40+
If the keypad can be set to transmit or not transmit, give these
41+
codes as smkx and rmkx. Otherwise the keypad is assumed to
42+
always transmit.
43+
44+
In the st case smkx=E[?1hE= and rmkx=E[?1lE>, so it is mandatory that
45+
applications which want to test against keypad keys send these
46+
sequences.
47+
48+
But buggy applications (like bash and irssi, for example) don't do this. A fast
49+
solution for them is to use the following command:
50+
51+
$ printf '\033[?1h\033=' >/dev/tty
52+
53+
or
54+
$ tput smkx
55+
56+
In the case of bash, readline is used. Readline has a different note in its
57+
manpage about this issue:
58+
59+
enable-keypad (Off)
60+
When set to On, readline will try to enable the
61+
application keypad when it is called. Some systems
62+
need this to enable arrow keys.
63+
64+
Adding this option to your .inputrc will fix the keypad problem for all
65+
applications using readline.
66+
67+
If you are using zsh, then read the zsh FAQ
68+
<http://zsh.sourceforge.net/FAQ/zshfaq03.html#l25>:
69+
70+
It should be noted that the O / [ confusion can occur with other keys
71+
such as Home and End. Some systems let you query the key sequences
72+
sent by these keys from the system's terminal database, terminfo.
73+
Unfortunately, the key sequences given there typically apply to the
74+
mode that is not the one zsh uses by default (it's the "application"
75+
mode rather than the "raw" mode). Explaining the use of terminfo is
76+
outside of the scope of this FAQ, but if you wish to use the key
77+
sequences given there you can tell the line editor to turn on
78+
"application" mode when it starts and turn it off when it stops:
79+
80+
function zle-line-init () { echoti smkx }
81+
function zle-line-finish () { echoti rmkx }
82+
zle -N zle-line-init
83+
zle -N zle-line-finish
84+
85+
Putting these lines into your .zshrc will fix the problems.
86+
87+
## How can I use meta in 8bit mode?
88+
89+
St supports meta in 8bit mode, but the default terminfo entry doesn't
90+
use this capability. If you want it, you have to use the 'st-meta' value
91+
in TERM.
92+
93+
## I cannot compile st in OpenBSD
94+
95+
OpenBSD lacks librt, despite it being mandatory in POSIX
96+
<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tag_20_11_13>.
97+
If you want to compile st for OpenBSD you have to remove -lrt from config.mk, and
98+
st will compile without any loss of functionality, because all the functions are
99+
included in libc on this platform.
100+
101+
## The Backspace Case
102+
103+
St is emulating the Linux way of handling backspace being delete and delete being
104+
backspace.
105+
106+
This is an issue that was discussed in suckless mailing list
107+
<http://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
108+
terminal users wants its backspace to be how he feels it:
109+
110+
Well, I am going to comment why I want to change the behaviour
111+
of this key. When ASCII was defined in 1968, communication
112+
with computers was done using punched cards, or hardcopy
113+
terminals (basically a typewriter machine connected with the
114+
computer using a serial port). ASCII defines DELETE as 7F,
115+
because, in punched-card terms, it means all the holes of the
116+
card punched; it is thus a kind of 'physical delete'. In the
117+
same way, the BACKSPACE key was a non-destructive backspace,
118+
as on a typewriter. So, if you wanted to delete a character,
119+
you had to BACKSPACE and then DELETE. Another use of BACKSPACE
120+
was to type accented characters, for example 'a BACKSPACE `'.
121+
The VT100 had no BACKSPACE key; it was generated using the
122+
CONTROL key as another control character (CONTROL key sets to
123+
0 b7 b6 b5, so it converts H (code 0x48) into BACKSPACE (code
124+
0x08)), but it had a DELETE key in a similar position where
125+
the BACKSPACE key is located today on common PC keyboards.
126+
All the terminal emulators emulated the difference between
127+
these keys correctly: the backspace key generated a BACKSPACE
128+
(^H) and delete key generated a DELETE (^?).
129+
130+
But a problem arose when Linus Torvalds wrote Linux. Unlike
131+
earlier terminals, the Linux virtual terminal (the terminal
132+
emulator integrated in the kernel) returned a DELETE when
133+
backspace was pressed, due to the VT100 having a DELETE key in
134+
the same position. This created a lot of problems (see [1]
135+
and [2]). Since Linux has become the king, a lot of terminal
136+
emulators today generate a DELETE when the backspace key is
137+
pressed in order to avoid problems with Linux. The result is
138+
that the only way of generating a BACKSPACE on these systems
139+
is by using CONTROL + H. (I also think that emacs had an
140+
important point here because the CONTROL + H prefix is used
141+
in emacs in some commands (help commands).)
142+
143+
From point of view of the kernel, you can change the key
144+
for deleting a previous character with stty erase. When you
145+
connect a real terminal into a machine you describe the type
146+
of terminal, so getty configures the correct value of stty
147+
erase for this terminal. In the case of terminal emulators,
148+
however, you don't have any getty that can set the correct
149+
value of stty erase, so you always get the default value.
150+
For this reason, it is necessary to add 'stty erase ^H' to your
151+
profile if you have changed the value of the backspace key.
152+
Of course, another solution is for st itself to modify the
153+
value of stty erase. I usually have the inverse problem:
154+
when I connect to non-Unix machines, I have to press CONTROL +
155+
h to get a BACKSPACE. The inverse problem occurs when a user
156+
connects to my Unix machines from a different system with a
157+
correct backspace key.
158+
159+
[1] http://www.ibb.net/~anne/keyboard.html
160+
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
161+
162+
## But I really want the old grumpy behaviour of my terminal
163+
164+
Apply [1].
165+
166+
[1] http://st.suckless.org/patches/delkey
167+

LEGACY

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
A STATEMENT ON LEGACY SUPPORT
2+
3+
In the terminal world there is much cruft that comes from old and unsup‐
4+
ported terminals that inherit incompatible modes and escape sequences
5+
which noone is able to know, except when he/she comes from that time and
6+
developed a graphical vt100 emulator at that time.
7+
8+
One goal of st is to only support what is really needed. When you en‐
9+
counter a sequence which you really need, implement it. But while you
10+
are at it, do not add the other cruft you might encounter while sneek‐
11+
ing at other terminal emulators. History has bloated them and there is
12+
no real evidence that most of the sequences are used today.
13+
14+
15+
Christoph Lohmann <[email protected]>
16+
2012-09-13T07:00:36.081271045+02:00
17+

LICENSE

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
MIT/X Consortium License
2+
3+
© 2014-2018 Hiltjo Posthuma <hiltjo at codemadness dot org>
4+
© 2018 Devin J. Pohly <djpohly at gmail dot com>
5+
© 2014-2017 Quentin Rameau <quinq at fifth dot space>
6+
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
7+
© 2008-2017 Anselm R Garbe <garbeam at gmail dot com>
8+
© 2012-2017 Roberto E. Vargas Caballero <k0ga at shike2 dot com>
9+
© 2012-2016 Christoph Lohmann <20h at r-36 dot net>
10+
© 2013 Eon S. Jeon <esjeon at hyunmu dot am>
11+
© 2013 Alexander Sedov <alex0player at gmail dot com>
12+
© 2013 Mark Edgar <medgar123 at gmail dot com>
13+
© 2013-2014 Eric Pruitt <eric.pruitt at gmail dot com>
14+
© 2013 Michael Forney <mforney at mforney dot org>
15+
© 2013-2014 Markus Teich <markus dot teich at stusta dot mhn dot de>
16+
© 2014-2015 Laslo Hunhold <dev at frign dot de>
17+
18+
Permission is hereby granted, free of charge, to any person obtaining a
19+
copy of this software and associated documentation files (the "Software"),
20+
to deal in the Software without restriction, including without limitation
21+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
22+
and/or sell copies of the Software, and to permit persons to whom the
23+
Software is furnished to do so, subject to the following conditions:
24+
25+
The above copyright notice and this permission notice shall be included in
26+
all copies or substantial portions of the Software.
27+
28+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
31+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
34+
DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# st - simple terminal
2+
# See LICENSE file for copyright and license details.
3+
.POSIX:
4+
5+
include config.mk
6+
7+
SRC = st.c x.c
8+
OBJ = $(SRC:.c=.o)
9+
10+
all: options st
11+
12+
options:
13+
@echo st build options:
14+
@echo "CFLAGS = $(STCFLAGS)"
15+
@echo "LDFLAGS = $(STLDFLAGS)"
16+
@echo "CC = $(CC)"
17+
18+
config.h:
19+
cp config.def.h config.h
20+
21+
.c.o:
22+
$(CC) $(STCFLAGS) -c $<
23+
24+
st.o: config.h st.h win.h
25+
x.o: arg.h config.h st.h win.h
26+
27+
$(OBJ): config.h config.mk
28+
29+
st: $(OBJ)
30+
$(CC) -o $@ $(OBJ) $(STLDFLAGS)
31+
32+
clean:
33+
rm -f st $(OBJ) st-$(VERSION).tar.gz
34+
35+
dist: clean
36+
mkdir -p st-$(VERSION)
37+
cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\
38+
config.def.h st.info st.1 arg.h st.h win.h $(SRC)\
39+
st-$(VERSION)
40+
tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz
41+
rm -rf st-$(VERSION)
42+
43+
install: st
44+
mkdir -p $(DESTDIR)$(PREFIX)/bin
45+
cp -f st $(DESTDIR)$(PREFIX)/bin
46+
chmod 755 $(DESTDIR)$(PREFIX)/bin/st
47+
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
48+
sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
49+
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
50+
tic -sx st.info
51+
@echo Please see the README file regarding the terminfo entry of st.
52+
53+
uninstall:
54+
rm -f $(DESTDIR)$(PREFIX)/bin/st
55+
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
56+
57+
.PHONY: all options clean dist install uninstall

README

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
st - simple terminal
2+
--------------------
3+
st is a simple terminal emulator for X which sucks less.
4+
5+
6+
Requirements
7+
------------
8+
In order to build st you need the Xlib header files.
9+
10+
11+
Installation
12+
------------
13+
Edit config.mk to match your local setup (st is installed into
14+
the /usr/local namespace by default).
15+
16+
Afterwards enter the following command to build and install st (if
17+
necessary as root):
18+
19+
make clean install
20+
21+
22+
Running st
23+
----------
24+
If you did not install st with make clean install, you must compile
25+
the st terminfo entry with the following command:
26+
27+
tic -sx st.info
28+
29+
See the man page for additional details.
30+
31+
Credits
32+
-------
33+
Based on Aurélien APTEL <aurelien dot aptel at gmail dot com> bt source code.
34+

TODO

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
vt emulation
2+
------------
3+
4+
* double-height support
5+
6+
code & interface
7+
----------------
8+
9+
* add a simple way to do multiplexing
10+
11+
drawing
12+
-------
13+
* add diacritics support to xdraws()
14+
* switch to a suckless font drawing library
15+
* make the font cache simpler
16+
* add better support for brightening of the upper colors
17+
18+
bugs
19+
----
20+
21+
* fix shift up/down (shift selection in emacs)
22+
* remove DEC test sequence when appropriate
23+
24+
misc
25+
----
26+
27+
$ grep -nE 'XXX|TODO' st.c
28+

arg.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copy me if you can.
3+
* by 20h
4+
*/
5+
6+
#ifndef ARG_H__
7+
#define ARG_H__
8+
9+
extern char *argv0;
10+
11+
/* use main(int argc, char *argv[]) */
12+
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
13+
argv[0] && argv[0][0] == '-'\
14+
&& argv[0][1];\
15+
argc--, argv++) {\
16+
char argc_;\
17+
char **argv_;\
18+
int brk_;\
19+
if (argv[0][1] == '-' && argv[0][2] == '\0') {\
20+
argv++;\
21+
argc--;\
22+
break;\
23+
}\
24+
int i_;\
25+
for (i_ = 1, brk_ = 0, argv_ = argv;\
26+
argv[0][i_] && !brk_;\
27+
i_++) {\
28+
if (argv_ != argv)\
29+
break;\
30+
argc_ = argv[0][i_];\
31+
switch (argc_)
32+
33+
#define ARGEND }\
34+
}
35+
36+
#define ARGC() argc_
37+
38+
#define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
39+
((x), abort(), (char *)0) :\
40+
(brk_ = 1, (argv[0][i_+1] != '\0')?\
41+
(&argv[0][i_+1]) :\
42+
(argc--, argv++, argv[0])))
43+
44+
#define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
45+
(char *)0 :\
46+
(brk_ = 1, (argv[0][i_+1] != '\0')?\
47+
(&argv[0][i_+1]) :\
48+
(argc--, argv++, argv[0])))
49+
50+
#endif

0 commit comments

Comments
 (0)