Compare commits
149 Commits
0.8
...
d0c62ba1db
Author | SHA1 | Date | |
---|---|---|---|
d0c62ba1db | |||
98610fcd37 | |||
6009e6e25b | |||
a0274bc20e | |||
5dbcca4926 | |||
d63b9eb902 | |||
497a756382 | |||
8c68ec5241 | |||
5ce9716281 | |||
f20e169a20 | |||
95f22c5305 | |||
7473a8d1a5 | |||
a3f7420310 | |||
9846a56bd7 | |||
559fdc2786 | |||
8abe4bcb41 | |||
2fc7e532b2 | |||
a6bbc0c96b | |||
eb3b894f40 | |||
3a6d6d7401 | |||
211964d56e | |||
f17abd25b3 | |||
7e8050cc62 | |||
e5e959835b | |||
68d1ad9b54 | |||
0008519903 | |||
72fd32736a | |||
baa9357e96 | |||
8629d9a1da | |||
ef0551932f | |||
af3bb68add | |||
2aefa348ba | |||
e823e2308f | |||
2c5edf28ec | |||
b1d97fec47 | |||
ea7cd7b62f | |||
7fb0c0cc68 | |||
7e1c68f25d | |||
65f1dc4283 | |||
a0467c802d | |||
273db5ceaf | |||
8e31030390 | |||
2f6e597ed8 | |||
1d3142da96 | |||
2ec571a30c | |||
4536f46cff | |||
9e68fdbcdb | |||
4ef0cbd8b9 | |||
28b4c822c5 | |||
fa253f077f | |||
b27a383a3a | |||
81067c65ea | |||
f74a9df6e1 | |||
818ec746f4 | |||
9ba7ecf7b1 | |||
a2a704492b | |||
0f8b40652b | |||
e6e2c6199f | |||
94b8ec0021 | |||
dec6b530a4 | |||
475a0a36cb | |||
e8392b282c | |||
f8afebdfa0 | |||
bda9c9ffa6 | |||
045a0fab4f | |||
9c30066e73 | |||
8304d4f059 | |||
914fb825df | |||
cde480c693 | |||
8211e36d28 | |||
87545c612e | |||
1d59091065 | |||
d6ea0a1a61 | |||
43a395ae91 | |||
72e3f6c7c0 | |||
33a9a45664 | |||
771bc401f7 | |||
d66bd405c0 | |||
e997303502 | |||
c1145268f6 | |||
0b73612c0d | |||
019449a7e6 | |||
fbae700a3f | |||
e52319cc7d | |||
21e0d6e8b8 | |||
5703aa0390 | |||
28ad288399 | |||
51e19ea11d | |||
26cdfebf31 | |||
cd785755f2 | |||
2cb539142b | |||
99de333951 | |||
895e5b50a8 | |||
384830110b | |||
2e54a21b5a | |||
289c52b7aa | |||
7ceb3d1f72 | |||
ea4d933ed9 | |||
83866428de | |||
1f09f0b0bb | |||
a2c479c4c8 | |||
d2b75db8d7 | |||
b6d280de6d | |||
ba7f4d69af | |||
2b8333f553 | |||
caa1d8fbea | |||
f1546cf9c1 | |||
21367a040f | |||
b650256044 | |||
9acec468fb | |||
927621f6da | |||
add0211522 | |||
d5efd256aa | |||
75b4ba4b4b | |||
ed68fe7dce | |||
4e0135afec | |||
a8cb8e9454 | |||
e85b6b6466 | |||
75f92eb348 | |||
3be4cf11d7 | |||
16d98738e7 | |||
e23acb9188 | |||
7e19e11676 | |||
096b125db7 | |||
d7bf023b2f | |||
b4d68d4daa | |||
30ec9a3dc3 | |||
67d0cb65d0 | |||
4f4bccd162 | |||
8ed7a4b3b7 | |||
732be223ee | |||
5535c1f04c | |||
b51bcd5553 | |||
1911c9274d | |||
29f341da7c | |||
dc3b5babf1 | |||
235a783e03 | |||
30ce2cc002 | |||
041912a791 | |||
bd3f7fd842 | |||
74cff67bd7 | |||
6f0f2b7ec3 | |||
f4020b2cc4 | |||
a5a928bfc1 | |||
6ac8c8aa50 | |||
5345db3c9b | |||
7648697f71 | |||
0b507bb731 | |||
e7ef3c4ce9 |
110
FAQ
110
FAQ
@ -1,6 +1,7 @@
|
|||||||
## Why does st not handle utmp entries?
|
## Why does st not handle utmp entries?
|
||||||
|
|
||||||
Use the excellent tool of [utmp](http://git.suckless.org/utmp/) for this task.
|
Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task.
|
||||||
|
|
||||||
|
|
||||||
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
|
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
|
||||||
|
|
||||||
@ -8,6 +9,7 @@ It means that st doesn’t have any terminfo entry on your system. Chances are
|
|||||||
you did not `make install`. If you just want to test it without installing it,
|
you did not `make install`. If you just want to test it without installing it,
|
||||||
you can manually run `tic -sx st.info`.
|
you can manually run `tic -sx st.info`.
|
||||||
|
|
||||||
|
|
||||||
## Nothing works, and nothing is said about an unknown terminal!
|
## Nothing works, and nothing is said about an unknown terminal!
|
||||||
|
|
||||||
* Some programs just assume they’re running in xterm i.e. they don’t rely on
|
* Some programs just assume they’re running in xterm i.e. they don’t rely on
|
||||||
@ -15,19 +17,21 @@ you can manually run `tic -sx st.info`.
|
|||||||
* Some programs don’t complain about the lacking st description and default to
|
* Some programs don’t complain about the lacking st description and default to
|
||||||
another terminal. In that case see the question about terminfo.
|
another terminal. In that case see the question about terminfo.
|
||||||
|
|
||||||
## I get some weird glitches/visual bug on _random program_!
|
|
||||||
|
|
||||||
Try launching it with a different TERM: $ TERM=xterm myapp. toe(1) will give
|
|
||||||
you a list of available terminals, but you’ll most likely switch between xterm,
|
|
||||||
st or st-256color. The default value for TERM can be changed in config.h
|
|
||||||
(TNAME).
|
|
||||||
|
|
||||||
## How do I scroll back up?
|
## How do I scroll back up?
|
||||||
|
|
||||||
Using a terminal multiplexer.
|
* Using a terminal multiplexer.
|
||||||
|
* `st -e tmux` using C-b [
|
||||||
|
* `st -e screen` using C-a ESC
|
||||||
|
* Using the excellent tool of [scroll](https://git.suckless.org/scroll/).
|
||||||
|
* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/).
|
||||||
|
|
||||||
|
|
||||||
|
## I would like to have utmp and/or scroll functionality by default
|
||||||
|
|
||||||
|
You can add the absolute path of both programs in your config.h file. You only
|
||||||
|
have to modify the value of utmp and scroll variables.
|
||||||
|
|
||||||
* `st -e tmux` using C-b [
|
|
||||||
* `st -e screen` using C-a ESC
|
|
||||||
|
|
||||||
## Why doesn't the Del key work in some programs?
|
## Why doesn't the Del key work in some programs?
|
||||||
|
|
||||||
@ -84,12 +88,14 @@ If you are using zsh, then read the zsh FAQ
|
|||||||
|
|
||||||
Putting these lines into your .zshrc will fix the problems.
|
Putting these lines into your .zshrc will fix the problems.
|
||||||
|
|
||||||
|
|
||||||
## How can I use meta in 8bit mode?
|
## How can I use meta in 8bit mode?
|
||||||
|
|
||||||
St supports meta in 8bit mode, but the default terminfo entry doesn't
|
St supports meta in 8bit mode, but the default terminfo entry doesn't
|
||||||
use this capability. If you want it, you have to use the 'st-meta' value
|
use this capability. If you want it, you have to use the 'st-meta' value
|
||||||
in TERM.
|
in TERM.
|
||||||
|
|
||||||
|
|
||||||
## I cannot compile st in OpenBSD
|
## I cannot compile st in OpenBSD
|
||||||
|
|
||||||
OpenBSD lacks librt, despite it being mandatory in POSIX
|
OpenBSD lacks librt, despite it being mandatory in POSIX
|
||||||
@ -98,13 +104,14 @@ If you want to compile st for OpenBSD you have to remove -lrt from config.mk, an
|
|||||||
st will compile without any loss of functionality, because all the functions are
|
st will compile without any loss of functionality, because all the functions are
|
||||||
included in libc on this platform.
|
included in libc on this platform.
|
||||||
|
|
||||||
|
|
||||||
## The Backspace Case
|
## The Backspace Case
|
||||||
|
|
||||||
St is emulating the Linux way of handling backspace being delete and delete being
|
St is emulating the Linux way of handling backspace being delete and delete being
|
||||||
backspace.
|
backspace.
|
||||||
|
|
||||||
This is an issue that was discussed in suckless mailing list
|
This is an issue that was discussed in suckless mailing list
|
||||||
<http://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
|
<https://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
|
||||||
terminal users wants its backspace to be how he feels it:
|
terminal users wants its backspace to be how he feels it:
|
||||||
|
|
||||||
Well, I am going to comment why I want to change the behaviour
|
Well, I am going to comment why I want to change the behaviour
|
||||||
@ -159,9 +166,88 @@ terminal users wants its backspace to be how he feels it:
|
|||||||
[1] http://www.ibb.net/~anne/keyboard.html
|
[1] http://www.ibb.net/~anne/keyboard.html
|
||||||
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
|
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
|
||||||
|
|
||||||
|
|
||||||
## But I really want the old grumpy behaviour of my terminal
|
## But I really want the old grumpy behaviour of my terminal
|
||||||
|
|
||||||
Apply [1].
|
Apply [1].
|
||||||
|
|
||||||
[1] http://st.suckless.org/patches/delkey
|
[1] https://st.suckless.org/patches/delkey
|
||||||
|
|
||||||
|
|
||||||
|
## Why do images not work in st using the w3m image hack?
|
||||||
|
|
||||||
|
w3mimg uses a hack that draws an image on top of the terminal emulator Drawable
|
||||||
|
window. The hack relies on the terminal to use a single buffer to draw its
|
||||||
|
contents directly.
|
||||||
|
|
||||||
|
st uses double-buffered drawing so the image is quickly replaced and may show a
|
||||||
|
short flicker effect.
|
||||||
|
|
||||||
|
Below is a patch example to change st double-buffering to a single Drawable
|
||||||
|
buffer.
|
||||||
|
|
||||||
|
diff --git a/x.c b/x.c
|
||||||
|
--- a/x.c
|
||||||
|
+++ b/x.c
|
||||||
|
@@ -732,10 +732,6 @@ xresize(int col, int row)
|
||||||
|
win.tw = col * win.cw;
|
||||||
|
win.th = row * win.ch;
|
||||||
|
|
||||||
|
- XFreePixmap(xw.dpy, xw.buf);
|
||||||
|
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
||||||
|
- DefaultDepth(xw.dpy, xw.scr));
|
||||||
|
- XftDrawChange(xw.draw, xw.buf);
|
||||||
|
xclear(0, 0, win.w, win.h);
|
||||||
|
|
||||||
|
/* resize to new width */
|
||||||
|
@@ -1148,8 +1144,7 @@ xinit(int cols, int rows)
|
||||||
|
gcvalues.graphics_exposures = False;
|
||||||
|
dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
|
||||||
|
&gcvalues);
|
||||||
|
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
||||||
|
- DefaultDepth(xw.dpy, xw.scr));
|
||||||
|
+ xw.buf = xw.win;
|
||||||
|
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
|
||||||
|
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
|
||||||
|
|
||||||
|
@@ -1632,8 +1627,6 @@ xdrawline(Line line, int x1, int y1, int x2)
|
||||||
|
void
|
||||||
|
xfinishdraw(void)
|
||||||
|
{
|
||||||
|
- XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w,
|
||||||
|
- win.h, 0, 0);
|
||||||
|
XSetForeground(xw.dpy, dc.gc,
|
||||||
|
dc.col[IS_SET(MODE_REVERSE)?
|
||||||
|
defaultfg : defaultbg].pixel);
|
||||||
|
|
||||||
|
|
||||||
|
## BadLength X error in Xft when trying to render emoji
|
||||||
|
|
||||||
|
Xft makes st crash when rendering color emojis with the following error:
|
||||||
|
|
||||||
|
"X Error of failed request: BadLength (poly request too large or internal Xlib length error)"
|
||||||
|
Major opcode of failed request: 139 (RENDER)
|
||||||
|
Minor opcode of failed request: 20 (RenderAddGlyphs)
|
||||||
|
Serial number of failed request: 1595
|
||||||
|
Current serial number in output stream: 1818"
|
||||||
|
|
||||||
|
This is a known bug in Xft (not st) which happens on some platforms and
|
||||||
|
combination of particular fonts and fontconfig settings.
|
||||||
|
|
||||||
|
See also:
|
||||||
|
https://gitlab.freedesktop.org/xorg/lib/libxft/issues/6
|
||||||
|
https://bugs.freedesktop.org/show_bug.cgi?id=107534
|
||||||
|
https://bugzilla.redhat.com/show_bug.cgi?id=1498269
|
||||||
|
|
||||||
|
The solution is to remove color emoji fonts or disable this in the fontconfig
|
||||||
|
XML configuration. As an ugly workaround (which may work only on newer
|
||||||
|
fontconfig versions (FC_COLOR)), the following code can be used to mask color
|
||||||
|
fonts:
|
||||||
|
|
||||||
|
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
|
||||||
|
|
||||||
|
Please don't bother reporting this bug to st, but notify the upstream Xft
|
||||||
|
developers about fixing this bug.
|
||||||
|
|
||||||
|
As of 2022-09-05 this now seems to be finally fixed in libXft 2.3.5:
|
||||||
|
https://gitlab.freedesktop.org/xorg/lib/libxft/-/blob/libXft-2.3.5/NEWS
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT/X Consortium License
|
MIT/X Consortium License
|
||||||
|
|
||||||
© 2014-2018 Hiltjo Posthuma <hiltjo at codemadness dot org>
|
© 2014-2022 Hiltjo Posthuma <hiltjo at codemadness dot org>
|
||||||
© 2018 Devin J. Pohly <djpohly at gmail dot com>
|
© 2018 Devin J. Pohly <djpohly at gmail dot com>
|
||||||
© 2014-2017 Quentin Rameau <quinq at fifth dot space>
|
© 2014-2017 Quentin Rameau <quinq at fifth dot space>
|
||||||
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
|
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
|
||||||
|
12
Makefile
12
Makefile
@ -7,13 +7,7 @@ include config.mk
|
|||||||
SRC = st.c x.c
|
SRC = st.c x.c
|
||||||
OBJ = $(SRC:.c=.o)
|
OBJ = $(SRC:.c=.o)
|
||||||
|
|
||||||
all: options st
|
all: st
|
||||||
|
|
||||||
options:
|
|
||||||
@echo st build options:
|
|
||||||
@echo "CFLAGS = $(STCFLAGS)"
|
|
||||||
@echo "LDFLAGS = $(STLDFLAGS)"
|
|
||||||
@echo "CC = $(CC)"
|
|
||||||
|
|
||||||
config.h:
|
config.h:
|
||||||
cp config.def.h config.h
|
cp config.def.h config.h
|
||||||
@ -22,7 +16,7 @@ config.h:
|
|||||||
$(CC) $(STCFLAGS) -c $<
|
$(CC) $(STCFLAGS) -c $<
|
||||||
|
|
||||||
st.o: config.h st.h win.h
|
st.o: config.h st.h win.h
|
||||||
x.o: arg.h st.h win.h
|
x.o: arg.h config.h st.h win.h
|
||||||
|
|
||||||
$(OBJ): config.h config.mk
|
$(OBJ): config.h config.mk
|
||||||
|
|
||||||
@ -54,4 +48,4 @@ uninstall:
|
|||||||
rm -f $(DESTDIR)$(PREFIX)/bin/st
|
rm -f $(DESTDIR)$(PREFIX)/bin/st
|
||||||
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||||
|
|
||||||
.PHONY: all options clean dist install uninstall
|
.PHONY: all clean dist install uninstall
|
||||||
|
22
arg.h
22
arg.h
@ -21,28 +21,30 @@ extern char *argv0;
|
|||||||
argc--;\
|
argc--;\
|
||||||
break;\
|
break;\
|
||||||
}\
|
}\
|
||||||
for (brk_ = 0, argv[0]++, argv_ = argv;\
|
int i_;\
|
||||||
argv[0][0] && !brk_;\
|
for (i_ = 1, brk_ = 0, argv_ = argv;\
|
||||||
argv[0]++) {\
|
argv[0][i_] && !brk_;\
|
||||||
|
i_++) {\
|
||||||
if (argv_ != argv)\
|
if (argv_ != argv)\
|
||||||
break;\
|
break;\
|
||||||
argc_ = argv[0][0];\
|
argc_ = argv[0][i_];\
|
||||||
switch (argc_)
|
switch (argc_)
|
||||||
|
|
||||||
#define ARGEND }\
|
#define ARGEND }\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ARGC() argc_
|
#define ARGC() argc_
|
||||||
|
|
||||||
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
#define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
|
||||||
((x), abort(), (char *)0) :\
|
((x), abort(), (char *)0) :\
|
||||||
(brk_ = 1, (argv[0][1] != '\0')?\
|
(brk_ = 1, (argv[0][i_+1] != '\0')?\
|
||||||
(&argv[0][1]) :\
|
(&argv[0][i_+1]) :\
|
||||||
(argc--, argv++, argv[0])))
|
(argc--, argv++, argv[0])))
|
||||||
|
|
||||||
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
#define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
|
||||||
(char *)0 :\
|
(char *)0 :\
|
||||||
(brk_ = 1, (argv[0][1] != '\0')?\
|
(brk_ = 1, (argv[0][i_+1] != '\0')?\
|
||||||
(&argv[0][1]) :\
|
(&argv[0][i_+1]) :\
|
||||||
(argc--, argv++, argv[0])))
|
(argc--, argv++, argv[0])))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
60
config.def.h
60
config.def.h
@ -11,13 +11,15 @@ static int borderpx = 2;
|
|||||||
/*
|
/*
|
||||||
* What program is execed by st depends of these precedence rules:
|
* What program is execed by st depends of these precedence rules:
|
||||||
* 1: program passed with -e
|
* 1: program passed with -e
|
||||||
* 2: utmp option
|
* 2: scroll and/or utmp
|
||||||
* 3: SHELL environment variable
|
* 3: SHELL environment variable
|
||||||
* 4: value of shell in /etc/passwd
|
* 4: value of shell in /etc/passwd
|
||||||
* 5: value of shell in config.h
|
* 5: value of shell in config.h
|
||||||
*/
|
*/
|
||||||
static char *shell = "/bin/sh";
|
static char *shell = "/bin/sh";
|
||||||
char *utmp = NULL;
|
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";
|
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
|
||||||
|
|
||||||
/* identification sequence returned in DA and DECID */
|
/* identification sequence returned in DA and DECID */
|
||||||
@ -30,9 +32,9 @@ static float chscale = 1.0;
|
|||||||
/*
|
/*
|
||||||
* word delimiter string
|
* word delimiter string
|
||||||
*
|
*
|
||||||
* More advanced example: " `'\"()[]{}"
|
* More advanced example: L" `'\"()[]{}"
|
||||||
*/
|
*/
|
||||||
char *worddelimiters = " ";
|
wchar_t *worddelimiters = L" ";
|
||||||
|
|
||||||
/* selection timeouts (in milliseconds) */
|
/* selection timeouts (in milliseconds) */
|
||||||
static unsigned int doubleclicktimeout = 300;
|
static unsigned int doubleclicktimeout = 300;
|
||||||
@ -41,9 +43,18 @@ static unsigned int tripleclicktimeout = 600;
|
|||||||
/* alt screens */
|
/* alt screens */
|
||||||
int allowaltscreen = 1;
|
int allowaltscreen = 1;
|
||||||
|
|
||||||
/* frames per second st should at maximum draw to the screen */
|
/* allow certain non-interactive (insecure) window operations such as:
|
||||||
static unsigned int xfps = 120;
|
setting the clipboard text */
|
||||||
static unsigned int actionfps = 30;
|
int allowwindowops = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* draw latency range in ms - from new content/keypress/etc until drawing.
|
||||||
|
* within this range, st draws when content stops arriving (idle). mostly it's
|
||||||
|
* near minlatency, but it waits longer for slow updates to avoid partial draw.
|
||||||
|
* low minlatency will tear/flicker more, as it can "detect" idle too early.
|
||||||
|
*/
|
||||||
|
static double minlatency = 2;
|
||||||
|
static double maxlatency = 33;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
||||||
@ -109,6 +120,8 @@ static const char *colorname[] = {
|
|||||||
/* more colors can be added after 255 to use with DefaultXX */
|
/* more colors can be added after 255 to use with DefaultXX */
|
||||||
"#cccccc",
|
"#cccccc",
|
||||||
"#555555",
|
"#555555",
|
||||||
|
"gray90", /* default foreground colour */
|
||||||
|
"black", /* default background colour */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -116,9 +129,9 @@ static const char *colorname[] = {
|
|||||||
* Default colors (colorname index)
|
* Default colors (colorname index)
|
||||||
* foreground, background, cursor, reverse cursor
|
* foreground, background, cursor, reverse cursor
|
||||||
*/
|
*/
|
||||||
unsigned int defaultfg = 7;
|
unsigned int defaultfg = 258;
|
||||||
unsigned int defaultbg = 0;
|
unsigned int defaultbg = 259;
|
||||||
static unsigned int defaultcs = 256;
|
unsigned int defaultcs = 256;
|
||||||
static unsigned int defaultrcs = 257;
|
static unsigned int defaultrcs = 257;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -150,14 +163,24 @@ static unsigned int mousebg = 0;
|
|||||||
*/
|
*/
|
||||||
static unsigned int defaultattr = 11;
|
static unsigned int defaultattr = 11;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
|
||||||
|
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
||||||
|
* modifier, set to 0 to not use it.
|
||||||
|
*/
|
||||||
|
static uint forcemousemod = ShiftMask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal mouse shortcuts.
|
* Internal mouse shortcuts.
|
||||||
* Beware that overloading Button1 will disable the selection.
|
* Beware that overloading Button1 will disable the selection.
|
||||||
*/
|
*/
|
||||||
static MouseShortcut mshortcuts[] = {
|
static MouseShortcut mshortcuts[] = {
|
||||||
/* button mask string */
|
/* mask button function argument release */
|
||||||
{ Button4, XK_ANY_MOD, "\031" },
|
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
||||||
{ Button5, XK_ANY_MOD, "\005" },
|
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
||||||
|
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
||||||
|
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
||||||
|
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Internal keyboard shortcuts. */
|
/* Internal keyboard shortcuts. */
|
||||||
@ -176,8 +199,8 @@ static Shortcut shortcuts[] = {
|
|||||||
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
|
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
|
||||||
{ TERMMOD, XK_V, clippaste, {.i = 0} },
|
{ TERMMOD, XK_V, clippaste, {.i = 0} },
|
||||||
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
||||||
|
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
||||||
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
||||||
{ TERMMOD, XK_I, iso14755, {.i = 0} },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -195,10 +218,6 @@ static Shortcut shortcuts[] = {
|
|||||||
* * 0: no value
|
* * 0: no value
|
||||||
* * > 0: cursor application mode enabled
|
* * > 0: cursor application mode enabled
|
||||||
* * < 0: cursor application mode disabled
|
* * < 0: cursor application mode disabled
|
||||||
* crlf value
|
|
||||||
* * 0: no value
|
|
||||||
* * > 0: crlf mode is enabled
|
|
||||||
* * < 0: crlf mode is disabled
|
|
||||||
*
|
*
|
||||||
* Be careful with the order of the definitions because st searches in
|
* Be careful with the order of the definitions because st searches in
|
||||||
* this table sequentially, so any XK_ANY_MOD must be in the last
|
* this table sequentially, so any XK_ANY_MOD must be in the last
|
||||||
@ -217,13 +236,6 @@ static KeySym mappedkeys[] = { -1 };
|
|||||||
*/
|
*/
|
||||||
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
|
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
|
||||||
|
|
||||||
/*
|
|
||||||
* Override mouse-select while mask is active (when MODE_MOUSE is set).
|
|
||||||
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
|
||||||
* modifier, set to 0 to not use it.
|
|
||||||
*/
|
|
||||||
static uint forceselmod = ShiftMask;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the huge key array which defines all compatibility to the Linux
|
* This is the huge key array which defines all compatibility to the Linux
|
||||||
* world. Please decide about changes wisely.
|
* world. Please decide about changes wisely.
|
||||||
|
24
config.mk
24
config.mk
@ -1,5 +1,5 @@
|
|||||||
# st version
|
# st version
|
||||||
VERSION = 0.8
|
VERSION = 0.9.2
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
@ -10,19 +10,27 @@ MANPREFIX = $(PREFIX)/share/man
|
|||||||
X11INC = /usr/X11R6/include
|
X11INC = /usr/X11R6/include
|
||||||
X11LIB = /usr/X11R6/lib
|
X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
|
PKG_CONFIG = pkg-config
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I$(X11INC) \
|
INCS = -I$(X11INC) \
|
||||||
`pkg-config --cflags fontconfig` \
|
`$(PKG_CONFIG) --cflags fontconfig` \
|
||||||
`pkg-config --cflags freetype2`
|
`$(PKG_CONFIG) --cflags freetype2`
|
||||||
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
||||||
`pkg-config --libs fontconfig` \
|
`$(PKG_CONFIG) --libs fontconfig` \
|
||||||
`pkg-config --libs freetype2`
|
`$(PKG_CONFIG) --libs freetype2`
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
||||||
STCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS)
|
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||||
STLDFLAGS = $(LIBS) $(LDFLAGS)
|
STLDFLAGS = $(LIBS) $(LDFLAGS)
|
||||||
|
|
||||||
|
# OpenBSD:
|
||||||
|
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
|
||||||
|
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
|
||||||
|
# `$(PKG_CONFIG) --libs fontconfig` \
|
||||||
|
# `$(PKG_CONFIG) --libs freetype2`
|
||||||
|
#MANPREFIX = ${PREFIX}/man
|
||||||
|
|
||||||
# compiler and linker
|
# compiler and linker
|
||||||
# CC = c99
|
# CC = c99
|
||||||
|
|
||||||
|
164
patches/st-anysize-20220718-baa9357.diff
Normal file
164
patches/st-anysize-20220718-baa9357.diff
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
From 8dcdc4b21a73268e167d98aa30f24315c7f3b7ff Mon Sep 17 00:00:00 2001
|
||||||
|
From: Bakkeby <bakkeby@gmail.com>
|
||||||
|
Date: Mon, 18 Jul 2022 16:52:03 +0200
|
||||||
|
Subject: [PATCH] Adding anysize patch
|
||||||
|
|
||||||
|
---
|
||||||
|
x.c | 56 ++++++++++++++++++++++++++++++--------------------------
|
||||||
|
1 file changed, 30 insertions(+), 26 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/x.c b/x.c
|
||||||
|
index 2a3bd38..f534347 100644
|
||||||
|
--- a/x.c
|
||||||
|
+++ b/x.c
|
||||||
|
@@ -81,6 +81,7 @@ typedef XftGlyphFontSpec GlyphFontSpec;
|
||||||
|
typedef struct {
|
||||||
|
int tw, th; /* tty width and height */
|
||||||
|
int w, h; /* window width and height */
|
||||||
|
+ int hborderpx, vborderpx;
|
||||||
|
int ch; /* char height */
|
||||||
|
int cw; /* char width */
|
||||||
|
int mode; /* window state/mode flags */
|
||||||
|
@@ -331,7 +332,7 @@ ttysend(const Arg *arg)
|
||||||
|
int
|
||||||
|
evcol(XEvent *e)
|
||||||
|
{
|
||||||
|
- int x = e->xbutton.x - borderpx;
|
||||||
|
+ int x = e->xbutton.x - win.hborderpx;
|
||||||
|
LIMIT(x, 0, win.tw - 1);
|
||||||
|
return x / win.cw;
|
||||||
|
}
|
||||||
|
@@ -339,7 +340,7 @@ evcol(XEvent *e)
|
||||||
|
int
|
||||||
|
evrow(XEvent *e)
|
||||||
|
{
|
||||||
|
- int y = e->xbutton.y - borderpx;
|
||||||
|
+ int y = e->xbutton.y - win.vborderpx;
|
||||||
|
LIMIT(y, 0, win.th - 1);
|
||||||
|
return y / win.ch;
|
||||||
|
}
|
||||||
|
@@ -739,6 +740,9 @@ cresize(int width, int height)
|
||||||
|
col = MAX(1, col);
|
||||||
|
row = MAX(1, row);
|
||||||
|
|
||||||
|
+ win.hborderpx = (win.w - col * win.cw) / 2;
|
||||||
|
+ win.vborderpx = (win.h - row * win.ch) / 2;
|
||||||
|
+
|
||||||
|
tresize(col, row);
|
||||||
|
xresize(col, row);
|
||||||
|
ttyresize(win.tw, win.th);
|
||||||
|
@@ -869,8 +873,8 @@ xhints(void)
|
||||||
|
sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
|
||||||
|
sizeh->height = win.h;
|
||||||
|
sizeh->width = win.w;
|
||||||
|
- sizeh->height_inc = win.ch;
|
||||||
|
- sizeh->width_inc = win.cw;
|
||||||
|
+ sizeh->height_inc = 1;
|
||||||
|
+ sizeh->width_inc = 1;
|
||||||
|
sizeh->base_height = 2 * borderpx;
|
||||||
|
sizeh->base_width = 2 * borderpx;
|
||||||
|
sizeh->min_height = win.ch + 2 * borderpx;
|
||||||
|
@@ -1152,8 +1156,8 @@ xinit(int cols, int rows)
|
||||||
|
xloadcols();
|
||||||
|
|
||||||
|
/* adjust fixed window geometry */
|
||||||
|
- win.w = 2 * borderpx + cols * win.cw;
|
||||||
|
- win.h = 2 * borderpx + rows * win.ch;
|
||||||
|
+ win.w = 2 * win.hborderpx + 2 * borderpx + cols * win.cw;
|
||||||
|
+ win.h = 2 * win.vborderpx + 2 * borderpx + rows * win.ch;
|
||||||
|
if (xw.gm & XNegative)
|
||||||
|
xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
|
||||||
|
if (xw.gm & YNegative)
|
||||||
|
@@ -1242,7 +1246,7 @@ xinit(int cols, int rows)
|
||||||
|
int
|
||||||
|
xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y)
|
||||||
|
{
|
||||||
|
- float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp;
|
||||||
|
+ float winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch, xp, yp;
|
||||||
|
ushort mode, prevmode = USHRT_MAX;
|
||||||
|
Font *font = &dc.font;
|
||||||
|
int frcflags = FRC_NORMAL;
|
||||||
|
@@ -1375,7 +1379,7 @@ void
|
||||||
|
xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
|
||||||
|
{
|
||||||
|
int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
|
||||||
|
- int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
|
||||||
|
+ int winx = win.hborderpx + x * win.cw, winy = win.vborderpx + y * win.ch,
|
||||||
|
width = charlen * win.cw;
|
||||||
|
Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
|
||||||
|
XRenderColor colfg, colbg;
|
||||||
|
@@ -1465,17 +1469,17 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
||||||
|
|
||||||
|
/* Intelligent cleaning up of the borders. */
|
||||||
|
if (x == 0) {
|
||||||
|
- xclear(0, (y == 0)? 0 : winy, borderpx,
|
||||||
|
+ xclear(0, (y == 0)? 0 : winy, win.hborderpx,
|
||||||
|
winy + win.ch +
|
||||||
|
- ((winy + win.ch >= borderpx + win.th)? win.h : 0));
|
||||||
|
+ ((winy + win.ch >= win.vborderpx + win.th)? win.h : 0));
|
||||||
|
}
|
||||||
|
- if (winx + width >= borderpx + win.tw) {
|
||||||
|
+ if (winx + width >= win.hborderpx + win.tw) {
|
||||||
|
xclear(winx + width, (y == 0)? 0 : winy, win.w,
|
||||||
|
- ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch)));
|
||||||
|
+ ((winy + win.ch >= win.vborderpx + win.th)? win.h : (winy + win.ch)));
|
||||||
|
}
|
||||||
|
if (y == 0)
|
||||||
|
- xclear(winx, 0, winx + width, borderpx);
|
||||||
|
- if (winy + win.ch >= borderpx + win.th)
|
||||||
|
+ xclear(winx, 0, winx + width, win.vborderpx);
|
||||||
|
+ if (winy + win.ch >= win.vborderpx + win.th)
|
||||||
|
xclear(winx, winy + win.ch, winx + width, win.h);
|
||||||
|
|
||||||
|
/* Clean up the region we want to draw to. */
|
||||||
|
@@ -1569,35 +1573,35 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
|
||||||
|
case 3: /* Blinking Underline */
|
||||||
|
case 4: /* Steady Underline */
|
||||||
|
XftDrawRect(xw.draw, &drawcol,
|
||||||
|
- borderpx + cx * win.cw,
|
||||||
|
- borderpx + (cy + 1) * win.ch - \
|
||||||
|
+ win.hborderpx + cx * win.cw,
|
||||||
|
+ win.vborderpx + (cy + 1) * win.ch - \
|
||||||
|
cursorthickness,
|
||||||
|
win.cw, cursorthickness);
|
||||||
|
break;
|
||||||
|
case 5: /* Blinking bar */
|
||||||
|
case 6: /* Steady bar */
|
||||||
|
XftDrawRect(xw.draw, &drawcol,
|
||||||
|
- borderpx + cx * win.cw,
|
||||||
|
- borderpx + cy * win.ch,
|
||||||
|
+ win.hborderpx + cx * win.cw,
|
||||||
|
+ win.vborderpx + cy * win.ch,
|
||||||
|
cursorthickness, win.ch);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
XftDrawRect(xw.draw, &drawcol,
|
||||||
|
- borderpx + cx * win.cw,
|
||||||
|
- borderpx + cy * win.ch,
|
||||||
|
+ win.hborderpx + cx * win.cw,
|
||||||
|
+ win.vborderpx + cy * win.ch,
|
||||||
|
win.cw - 1, 1);
|
||||||
|
XftDrawRect(xw.draw, &drawcol,
|
||||||
|
- borderpx + cx * win.cw,
|
||||||
|
- borderpx + cy * win.ch,
|
||||||
|
+ win.hborderpx + cx * win.cw,
|
||||||
|
+ win.vborderpx + cy * win.ch,
|
||||||
|
1, win.ch - 1);
|
||||||
|
XftDrawRect(xw.draw, &drawcol,
|
||||||
|
- borderpx + (cx + 1) * win.cw - 1,
|
||||||
|
- borderpx + cy * win.ch,
|
||||||
|
+ win.hborderpx + (cx + 1) * win.cw - 1,
|
||||||
|
+ win.vborderpx + cy * win.ch,
|
||||||
|
1, win.ch - 1);
|
||||||
|
XftDrawRect(xw.draw, &drawcol,
|
||||||
|
- borderpx + cx * win.cw,
|
||||||
|
- borderpx + (cy + 1) * win.ch - 1,
|
||||||
|
+ win.hborderpx + cx * win.cw,
|
||||||
|
+ win.vborderpx + (cy + 1) * win.ch - 1,
|
||||||
|
win.cw, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.37.1
|
||||||
|
|
7
st.1
7
st.1
@ -159,10 +159,6 @@ Copy the selected text to the clipboard selection.
|
|||||||
.TP
|
.TP
|
||||||
.B Ctrl-Shift-v
|
.B Ctrl-Shift-v
|
||||||
Paste from the clipboard selection.
|
Paste from the clipboard selection.
|
||||||
.TP
|
|
||||||
.B Ctrl-Shift-i
|
|
||||||
Launch dmenu to enter a unicode codepoint and send the corresponding glyph
|
|
||||||
to st.
|
|
||||||
.SH CUSTOMIZATION
|
.SH CUSTOMIZATION
|
||||||
.B st
|
.B st
|
||||||
can be customized by creating a custom config.h and (re)compiling the source
|
can be customized by creating a custom config.h and (re)compiling the source
|
||||||
@ -174,7 +170,8 @@ See the LICENSE file for the terms of redistribution.
|
|||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
.BR tabbed (1),
|
.BR tabbed (1),
|
||||||
.BR utmp (1),
|
.BR utmp (1),
|
||||||
.BR stty (1)
|
.BR stty (1),
|
||||||
|
.BR scroll (1)
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
See the TODO file in the distribution.
|
See the TODO file in the distribution.
|
||||||
|
|
||||||
|
459
st.c
459
st.c
@ -38,14 +38,10 @@
|
|||||||
|
|
||||||
/* macros */
|
/* macros */
|
||||||
#define IS_SET(flag) ((term.mode & (flag)) != 0)
|
#define IS_SET(flag) ((term.mode & (flag)) != 0)
|
||||||
#define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
|
#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == 0x7f)
|
||||||
#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177')
|
|
||||||
#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
|
#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
|
||||||
#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
|
#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
|
||||||
#define ISDELIM(u) (utf8strchr(worddelimiters, u) != NULL)
|
#define ISDELIM(u) (u && wcschr(worddelimiters, u))
|
||||||
|
|
||||||
/* constants */
|
|
||||||
#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null"
|
|
||||||
|
|
||||||
enum term_mode {
|
enum term_mode {
|
||||||
MODE_WRAP = 1 << 0,
|
MODE_WRAP = 1 << 0,
|
||||||
@ -55,7 +51,6 @@ enum term_mode {
|
|||||||
MODE_ECHO = 1 << 4,
|
MODE_ECHO = 1 << 4,
|
||||||
MODE_PRINT = 1 << 5,
|
MODE_PRINT = 1 << 5,
|
||||||
MODE_UTF8 = 1 << 6,
|
MODE_UTF8 = 1 << 6,
|
||||||
MODE_SIXEL = 1 << 7,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum cursor_movement {
|
enum cursor_movement {
|
||||||
@ -82,12 +77,11 @@ enum charset {
|
|||||||
enum escape_state {
|
enum escape_state {
|
||||||
ESC_START = 1,
|
ESC_START = 1,
|
||||||
ESC_CSI = 2,
|
ESC_CSI = 2,
|
||||||
ESC_STR = 4, /* OSC, PM, APC */
|
ESC_STR = 4, /* DCS, OSC, PM, APC */
|
||||||
ESC_ALTCHARSET = 8,
|
ESC_ALTCHARSET = 8,
|
||||||
ESC_STR_END = 16, /* a final string was encountered */
|
ESC_STR_END = 16, /* a final string was encountered */
|
||||||
ESC_TEST = 32, /* Enter in test mode */
|
ESC_TEST = 32, /* Enter in test mode */
|
||||||
ESC_UTF8 = 64,
|
ESC_UTF8 = 64,
|
||||||
ESC_DCS =128,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -133,13 +127,14 @@ typedef struct {
|
|||||||
int charset; /* current charset */
|
int charset; /* current charset */
|
||||||
int icharset; /* selected charset for sequence */
|
int icharset; /* selected charset for sequence */
|
||||||
int *tabs;
|
int *tabs;
|
||||||
|
Rune lastc; /* last printed char outside of sequence, 0 if control */
|
||||||
} Term;
|
} Term;
|
||||||
|
|
||||||
/* CSI Escape sequence structs */
|
/* CSI Escape sequence structs */
|
||||||
/* ESC '[' [[ [<priv>] <arg> [;]] <mode> [<mode>]] */
|
/* ESC '[' [[ [<priv>] <arg> [;]] <mode> [<mode>]] */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char buf[ESC_BUF_SIZ]; /* raw string */
|
char buf[ESC_BUF_SIZ]; /* raw string */
|
||||||
int len; /* raw string length */
|
size_t len; /* raw string length */
|
||||||
char priv;
|
char priv;
|
||||||
int arg[ESC_ARG_SIZ];
|
int arg[ESC_ARG_SIZ];
|
||||||
int narg; /* nb of args */
|
int narg; /* nb of args */
|
||||||
@ -150,8 +145,9 @@ typedef struct {
|
|||||||
/* ESC type [[ [<priv>] <arg> [;]] <mode>] ESC '\' */
|
/* ESC type [[ [<priv>] <arg> [;]] <mode>] ESC '\' */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char type; /* ESC type ... */
|
char type; /* ESC type ... */
|
||||||
char buf[STR_BUF_SIZ]; /* raw string */
|
char *buf; /* allocated raw string */
|
||||||
int len; /* raw string length */
|
size_t siz; /* allocation size */
|
||||||
|
size_t len; /* raw string length */
|
||||||
char *args[STR_ARG_SIZ];
|
char *args[STR_ARG_SIZ];
|
||||||
int narg; /* nb of args */
|
int narg; /* nb of args */
|
||||||
} STREscape;
|
} STREscape;
|
||||||
@ -165,6 +161,7 @@ static void csidump(void);
|
|||||||
static void csihandle(void);
|
static void csihandle(void);
|
||||||
static void csiparse(void);
|
static void csiparse(void);
|
||||||
static void csireset(void);
|
static void csireset(void);
|
||||||
|
static void osc_color_response(int, int, int);
|
||||||
static int eschandle(uchar);
|
static int eschandle(uchar);
|
||||||
static void strdump(void);
|
static void strdump(void);
|
||||||
static void strhandle(void);
|
static void strhandle(void);
|
||||||
@ -190,18 +187,18 @@ static void tputc(Rune);
|
|||||||
static void treset(void);
|
static void treset(void);
|
||||||
static void tscrollup(int, int);
|
static void tscrollup(int, int);
|
||||||
static void tscrolldown(int, int);
|
static void tscrolldown(int, int);
|
||||||
static void tsetattr(int *, int);
|
static void tsetattr(const int *, int);
|
||||||
static void tsetchar(Rune, Glyph *, int, int);
|
static void tsetchar(Rune, const Glyph *, int, int);
|
||||||
static void tsetdirt(int, int);
|
static void tsetdirt(int, int);
|
||||||
static void tsetscroll(int, int);
|
static void tsetscroll(int, int);
|
||||||
static void tswapscreen(void);
|
static void tswapscreen(void);
|
||||||
static void tsetmode(int, int, int *, int);
|
static void tsetmode(int, int, const int *, int);
|
||||||
static int twrite(const char *, int, int);
|
static int twrite(const char *, int, int);
|
||||||
static void tfulldirt(void);
|
static void tfulldirt(void);
|
||||||
static void tcontrolcode(uchar );
|
static void tcontrolcode(uchar );
|
||||||
static void tdectest(char );
|
static void tdectest(char );
|
||||||
static void tdefutf8(char);
|
static void tdefutf8(char);
|
||||||
static int32_t tdefcolor(int *, int *, int);
|
static int32_t tdefcolor(const int *, int *, int);
|
||||||
static void tdeftran(char);
|
static void tdeftran(char);
|
||||||
static void tstrsequence(uchar);
|
static void tstrsequence(uchar);
|
||||||
|
|
||||||
@ -214,7 +211,6 @@ static void selsnap(int *, int *, int);
|
|||||||
static size_t utf8decode(const char *, Rune *, size_t);
|
static size_t utf8decode(const char *, Rune *, size_t);
|
||||||
static Rune utf8decodebyte(char, size_t *);
|
static Rune utf8decodebyte(char, size_t *);
|
||||||
static char utf8encodebyte(Rune, size_t);
|
static char utf8encodebyte(Rune, size_t);
|
||||||
static char *utf8strchr(char *, Rune);
|
|
||||||
static size_t utf8validate(Rune *, size_t);
|
static size_t utf8validate(Rune *, size_t);
|
||||||
|
|
||||||
static char *base64dec(const char *);
|
static char *base64dec(const char *);
|
||||||
@ -231,10 +227,10 @@ static int iofd = 1;
|
|||||||
static int cmdfd;
|
static int cmdfd;
|
||||||
static pid_t pid;
|
static pid_t pid;
|
||||||
|
|
||||||
static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
static const uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||||
static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
static const uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||||
static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
static const Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||||
static Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
static const Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
xwrite(int fd, const char *s, size_t len)
|
xwrite(int fd, const char *s, size_t len)
|
||||||
@ -256,10 +252,10 @@ xwrite(int fd, const char *s, size_t len)
|
|||||||
void *
|
void *
|
||||||
xmalloc(size_t len)
|
xmalloc(size_t len)
|
||||||
{
|
{
|
||||||
void *p = malloc(len);
|
void *p;
|
||||||
|
|
||||||
if (!p)
|
if (!(p = malloc(len)))
|
||||||
die("Out of memory\n");
|
die("malloc: %s\n", strerror(errno));
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -268,18 +264,20 @@ void *
|
|||||||
xrealloc(void *p, size_t len)
|
xrealloc(void *p, size_t len)
|
||||||
{
|
{
|
||||||
if ((p = realloc(p, len)) == NULL)
|
if ((p = realloc(p, len)) == NULL)
|
||||||
die("Out of memory\n");
|
die("realloc: %s\n", strerror(errno));
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
xstrdup(char *s)
|
xstrdup(const char *s)
|
||||||
{
|
{
|
||||||
if ((s = strdup(s)) == NULL)
|
char *p;
|
||||||
die("Out of memory\n");
|
|
||||||
|
|
||||||
return s;
|
if ((p = strdup(s)) == NULL)
|
||||||
|
die("strdup: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
@ -341,23 +339,6 @@ utf8encodebyte(Rune u, size_t i)
|
|||||||
return utfbyte[i] | (u & ~utfmask[i]);
|
return utfbyte[i] | (u & ~utfmask[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
|
||||||
utf8strchr(char *s, Rune u)
|
|
||||||
{
|
|
||||||
Rune r;
|
|
||||||
size_t i, j, len;
|
|
||||||
|
|
||||||
len = strlen(s);
|
|
||||||
for (i = 0, j = 0; i < len; i += j) {
|
|
||||||
if (!(j = utf8decode(&s[i], &r, len - i)))
|
|
||||||
break;
|
|
||||||
if (r == u)
|
|
||||||
return &(s[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
utf8validate(Rune *u, size_t i)
|
utf8validate(Rune *u, size_t i)
|
||||||
{
|
{
|
||||||
@ -369,26 +350,12 @@ utf8validate(Rune *u, size_t i)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char base64_digits[] = {
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0,
|
|
||||||
63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, -1, 0, 0, 0, 0, 1,
|
|
||||||
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
|
||||||
22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34,
|
|
||||||
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
char
|
char
|
||||||
base64dec_getc(const char **src)
|
base64dec_getc(const char **src)
|
||||||
{
|
{
|
||||||
while (**src && !isprint(**src)) (*src)++;
|
while (**src && !isprint((unsigned char)**src))
|
||||||
return *((*src)++);
|
(*src)++;
|
||||||
|
return **src ? *((*src)++) : '='; /* emulate padding if string ends */
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -396,6 +363,13 @@ base64dec(const char *src)
|
|||||||
{
|
{
|
||||||
size_t in_len = strlen(src);
|
size_t in_len = strlen(src);
|
||||||
char *result, *dst;
|
char *result, *dst;
|
||||||
|
static const char base64_digits[256] = {
|
||||||
|
[43] = 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
|
||||||
|
0, 0, 0, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
|
||||||
|
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0,
|
||||||
|
0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
||||||
|
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
|
||||||
|
};
|
||||||
|
|
||||||
if (in_len % 4)
|
if (in_len % 4)
|
||||||
in_len += 4 - (in_len % 4);
|
in_len += 4 - (in_len % 4);
|
||||||
@ -406,6 +380,10 @@ base64dec(const char *src)
|
|||||||
int c = base64_digits[(unsigned char) base64dec_getc(&src)];
|
int c = base64_digits[(unsigned char) base64dec_getc(&src)];
|
||||||
int d = base64_digits[(unsigned char) base64dec_getc(&src)];
|
int d = base64_digits[(unsigned char) base64dec_getc(&src)];
|
||||||
|
|
||||||
|
/* invalid input. 'a' can be -1, e.g. if src is "\n" (c-str) */
|
||||||
|
if (a == -1 || b == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
*dst++ = (a << 2) | ((b & 0x30) >> 4);
|
*dst++ = (a << 2) | ((b & 0x30) >> 4);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
@ -446,6 +424,7 @@ selstart(int col, int row, int snap)
|
|||||||
selclear();
|
selclear();
|
||||||
sel.mode = SEL_EMPTY;
|
sel.mode = SEL_EMPTY;
|
||||||
sel.type = SEL_REGULAR;
|
sel.type = SEL_REGULAR;
|
||||||
|
sel.alt = IS_SET(MODE_ALTSCREEN);
|
||||||
sel.snap = snap;
|
sel.snap = snap;
|
||||||
sel.oe.x = sel.ob.x = col;
|
sel.oe.x = sel.ob.x = col;
|
||||||
sel.oe.y = sel.ob.y = row;
|
sel.oe.y = sel.ob.y = row;
|
||||||
@ -461,7 +440,7 @@ selextend(int col, int row, int type, int done)
|
|||||||
{
|
{
|
||||||
int oldey, oldex, oldsby, oldsey, oldtype;
|
int oldey, oldex, oldsby, oldsey, oldtype;
|
||||||
|
|
||||||
if (!sel.mode)
|
if (sel.mode == SEL_IDLE)
|
||||||
return;
|
return;
|
||||||
if (done && sel.mode == SEL_EMPTY) {
|
if (done && sel.mode == SEL_EMPTY) {
|
||||||
selclear();
|
selclear();
|
||||||
@ -474,13 +453,12 @@ selextend(int col, int row, int type, int done)
|
|||||||
oldsey = sel.ne.y;
|
oldsey = sel.ne.y;
|
||||||
oldtype = sel.type;
|
oldtype = sel.type;
|
||||||
|
|
||||||
sel.alt = IS_SET(MODE_ALTSCREEN);
|
|
||||||
sel.oe.x = col;
|
sel.oe.x = col;
|
||||||
sel.oe.y = row;
|
sel.oe.y = row;
|
||||||
selnormalize();
|
selnormalize();
|
||||||
sel.type = type;
|
sel.type = type;
|
||||||
|
|
||||||
if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type)
|
if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type || sel.mode == SEL_EMPTY)
|
||||||
tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey));
|
tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey));
|
||||||
|
|
||||||
sel.mode = done ? SEL_IDLE : SEL_READY;
|
sel.mode = done ? SEL_IDLE : SEL_READY;
|
||||||
@ -535,7 +513,7 @@ selsnap(int *x, int *y, int direction)
|
|||||||
{
|
{
|
||||||
int newx, newy, xt, yt;
|
int newx, newy, xt, yt;
|
||||||
int delim, prevdelim;
|
int delim, prevdelim;
|
||||||
Glyph *gp, *prevgp;
|
const Glyph *gp, *prevgp;
|
||||||
|
|
||||||
switch (sel.snap) {
|
switch (sel.snap) {
|
||||||
case SNAP_WORD:
|
case SNAP_WORD:
|
||||||
@ -608,7 +586,7 @@ getsel(void)
|
|||||||
{
|
{
|
||||||
char *str, *ptr;
|
char *str, *ptr;
|
||||||
int y, bufsize, lastx, linelen;
|
int y, bufsize, lastx, linelen;
|
||||||
Glyph *gp, *last;
|
const Glyph *gp, *last;
|
||||||
|
|
||||||
if (sel.ob.x == -1)
|
if (sel.ob.x == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -650,7 +628,8 @@ getsel(void)
|
|||||||
* st.
|
* st.
|
||||||
* FIXME: Fix the computer world.
|
* FIXME: Fix the computer world.
|
||||||
*/
|
*/
|
||||||
if ((y < sel.ne.y || lastx >= linelen) && !(last->mode & ATTR_WRAP))
|
if ((y < sel.ne.y || lastx >= linelen) &&
|
||||||
|
(!(last->mode & ATTR_WRAP) || sel.type == SEL_RECTANGULAR))
|
||||||
*ptr++ = '\n';
|
*ptr++ = '\n';
|
||||||
}
|
}
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
@ -681,13 +660,13 @@ die(const char *errstr, ...)
|
|||||||
void
|
void
|
||||||
execsh(char *cmd, char **args)
|
execsh(char *cmd, char **args)
|
||||||
{
|
{
|
||||||
char *sh, *prog;
|
char *sh, *prog, *arg;
|
||||||
const struct passwd *pw;
|
const struct passwd *pw;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if ((pw = getpwuid(getuid())) == NULL) {
|
if ((pw = getpwuid(getuid())) == NULL) {
|
||||||
if (errno)
|
if (errno)
|
||||||
die("getpwuid:%s\n", strerror(errno));
|
die("getpwuid: %s\n", strerror(errno));
|
||||||
else
|
else
|
||||||
die("who are you?\n");
|
die("who are you?\n");
|
||||||
}
|
}
|
||||||
@ -695,13 +674,20 @@ execsh(char *cmd, char **args)
|
|||||||
if ((sh = getenv("SHELL")) == NULL)
|
if ((sh = getenv("SHELL")) == NULL)
|
||||||
sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd;
|
sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd;
|
||||||
|
|
||||||
if (args)
|
if (args) {
|
||||||
prog = args[0];
|
prog = args[0];
|
||||||
else if (utmp)
|
arg = NULL;
|
||||||
|
} else if (scroll) {
|
||||||
|
prog = scroll;
|
||||||
|
arg = utmp ? utmp : sh;
|
||||||
|
} else if (utmp) {
|
||||||
prog = utmp;
|
prog = utmp;
|
||||||
else
|
arg = NULL;
|
||||||
|
} else {
|
||||||
prog = sh;
|
prog = sh;
|
||||||
DEFAULT(args, ((char *[]) {prog, NULL}));
|
arg = NULL;
|
||||||
|
}
|
||||||
|
DEFAULT(args, ((char *[]) {prog, arg, NULL}));
|
||||||
|
|
||||||
unsetenv("COLUMNS");
|
unsetenv("COLUMNS");
|
||||||
unsetenv("LINES");
|
unsetenv("LINES");
|
||||||
@ -730,17 +716,18 @@ sigchld(int a)
|
|||||||
pid_t p;
|
pid_t p;
|
||||||
|
|
||||||
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
|
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
|
||||||
die("Waiting for pid %hd failed: %s\n", pid, strerror(errno));
|
die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
|
||||||
|
|
||||||
if (pid != p)
|
if (pid != p)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!WIFEXITED(stat) || WEXITSTATUS(stat))
|
if (WIFEXITED(stat) && WEXITSTATUS(stat))
|
||||||
die("child finished with error '%d'\n", stat);
|
die("child exited with status %d\n", WEXITSTATUS(stat));
|
||||||
exit(0);
|
else if (WIFSIGNALED(stat))
|
||||||
|
die("child terminated due to signal %d\n", WTERMSIG(stat));
|
||||||
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
stty(char **args)
|
stty(char **args)
|
||||||
{
|
{
|
||||||
@ -762,11 +749,11 @@ stty(char **args)
|
|||||||
}
|
}
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
if (system(cmd) != 0)
|
if (system(cmd) != 0)
|
||||||
perror("Couldn't call stty");
|
perror("Couldn't call stty");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ttynew(char *line, char *cmd, char *out, char **args)
|
ttynew(const char *line, char *cmd, const char *out, char **args)
|
||||||
{
|
{
|
||||||
int m, s;
|
int m, s;
|
||||||
|
|
||||||
@ -782,7 +769,8 @@ ttynew(char *line, char *cmd, char *out, char **args)
|
|||||||
|
|
||||||
if (line) {
|
if (line) {
|
||||||
if ((cmdfd = open(line, O_RDWR)) < 0)
|
if ((cmdfd = open(line, O_RDWR)) < 0)
|
||||||
die("open line failed: %s\n", strerror(errno));
|
die("open line '%s' failed: %s\n",
|
||||||
|
line, strerror(errno));
|
||||||
dup2(cmdfd, 0);
|
dup2(cmdfd, 0);
|
||||||
stty(args);
|
stty(args);
|
||||||
return cmdfd;
|
return cmdfd;
|
||||||
@ -794,21 +782,30 @@ ttynew(char *line, char *cmd, char *out, char **args)
|
|||||||
|
|
||||||
switch (pid = fork()) {
|
switch (pid = fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
die("fork failed\n");
|
die("fork failed: %s\n", strerror(errno));
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
close(iofd);
|
close(iofd);
|
||||||
|
close(m);
|
||||||
setsid(); /* create a new process group */
|
setsid(); /* create a new process group */
|
||||||
dup2(s, 0);
|
dup2(s, 0);
|
||||||
dup2(s, 1);
|
dup2(s, 1);
|
||||||
dup2(s, 2);
|
dup2(s, 2);
|
||||||
if (ioctl(s, TIOCSCTTY, NULL) < 0)
|
if (ioctl(s, TIOCSCTTY, NULL) < 0)
|
||||||
die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
|
die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
|
||||||
close(s);
|
if (s > 2)
|
||||||
close(m);
|
close(s);
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
if (pledge("stdio getpw proc exec", NULL) == -1)
|
||||||
|
die("pledge\n");
|
||||||
|
#endif
|
||||||
execsh(cmd, args);
|
execsh(cmd, args);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
if (pledge("stdio rpath tty proc", NULL) == -1)
|
||||||
|
die("pledge\n");
|
||||||
|
#endif
|
||||||
close(s);
|
close(s);
|
||||||
cmdfd = m;
|
cmdfd = m;
|
||||||
signal(SIGCHLD, sigchld);
|
signal(SIGCHLD, sigchld);
|
||||||
@ -822,21 +819,25 @@ ttyread(void)
|
|||||||
{
|
{
|
||||||
static char buf[BUFSIZ];
|
static char buf[BUFSIZ];
|
||||||
static int buflen = 0;
|
static int buflen = 0;
|
||||||
int written;
|
int ret, written;
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* append read bytes to unprocessed bytes */
|
/* append read bytes to unprocessed bytes */
|
||||||
if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0)
|
ret = read(cmdfd, buf+buflen, LEN(buf)-buflen);
|
||||||
die("Couldn't read from shell: %s\n", strerror(errno));
|
|
||||||
buflen += ret;
|
|
||||||
|
|
||||||
written = twrite(buf, buflen, 0);
|
switch (ret) {
|
||||||
buflen -= written;
|
case 0:
|
||||||
/* keep any uncomplete utf8 char for the next call */
|
exit(0);
|
||||||
if (buflen > 0)
|
case -1:
|
||||||
memmove(buf, buf + written, buflen);
|
die("couldn't read from shell: %s\n", strerror(errno));
|
||||||
|
default:
|
||||||
return ret;
|
buflen += ret;
|
||||||
|
written = twrite(buf, buflen, 0);
|
||||||
|
buflen -= written;
|
||||||
|
/* keep any incomplete UTF-8 byte sequence for the next call */
|
||||||
|
if (buflen > 0)
|
||||||
|
memmove(buf, buf + written, buflen);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -938,7 +939,7 @@ ttyresize(int tw, int th)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ttyhangup()
|
ttyhangup(void)
|
||||||
{
|
{
|
||||||
/* Send SIGHUP to shell */
|
/* Send SIGHUP to shell */
|
||||||
kill(pid, SIGHUP);
|
kill(pid, SIGHUP);
|
||||||
@ -1096,30 +1097,20 @@ tscrollup(int orig, int n)
|
|||||||
void
|
void
|
||||||
selscroll(int orig, int n)
|
selscroll(int orig, int n)
|
||||||
{
|
{
|
||||||
if (sel.ob.x == -1)
|
if (sel.ob.x == -1 || sel.alt != IS_SET(MODE_ALTSCREEN))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) {
|
if (BETWEEN(sel.nb.y, orig, term.bot) != BETWEEN(sel.ne.y, orig, term.bot)) {
|
||||||
if ((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) {
|
selclear();
|
||||||
|
} else if (BETWEEN(sel.nb.y, orig, term.bot)) {
|
||||||
|
sel.ob.y += n;
|
||||||
|
sel.oe.y += n;
|
||||||
|
if (sel.ob.y < term.top || sel.ob.y > term.bot ||
|
||||||
|
sel.oe.y < term.top || sel.oe.y > term.bot) {
|
||||||
selclear();
|
selclear();
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sel.type == SEL_RECTANGULAR) {
|
|
||||||
if (sel.ob.y < term.top)
|
|
||||||
sel.ob.y = term.top;
|
|
||||||
if (sel.oe.y > term.bot)
|
|
||||||
sel.oe.y = term.bot;
|
|
||||||
} else {
|
} else {
|
||||||
if (sel.ob.y < term.top) {
|
selnormalize();
|
||||||
sel.ob.y = term.top;
|
|
||||||
sel.ob.x = 0;
|
|
||||||
}
|
|
||||||
if (sel.oe.y > term.bot) {
|
|
||||||
sel.oe.y = term.bot;
|
|
||||||
sel.oe.x = term.col;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
selnormalize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1141,6 +1132,7 @@ csiparse(void)
|
|||||||
{
|
{
|
||||||
char *p = csiescseq.buf, *np;
|
char *p = csiescseq.buf, *np;
|
||||||
long int v;
|
long int v;
|
||||||
|
int sep = ';'; /* colon or semi-colon, but not both */
|
||||||
|
|
||||||
csiescseq.narg = 0;
|
csiescseq.narg = 0;
|
||||||
if (*p == '?') {
|
if (*p == '?') {
|
||||||
@ -1158,7 +1150,9 @@ csiparse(void)
|
|||||||
v = -1;
|
v = -1;
|
||||||
csiescseq.arg[csiescseq.narg++] = v;
|
csiescseq.arg[csiescseq.narg++] = v;
|
||||||
p = np;
|
p = np;
|
||||||
if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ)
|
if (sep == ';' && *p == ':')
|
||||||
|
sep = ':'; /* allow override to colon once */
|
||||||
|
if (*p != sep || csiescseq.narg == ESC_ARG_SIZ)
|
||||||
break;
|
break;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@ -1191,9 +1185,9 @@ tmoveto(int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tsetchar(Rune u, Glyph *attr, int x, int y)
|
tsetchar(Rune u, const Glyph *attr, int x, int y)
|
||||||
{
|
{
|
||||||
static char *vt100_0[62] = { /* 0x41 - 0x7e */
|
static const char *vt100_0[62] = { /* 0x41 - 0x7e */
|
||||||
"↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
|
"↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
|
0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, /* P - W */
|
0, 0, 0, 0, 0, 0, 0, 0, /* P - W */
|
||||||
@ -1305,7 +1299,7 @@ tdeleteline(int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
tdefcolor(int *attr, int *npar, int l)
|
tdefcolor(const int *attr, int *npar, int l)
|
||||||
{
|
{
|
||||||
int32_t idx = -1;
|
int32_t idx = -1;
|
||||||
uint r, g, b;
|
uint r, g, b;
|
||||||
@ -1355,7 +1349,7 @@ tdefcolor(int *attr, int *npar, int l)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tsetattr(int *attr, int l)
|
tsetattr(const int *attr, int l)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int32_t idx;
|
int32_t idx;
|
||||||
@ -1448,7 +1442,8 @@ tsetattr(int *attr, int l)
|
|||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"erresc(default): gfx attr %d unknown\n",
|
"erresc(default): gfx attr %d unknown\n",
|
||||||
attr[i]), csidump();
|
attr[i]);
|
||||||
|
csidump();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1472,9 +1467,9 @@ tsetscroll(int t, int b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tsetmode(int priv, int set, int *args, int narg)
|
tsetmode(int priv, int set, const int *args, int narg)
|
||||||
{
|
{
|
||||||
int alt, *lim;
|
int alt; const int *lim;
|
||||||
|
|
||||||
for (lim = args + narg; args < lim; ++args) {
|
for (lim = args + narg; args < lim; ++args) {
|
||||||
if (priv) {
|
if (priv) {
|
||||||
@ -1568,6 +1563,7 @@ tsetmode(int priv, int set, int *args, int narg)
|
|||||||
case 1015: /* urxvt mangled mouse mode; incompatible
|
case 1015: /* urxvt mangled mouse mode; incompatible
|
||||||
and can be mistaken for other control
|
and can be mistaken for other control
|
||||||
codes. */
|
codes. */
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"erresc: unknown private set/reset mode %d\n",
|
"erresc: unknown private set/reset mode %d\n",
|
||||||
@ -1649,6 +1645,12 @@ csihandle(void)
|
|||||||
if (csiescseq.arg[0] == 0)
|
if (csiescseq.arg[0] == 0)
|
||||||
ttywrite(vtiden, strlen(vtiden), 0);
|
ttywrite(vtiden, strlen(vtiden), 0);
|
||||||
break;
|
break;
|
||||||
|
case 'b': /* REP -- if last char is printable print it <n> more times */
|
||||||
|
LIMIT(csiescseq.arg[0], 1, 65535);
|
||||||
|
if (term.lastc)
|
||||||
|
while (csiescseq.arg[0]-- > 0)
|
||||||
|
tputc(term.lastc);
|
||||||
|
break;
|
||||||
case 'C': /* CUF -- Cursor <n> Forward */
|
case 'C': /* CUF -- Cursor <n> Forward */
|
||||||
case 'a': /* HPR -- Cursor <n> Forward */
|
case 'a': /* HPR -- Cursor <n> Forward */
|
||||||
DEFAULT(csiescseq.arg[0], 1);
|
DEFAULT(csiescseq.arg[0], 1);
|
||||||
@ -1703,7 +1705,7 @@ csihandle(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1: /* above */
|
case 1: /* above */
|
||||||
if (term.c.y > 1)
|
if (term.c.y > 0)
|
||||||
tclearregion(0, 0, term.col-1, term.c.y-1);
|
tclearregion(0, 0, term.col-1, term.c.y-1);
|
||||||
tclearregion(0, term.c.y, term.c.x, term.c.y);
|
tclearregion(0, term.c.y, term.c.x, term.c.y);
|
||||||
break;
|
break;
|
||||||
@ -1729,6 +1731,7 @@ csihandle(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'S': /* SU -- Scroll <n> line up */
|
case 'S': /* SU -- Scroll <n> line up */
|
||||||
|
if (csiescseq.priv) break;
|
||||||
DEFAULT(csiescseq.arg[0], 1);
|
DEFAULT(csiescseq.arg[0], 1);
|
||||||
tscrollup(term.top, csiescseq.arg[0]);
|
tscrollup(term.top, csiescseq.arg[0]);
|
||||||
break;
|
break;
|
||||||
@ -1770,11 +1773,18 @@ csihandle(void)
|
|||||||
case 'm': /* SGR -- Terminal attribute (color) */
|
case 'm': /* SGR -- Terminal attribute (color) */
|
||||||
tsetattr(csiescseq.arg, csiescseq.narg);
|
tsetattr(csiescseq.arg, csiescseq.narg);
|
||||||
break;
|
break;
|
||||||
case 'n': /* DSR – Device Status Report (cursor position) */
|
case 'n': /* DSR -- Device Status Report */
|
||||||
if (csiescseq.arg[0] == 6) {
|
switch (csiescseq.arg[0]) {
|
||||||
len = snprintf(buf, sizeof(buf),"\033[%i;%iR",
|
case 5: /* Status Report "OK" `0n` */
|
||||||
term.c.y+1, term.c.x+1);
|
ttywrite("\033[0n", sizeof("\033[0n") - 1, 0);
|
||||||
|
break;
|
||||||
|
case 6: /* Report Cursor Position (CPR) "<row>;<column>R" */
|
||||||
|
len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
|
||||||
|
term.c.y+1, term.c.x+1);
|
||||||
ttywrite(buf, len, 0);
|
ttywrite(buf, len, 0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto unknown;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'r': /* DECSTBM -- Set Scrolling Region */
|
case 'r': /* DECSTBM -- Set Scrolling Region */
|
||||||
@ -1791,7 +1801,11 @@ csihandle(void)
|
|||||||
tcursor(CURSOR_SAVE);
|
tcursor(CURSOR_SAVE);
|
||||||
break;
|
break;
|
||||||
case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
|
case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
|
||||||
tcursor(CURSOR_LOAD);
|
if (csiescseq.priv) {
|
||||||
|
goto unknown;
|
||||||
|
} else {
|
||||||
|
tcursor(CURSOR_LOAD);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ' ':
|
case ' ':
|
||||||
switch (csiescseq.mode[1]) {
|
switch (csiescseq.mode[1]) {
|
||||||
@ -1809,7 +1823,7 @@ csihandle(void)
|
|||||||
void
|
void
|
||||||
csidump(void)
|
csidump(void)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
uint c;
|
uint c;
|
||||||
|
|
||||||
fprintf(stderr, "ESC[");
|
fprintf(stderr, "ESC[");
|
||||||
@ -1836,11 +1850,41 @@ csireset(void)
|
|||||||
memset(&csiescseq, 0, sizeof(csiescseq));
|
memset(&csiescseq, 0, sizeof(csiescseq));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
osc_color_response(int num, int index, int is_osc4)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
char buf[32];
|
||||||
|
unsigned char r, g, b;
|
||||||
|
|
||||||
|
if (xgetcolor(is_osc4 ? num : index, &r, &g, &b)) {
|
||||||
|
fprintf(stderr, "erresc: failed to fetch %s color %d\n",
|
||||||
|
is_osc4 ? "osc4" : "osc",
|
||||||
|
is_osc4 ? num : index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = snprintf(buf, sizeof buf, "\033]%s%d;rgb:%02x%02x/%02x%02x/%02x%02x\007",
|
||||||
|
is_osc4 ? "4;" : "", num, r, r, g, g, b, b);
|
||||||
|
if (n < 0 || n >= sizeof(buf)) {
|
||||||
|
fprintf(stderr, "error: %s while printing %s response\n",
|
||||||
|
n < 0 ? "snprintf failed" : "truncation occurred",
|
||||||
|
is_osc4 ? "osc4" : "osc");
|
||||||
|
} else {
|
||||||
|
ttywrite(buf, n, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
strhandle(void)
|
strhandle(void)
|
||||||
{
|
{
|
||||||
char *p = NULL;
|
char *p = NULL, *dec;
|
||||||
int j, narg, par;
|
int j, narg, par;
|
||||||
|
const struct { int idx; char *str; } osc_table[] = {
|
||||||
|
{ defaultfg, "foreground" },
|
||||||
|
{ defaultbg, "background" },
|
||||||
|
{ defaultcs, "cursor" }
|
||||||
|
};
|
||||||
|
|
||||||
term.esc &= ~(ESC_STR_END|ESC_STR);
|
term.esc &= ~(ESC_STR_END|ESC_STR);
|
||||||
strparse();
|
strparse();
|
||||||
@ -1850,15 +1894,21 @@ strhandle(void)
|
|||||||
case ']': /* OSC -- Operating System Command */
|
case ']': /* OSC -- Operating System Command */
|
||||||
switch (par) {
|
switch (par) {
|
||||||
case 0:
|
case 0:
|
||||||
|
if (narg > 1) {
|
||||||
|
xsettitle(strescseq.args[1]);
|
||||||
|
xseticontitle(strescseq.args[1]);
|
||||||
|
}
|
||||||
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
|
if (narg > 1)
|
||||||
|
xseticontitle(strescseq.args[1]);
|
||||||
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
if (narg > 1)
|
if (narg > 1)
|
||||||
xsettitle(strescseq.args[1]);
|
xsettitle(strescseq.args[1]);
|
||||||
return;
|
return;
|
||||||
case 52:
|
case 52:
|
||||||
if (narg > 2) {
|
if (narg > 2 && allowwindowops) {
|
||||||
char *dec;
|
|
||||||
|
|
||||||
dec = base64dec(strescseq.args[2]);
|
dec = base64dec(strescseq.args[2]);
|
||||||
if (dec) {
|
if (dec) {
|
||||||
xsetsel(dec);
|
xsetsel(dec);
|
||||||
@ -1868,21 +1918,47 @@ strhandle(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
case 10:
|
||||||
|
case 11:
|
||||||
|
case 12:
|
||||||
|
if (narg < 2)
|
||||||
|
break;
|
||||||
|
p = strescseq.args[1];
|
||||||
|
if ((j = par - 10) < 0 || j >= LEN(osc_table))
|
||||||
|
break; /* shouldn't be possible */
|
||||||
|
|
||||||
|
if (!strcmp(p, "?")) {
|
||||||
|
osc_color_response(par, osc_table[j].idx, 0);
|
||||||
|
} else if (xsetcolorname(osc_table[j].idx, p)) {
|
||||||
|
fprintf(stderr, "erresc: invalid %s color: %s\n",
|
||||||
|
osc_table[j].str, p);
|
||||||
|
} else {
|
||||||
|
tfulldirt();
|
||||||
|
}
|
||||||
|
return;
|
||||||
case 4: /* color set */
|
case 4: /* color set */
|
||||||
if (narg < 3)
|
if (narg < 3)
|
||||||
break;
|
break;
|
||||||
p = strescseq.args[2];
|
p = strescseq.args[2];
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case 104: /* color reset, here p = NULL */
|
case 104: /* color reset */
|
||||||
j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
|
j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
|
||||||
if (xsetcolorname(j, p)) {
|
|
||||||
fprintf(stderr, "erresc: invalid color %s\n", p);
|
if (p && !strcmp(p, "?")) {
|
||||||
|
osc_color_response(j, 0, 1);
|
||||||
|
} else if (xsetcolorname(j, p)) {
|
||||||
|
if (par == 104 && narg <= 1) {
|
||||||
|
xloadcols();
|
||||||
|
return; /* color reset without parameter */
|
||||||
|
}
|
||||||
|
fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
|
||||||
|
j, p ? p : "(null)");
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* TODO if defaultbg color is changed, borders
|
* TODO if defaultbg color is changed, borders
|
||||||
* are dirty
|
* are dirty
|
||||||
*/
|
*/
|
||||||
redraw();
|
tfulldirt();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1891,7 +1967,6 @@ strhandle(void)
|
|||||||
xsettitle(strescseq.args[0]);
|
xsettitle(strescseq.args[0]);
|
||||||
return;
|
return;
|
||||||
case 'P': /* DCS -- Device Control String */
|
case 'P': /* DCS -- Device Control String */
|
||||||
term.mode |= ESC_DCS;
|
|
||||||
case '_': /* APC -- Application Program Command */
|
case '_': /* APC -- Application Program Command */
|
||||||
case '^': /* PM -- Privacy Message */
|
case '^': /* PM -- Privacy Message */
|
||||||
return;
|
return;
|
||||||
@ -1926,7 +2001,7 @@ strparse(void)
|
|||||||
void
|
void
|
||||||
strdump(void)
|
strdump(void)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
uint c;
|
uint c;
|
||||||
|
|
||||||
fprintf(stderr, "ESC%c", strescseq.type);
|
fprintf(stderr, "ESC%c", strescseq.type);
|
||||||
@ -1953,7 +2028,10 @@ strdump(void)
|
|||||||
void
|
void
|
||||||
strreset(void)
|
strreset(void)
|
||||||
{
|
{
|
||||||
memset(&strescseq, 0, sizeof(strescseq));
|
strescseq = (STREscape){
|
||||||
|
.buf = xrealloc(strescseq.buf, STR_BUF_SIZ),
|
||||||
|
.siz = STR_BUF_SIZ,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1973,28 +2051,6 @@ tprinter(char *s, size_t len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
iso14755(const Arg *arg)
|
|
||||||
{
|
|
||||||
FILE *p;
|
|
||||||
char *us, *e, codepoint[9], uc[UTF_SIZ];
|
|
||||||
unsigned long utf32;
|
|
||||||
|
|
||||||
if (!(p = popen(ISO14755CMD, "r")))
|
|
||||||
return;
|
|
||||||
|
|
||||||
us = fgets(codepoint, sizeof(codepoint), p);
|
|
||||||
pclose(p);
|
|
||||||
|
|
||||||
if (!us || *us == '\0' || *us == '-' || strlen(us) > 7)
|
|
||||||
return;
|
|
||||||
if ((utf32 = strtoul(us, &e, 16)) == ULONG_MAX ||
|
|
||||||
(*e != '\n' && *e != '\0'))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ttywrite(uc, utf8encode(utf32, uc), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
toggleprinter(const Arg *arg)
|
toggleprinter(const Arg *arg)
|
||||||
{
|
{
|
||||||
@ -2028,12 +2084,12 @@ void
|
|||||||
tdumpline(int n)
|
tdumpline(int n)
|
||||||
{
|
{
|
||||||
char buf[UTF_SIZ];
|
char buf[UTF_SIZ];
|
||||||
Glyph *bp, *end;
|
const Glyph *bp, *end;
|
||||||
|
|
||||||
bp = &term.line[n][0];
|
bp = &term.line[n][0];
|
||||||
end = &bp[MIN(tlinelen(n), term.col) - 1];
|
end = &bp[MIN(tlinelen(n), term.col) - 1];
|
||||||
if (bp != end || bp->u != ' ') {
|
if (bp != end || bp->u != ' ') {
|
||||||
for ( ;bp <= end; ++bp)
|
for ( ; bp <= end; ++bp)
|
||||||
tprinter(buf, utf8encode(bp->u, buf));
|
tprinter(buf, utf8encode(bp->u, buf));
|
||||||
}
|
}
|
||||||
tprinter("\n", 1);
|
tprinter("\n", 1);
|
||||||
@ -2104,12 +2160,9 @@ tdectest(char c)
|
|||||||
void
|
void
|
||||||
tstrsequence(uchar c)
|
tstrsequence(uchar c)
|
||||||
{
|
{
|
||||||
strreset();
|
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0x90: /* DCS -- Device Control String */
|
case 0x90: /* DCS -- Device Control String */
|
||||||
c = 'P';
|
c = 'P';
|
||||||
term.esc |= ESC_DCS;
|
|
||||||
break;
|
break;
|
||||||
case 0x9f: /* APC -- Application Program Command */
|
case 0x9f: /* APC -- Application Program Command */
|
||||||
c = '_';
|
c = '_';
|
||||||
@ -2121,6 +2174,7 @@ tstrsequence(uchar c)
|
|||||||
c = ']';
|
c = ']';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
strreset();
|
||||||
strescseq.type = c;
|
strescseq.type = c;
|
||||||
term.esc |= ESC_STR;
|
term.esc |= ESC_STR;
|
||||||
}
|
}
|
||||||
@ -2163,6 +2217,7 @@ tcontrolcode(uchar ascii)
|
|||||||
return;
|
return;
|
||||||
case '\032': /* SUB */
|
case '\032': /* SUB */
|
||||||
tsetchar('?', &term.c.attr, term.c.x, term.c.y);
|
tsetchar('?', &term.c.attr, term.c.x, term.c.y);
|
||||||
|
/* FALLTHROUGH */
|
||||||
case '\030': /* CAN */
|
case '\030': /* CAN */
|
||||||
csireset();
|
csireset();
|
||||||
break;
|
break;
|
||||||
@ -2279,10 +2334,11 @@ eschandle(uchar ascii)
|
|||||||
case 'Z': /* DECID -- Identify Terminal */
|
case 'Z': /* DECID -- Identify Terminal */
|
||||||
ttywrite(vtiden, strlen(vtiden), 0);
|
ttywrite(vtiden, strlen(vtiden), 0);
|
||||||
break;
|
break;
|
||||||
case 'c': /* RIS -- Reset to inital state */
|
case 'c': /* RIS -- Reset to initial state */
|
||||||
treset();
|
treset();
|
||||||
resettitle();
|
resettitle();
|
||||||
xloadcols();
|
xloadcols();
|
||||||
|
xsetmode(0, MODE_HIDE);
|
||||||
break;
|
break;
|
||||||
case '=': /* DECPAM -- Application keypad */
|
case '=': /* DECPAM -- Application keypad */
|
||||||
xsetmode(1, MODE_APPKEYPAD);
|
xsetmode(1, MODE_APPKEYPAD);
|
||||||
@ -2317,15 +2373,13 @@ tputc(Rune u)
|
|||||||
Glyph *gp;
|
Glyph *gp;
|
||||||
|
|
||||||
control = ISCONTROL(u);
|
control = ISCONTROL(u);
|
||||||
if (!IS_SET(MODE_UTF8) && !IS_SET(MODE_SIXEL)) {
|
if (u < 127 || !IS_SET(MODE_UTF8)) {
|
||||||
c[0] = u;
|
c[0] = u;
|
||||||
width = len = 1;
|
width = len = 1;
|
||||||
} else {
|
} else {
|
||||||
len = utf8encode(u, c);
|
len = utf8encode(u, c);
|
||||||
if (!control && (width = wcwidth(u)) == -1) {
|
if (!control && (width = wcwidth(u)) == -1)
|
||||||
memcpy(c, "\357\277\275", 4); /* UTF_INVALID */
|
|
||||||
width = 1;
|
width = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_SET(MODE_PRINT))
|
if (IS_SET(MODE_PRINT))
|
||||||
@ -2340,25 +2394,12 @@ tputc(Rune u)
|
|||||||
if (term.esc & ESC_STR) {
|
if (term.esc & ESC_STR) {
|
||||||
if (u == '\a' || u == 030 || u == 032 || u == 033 ||
|
if (u == '\a' || u == 030 || u == 032 || u == 033 ||
|
||||||
ISCONTROLC1(u)) {
|
ISCONTROLC1(u)) {
|
||||||
term.esc &= ~(ESC_START|ESC_STR|ESC_DCS);
|
term.esc &= ~(ESC_START|ESC_STR);
|
||||||
if (IS_SET(MODE_SIXEL)) {
|
|
||||||
/* TODO: render sixel */;
|
|
||||||
term.mode &= ~MODE_SIXEL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
term.esc |= ESC_STR_END;
|
term.esc |= ESC_STR_END;
|
||||||
goto check_control_code;
|
goto check_control_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strescseq.len+len >= strescseq.siz) {
|
||||||
if (IS_SET(MODE_SIXEL)) {
|
|
||||||
/* TODO: implement sixel mode */
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (term.esc&ESC_DCS && strescseq.len == 0 && u == 'q')
|
|
||||||
term.mode |= MODE_SIXEL;
|
|
||||||
|
|
||||||
if (strescseq.len+len >= sizeof(strescseq.buf)-1) {
|
|
||||||
/*
|
/*
|
||||||
* Here is a bug in terminals. If the user never sends
|
* Here is a bug in terminals. If the user never sends
|
||||||
* some code to stop the str or esc command, then st
|
* some code to stop the str or esc command, then st
|
||||||
@ -2372,7 +2413,10 @@ tputc(Rune u)
|
|||||||
* term.esc = 0;
|
* term.esc = 0;
|
||||||
* strhandle();
|
* strhandle();
|
||||||
*/
|
*/
|
||||||
return;
|
if (strescseq.siz > (SIZE_MAX - UTF_SIZ) / 2)
|
||||||
|
return;
|
||||||
|
strescseq.siz *= 2;
|
||||||
|
strescseq.buf = xrealloc(strescseq.buf, strescseq.siz);
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(&strescseq.buf[strescseq.len], c, len);
|
memmove(&strescseq.buf[strescseq.len], c, len);
|
||||||
@ -2387,10 +2431,15 @@ check_control_code:
|
|||||||
* they must not cause conflicts with sequences.
|
* they must not cause conflicts with sequences.
|
||||||
*/
|
*/
|
||||||
if (control) {
|
if (control) {
|
||||||
|
/* in UTF-8 mode ignore handling C1 control characters */
|
||||||
|
if (IS_SET(MODE_UTF8) && ISCONTROLC1(u))
|
||||||
|
return;
|
||||||
tcontrolcode(u);
|
tcontrolcode(u);
|
||||||
/*
|
/*
|
||||||
* control codes are not shown ever
|
* control codes are not shown ever
|
||||||
*/
|
*/
|
||||||
|
if (!term.esc)
|
||||||
|
term.lastc = 0;
|
||||||
return;
|
return;
|
||||||
} else if (term.esc & ESC_START) {
|
} else if (term.esc & ESC_START) {
|
||||||
if (term.esc & ESC_CSI) {
|
if (term.esc & ESC_CSI) {
|
||||||
@ -2421,7 +2470,7 @@ check_control_code:
|
|||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y))
|
if (selected(term.c.x, term.c.y))
|
||||||
selclear();
|
selclear();
|
||||||
|
|
||||||
gp = &term.line[term.c.y][term.c.x];
|
gp = &term.line[term.c.y][term.c.x];
|
||||||
@ -2431,19 +2480,29 @@ check_control_code:
|
|||||||
gp = &term.line[term.c.y][term.c.x];
|
gp = &term.line[term.c.y][term.c.x];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_SET(MODE_INSERT) && term.c.x+width < term.col)
|
if (IS_SET(MODE_INSERT) && term.c.x+width < term.col) {
|
||||||
memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph));
|
memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph));
|
||||||
|
gp->mode &= ~ATTR_WIDE;
|
||||||
|
}
|
||||||
|
|
||||||
if (term.c.x+width > term.col) {
|
if (term.c.x+width > term.col) {
|
||||||
tnewline(1);
|
if (IS_SET(MODE_WRAP))
|
||||||
|
tnewline(1);
|
||||||
|
else
|
||||||
|
tmoveto(term.col - width, term.c.y);
|
||||||
gp = &term.line[term.c.y][term.c.x];
|
gp = &term.line[term.c.y][term.c.x];
|
||||||
}
|
}
|
||||||
|
|
||||||
tsetchar(u, &term.c.attr, term.c.x, term.c.y);
|
tsetchar(u, &term.c.attr, term.c.x, term.c.y);
|
||||||
|
term.lastc = u;
|
||||||
|
|
||||||
if (width == 2) {
|
if (width == 2) {
|
||||||
gp->mode |= ATTR_WIDE;
|
gp->mode |= ATTR_WIDE;
|
||||||
if (term.c.x+1 < term.col) {
|
if (term.c.x+1 < term.col) {
|
||||||
|
if (gp[1].mode == ATTR_WIDE && term.c.x+2 < term.col) {
|
||||||
|
gp[2].u = ' ';
|
||||||
|
gp[2].mode &= ~ATTR_WDUMMY;
|
||||||
|
}
|
||||||
gp[1].u = '\0';
|
gp[1].u = '\0';
|
||||||
gp[1].mode = ATTR_WDUMMY;
|
gp[1].mode = ATTR_WDUMMY;
|
||||||
}
|
}
|
||||||
@ -2463,7 +2522,7 @@ twrite(const char *buf, int buflen, int show_ctrl)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
for (n = 0; n < buflen; n += charsize) {
|
for (n = 0; n < buflen; n += charsize) {
|
||||||
if (IS_SET(MODE_UTF8) && !IS_SET(MODE_SIXEL)) {
|
if (IS_SET(MODE_UTF8)) {
|
||||||
/* process a complete utf8 char */
|
/* process a complete utf8 char */
|
||||||
charsize = utf8decode(buf + n, &u, buflen - n);
|
charsize = utf8decode(buf + n, &u, buflen - n);
|
||||||
if (charsize == 0)
|
if (charsize == 0)
|
||||||
@ -2579,6 +2638,7 @@ void
|
|||||||
drawregion(int x1, int y1, int x2, int y2)
|
drawregion(int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
for (y = y1; y < y2; y++) {
|
for (y = y1; y < y2; y++) {
|
||||||
if (!term.dirty[y])
|
if (!term.dirty[y])
|
||||||
continue;
|
continue;
|
||||||
@ -2591,7 +2651,7 @@ drawregion(int x1, int y1, int x2, int y2)
|
|||||||
void
|
void
|
||||||
draw(void)
|
draw(void)
|
||||||
{
|
{
|
||||||
int cx = term.c.x;
|
int cx = term.c.x, ocx = term.ocx, ocy = term.ocy;
|
||||||
|
|
||||||
if (!xstartdraw())
|
if (!xstartdraw())
|
||||||
return;
|
return;
|
||||||
@ -2607,8 +2667,11 @@ draw(void)
|
|||||||
drawregion(0, 0, term.col, term.row);
|
drawregion(0, 0, term.col, term.row);
|
||||||
xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
|
xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
|
||||||
term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
|
term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
|
||||||
term.ocx = cx, term.ocy = term.c.y;
|
term.ocx = cx;
|
||||||
|
term.ocy = term.c.y;
|
||||||
xfinishdraw();
|
xfinishdraw();
|
||||||
|
if (ocx != term.ocx || ocy != term.ocy)
|
||||||
|
xximspot(term.ocx, term.ocy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
11
st.h
11
st.h
@ -74,13 +74,13 @@ typedef union {
|
|||||||
uint ui;
|
uint ui;
|
||||||
float f;
|
float f;
|
||||||
const void *v;
|
const void *v;
|
||||||
|
const char *s;
|
||||||
} Arg;
|
} Arg;
|
||||||
|
|
||||||
void die(const char *, ...);
|
void die(const char *, ...);
|
||||||
void redraw(void);
|
void redraw(void);
|
||||||
void draw(void);
|
void draw(void);
|
||||||
|
|
||||||
void iso14755(const Arg *);
|
|
||||||
void printscreen(const Arg *);
|
void printscreen(const Arg *);
|
||||||
void printsel(const Arg *);
|
void printsel(const Arg *);
|
||||||
void sendbreak(const Arg *);
|
void sendbreak(const Arg *);
|
||||||
@ -91,7 +91,7 @@ void tnew(int, int);
|
|||||||
void tresize(int, int);
|
void tresize(int, int);
|
||||||
void tsetdirtattr(int);
|
void tsetdirtattr(int);
|
||||||
void ttyhangup(void);
|
void ttyhangup(void);
|
||||||
int ttynew(char *, char *, char *, char **);
|
int ttynew(const char *, char *, const char *, char **);
|
||||||
size_t ttyread(void);
|
size_t ttyread(void);
|
||||||
void ttyresize(int, int);
|
void ttyresize(int, int);
|
||||||
void ttywrite(const char *, size_t, int);
|
void ttywrite(const char *, size_t, int);
|
||||||
@ -109,15 +109,18 @@ size_t utf8encode(Rune, char *);
|
|||||||
|
|
||||||
void *xmalloc(size_t);
|
void *xmalloc(size_t);
|
||||||
void *xrealloc(void *, size_t);
|
void *xrealloc(void *, size_t);
|
||||||
char *xstrdup(char *);
|
char *xstrdup(const char *);
|
||||||
|
|
||||||
/* config.h globals */
|
/* config.h globals */
|
||||||
extern char *utmp;
|
extern char *utmp;
|
||||||
|
extern char *scroll;
|
||||||
extern char *stty_args;
|
extern char *stty_args;
|
||||||
extern char *vtiden;
|
extern char *vtiden;
|
||||||
extern char *worddelimiters;
|
extern wchar_t *worddelimiters;
|
||||||
extern int allowaltscreen;
|
extern int allowaltscreen;
|
||||||
|
extern int allowwindowops;
|
||||||
extern char *termname;
|
extern char *termname;
|
||||||
extern unsigned int tabspaces;
|
extern unsigned int tabspaces;
|
||||||
extern unsigned int defaultfg;
|
extern unsigned int defaultfg;
|
||||||
extern unsigned int defaultbg;
|
extern unsigned int defaultbg;
|
||||||
|
extern unsigned int defaultcs;
|
||||||
|
41
st.info
41
st.info
@ -1,4 +1,4 @@
|
|||||||
st| simpleterm,
|
st-mono| simpleterm monocolor,
|
||||||
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
||||||
am,
|
am,
|
||||||
bce,
|
bce,
|
||||||
@ -10,7 +10,7 @@ st| simpleterm,
|
|||||||
civis=\E[?25l,
|
civis=\E[?25l,
|
||||||
clear=\E[H\E[2J,
|
clear=\E[H\E[2J,
|
||||||
cnorm=\E[?12l\E[?25h,
|
cnorm=\E[?12l\E[?25h,
|
||||||
colors#8,
|
colors#2,
|
||||||
cols#80,
|
cols#80,
|
||||||
cr=^M,
|
cr=^M,
|
||||||
csr=\E[%i%p1%d;%p2%dr,
|
csr=\E[%i%p1%d;%p2%dr,
|
||||||
@ -158,6 +158,7 @@ st| simpleterm,
|
|||||||
rc=\E8,
|
rc=\E8,
|
||||||
rev=\E[7m,
|
rev=\E[7m,
|
||||||
ri=\EM,
|
ri=\EM,
|
||||||
|
rin=\E[%p1%dT,
|
||||||
ritm=\E[23m,
|
ritm=\E[23m,
|
||||||
rmacs=\E(B,
|
rmacs=\E(B,
|
||||||
rmcup=\E[?1049l,
|
rmcup=\E[?1049l,
|
||||||
@ -168,13 +169,8 @@ st| simpleterm,
|
|||||||
rs1=\Ec,
|
rs1=\Ec,
|
||||||
rs2=\E[4l\E>\E[?1034l,
|
rs2=\E[4l\E>\E[?1034l,
|
||||||
sc=\E7,
|
sc=\E7,
|
||||||
setab=\E[4%p1%dm,
|
|
||||||
setaf=\E[3%p1%dm,
|
|
||||||
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
|
||||||
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
|
||||||
sgr0=\E[0m,
|
|
||||||
sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
|
|
||||||
sitm=\E[3m,
|
sitm=\E[3m,
|
||||||
|
sgr0=\E[0m,
|
||||||
smacs=\E(0,
|
smacs=\E(0,
|
||||||
smcup=\E[?1049h,
|
smcup=\E[?1049h,
|
||||||
smir=\E[4h,
|
smir=\E[4h,
|
||||||
@ -188,11 +184,26 @@ st| simpleterm,
|
|||||||
# XTerm extensions
|
# XTerm extensions
|
||||||
rmxx=\E[29m,
|
rmxx=\E[29m,
|
||||||
smxx=\E[9m,
|
smxx=\E[9m,
|
||||||
|
BE=\E[?2004h,
|
||||||
|
BD=\E[?2004l,
|
||||||
|
PS=\E[200~,
|
||||||
|
PE=\E[201~,
|
||||||
|
# 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)
|
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
|
||||||
Se,
|
|
||||||
Ss,
|
|
||||||
Tc,
|
Tc,
|
||||||
Ms=\E]52;%p1%s;%p2%s\007,
|
Ms=\E]52;%p1%s;%p2%s\007,
|
||||||
|
Se=\E[2 q,
|
||||||
|
Ss=\E[%p1%d q,
|
||||||
|
|
||||||
|
st| simpleterm,
|
||||||
|
use=st-mono,
|
||||||
|
colors#8,
|
||||||
|
setab=\E[4%p1%dm,
|
||||||
|
setaf=\E[3%p1%dm,
|
||||||
|
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
||||||
|
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
||||||
|
sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
|
||||||
|
|
||||||
st-256color| simpleterm with 256 colors,
|
st-256color| simpleterm with 256 colors,
|
||||||
use=st,
|
use=st,
|
||||||
@ -220,3 +231,13 @@ st-meta-256color| simpleterm with meta key and 256 colors,
|
|||||||
smm=\E[?1034h,
|
smm=\E[?1034h,
|
||||||
rs2=\E[4l\E>\E[?1034h,
|
rs2=\E[4l\E>\E[?1034h,
|
||||||
is2=\E[4l\E>\E[?1034h,
|
is2=\E[4l\E>\E[?1034h,
|
||||||
|
|
||||||
|
st-bs| simpleterm with backspace as backspace,
|
||||||
|
use=st,
|
||||||
|
kbs=\010,
|
||||||
|
kdch1=\177,
|
||||||
|
|
||||||
|
st-bs-256color| simpleterm with backspace as backspace and 256colors,
|
||||||
|
use=st-256color,
|
||||||
|
kbs=\010,
|
||||||
|
kdch1=\177,
|
||||||
|
3
win.h
3
win.h
@ -30,9 +30,12 @@ void xdrawline(Line, int, int, int);
|
|||||||
void xfinishdraw(void);
|
void xfinishdraw(void);
|
||||||
void xloadcols(void);
|
void xloadcols(void);
|
||||||
int xsetcolorname(int, const char *);
|
int xsetcolorname(int, const char *);
|
||||||
|
int xgetcolor(int, unsigned char *, unsigned char *, unsigned char *);
|
||||||
|
void xseticontitle(char *);
|
||||||
void xsettitle(char *);
|
void xsettitle(char *);
|
||||||
int xsetcursor(int);
|
int xsetcursor(int);
|
||||||
void xsetmode(int, unsigned int);
|
void xsetmode(int, unsigned int);
|
||||||
void xsetpointermotion(int);
|
void xsetpointermotion(int);
|
||||||
void xsetsel(char *);
|
void xsetsel(char *);
|
||||||
int xstartdraw(void);
|
int xstartdraw(void);
|
||||||
|
void xximspot(int, int);
|
||||||
|
Reference in New Issue
Block a user