Compare commits
No commits in common. "master" and "0.8.3" have entirely different histories.
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
config.h
|
|
||||||
*.o
|
|
||||||
st
|
|
66
FAQ
66
FAQ
@ -2,14 +2,12 @@
|
|||||||
|
|
||||||
Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task.
|
Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task.
|
||||||
|
|
||||||
|
|
||||||
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
|
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
|
||||||
|
|
||||||
It means that st doesn’t have any terminfo entry on your system. Chances are
|
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
|
||||||
@ -17,7 +15,6 @@ 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.
|
||||||
|
|
||||||
|
|
||||||
## How do I scroll back up?
|
## How do I scroll back up?
|
||||||
|
|
||||||
* Using a terminal multiplexer.
|
* Using a terminal multiplexer.
|
||||||
@ -26,12 +23,10 @@ you can manually run `tic -sx st.info`.
|
|||||||
* Using the excellent tool of [scroll](https://git.suckless.org/scroll/).
|
* Using the excellent tool of [scroll](https://git.suckless.org/scroll/).
|
||||||
* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/).
|
* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/).
|
||||||
|
|
||||||
|
|
||||||
## I would like to have utmp and/or scroll functionality by default
|
## 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
|
You can add the absolute patch of both programs in your config.h
|
||||||
have to modify the value of utmp and scroll variables.
|
file. You only have to modify the value of utmp and scroll variables.
|
||||||
|
|
||||||
|
|
||||||
## Why doesn't the Del key work in some programs?
|
## Why doesn't the Del key work in some programs?
|
||||||
|
|
||||||
@ -88,14 +83,12 @@ 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
|
||||||
@ -104,7 +97,6 @@ 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
|
||||||
@ -166,60 +158,19 @@ 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] https://st.suckless.org/patches/delkey
|
[1] https://st.suckless.org/patches/delkey
|
||||||
|
|
||||||
|
## Why do images not work in st (in programs such as w3m)?
|
||||||
|
|
||||||
## Why do images not work in st using the w3m image hack?
|
This is a terrible hack that overdraws an image on top of the terminal emulator
|
||||||
|
window. It also relies on a very specific way the terminal draws it's contents.
|
||||||
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);
|
|
||||||
|
|
||||||
|
A more proper (but limited way) would be using sixels. Which st doesn't
|
||||||
|
support.
|
||||||
|
|
||||||
## BadLength X error in Xft when trying to render emoji
|
## BadLength X error in Xft when trying to render emoji
|
||||||
|
|
||||||
@ -248,6 +199,3 @@ fonts:
|
|||||||
|
|
||||||
Please don't bother reporting this bug to st, but notify the upstream Xft
|
Please don't bother reporting this bug to st, but notify the upstream Xft
|
||||||
developers about fixing this bug.
|
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-2022 Hiltjo Posthuma <hiltjo at codemadness dot org>
|
© 2014-2018 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>
|
||||||
|
8
Makefile
8
Makefile
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = st.c x.c hb.c
|
SRC = st.c x.c
|
||||||
OBJ = $(SRC:.c=.o)
|
OBJ = $(SRC:.c=.o)
|
||||||
|
|
||||||
all: options st
|
all: options st
|
||||||
@ -22,8 +22,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 config.h st.h win.h hb.h
|
x.o: arg.h config.h st.h win.h
|
||||||
hb.o: st.h
|
|
||||||
|
|
||||||
$(OBJ): config.h config.mk
|
$(OBJ): config.h config.mk
|
||||||
|
|
||||||
@ -50,12 +49,9 @@ install: st
|
|||||||
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
|
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||||
tic -sx st.info
|
tic -sx st.info
|
||||||
@echo Please see the README file regarding the terminfo entry of st.
|
@echo Please see the README file regarding the terminfo entry of st.
|
||||||
mkdir -p $(DESTDIR)$(APPPREFIX)
|
|
||||||
cp -f st.desktop $(DESTDIR)$(APPPREFIX)
|
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f $(DESTDIR)$(PREFIX)/bin/st
|
rm -f $(DESTDIR)$(PREFIX)/bin/st
|
||||||
rm -f $(DESTDIR)$(APPPREFIX)/st.desktop
|
|
||||||
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||||
|
|
||||||
.PHONY: all options clean dist install uninstall
|
.PHONY: all options clean dist install uninstall
|
||||||
|
118
config.def.h
118
config.def.h
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||||
*/
|
*/
|
||||||
static char *font = "Fira Code:pixelsize=14:antialias=true:autohint=true";
|
static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
|
||||||
static int borderpx = 2;
|
static int borderpx = 2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -43,18 +43,9 @@ static unsigned int tripleclicktimeout = 600;
|
|||||||
/* alt screens */
|
/* alt screens */
|
||||||
int allowaltscreen = 1;
|
int allowaltscreen = 1;
|
||||||
|
|
||||||
/* allow certain non-interactive (insecure) window operations such as:
|
/* frames per second st should at maximum draw to the screen */
|
||||||
setting the clipboard text */
|
static unsigned int xfps = 120;
|
||||||
int allowwindowops = 0;
|
static unsigned int actionfps = 30;
|
||||||
|
|
||||||
/*
|
|
||||||
* draw latency range in ms - from new content/keypress/etc until drawing.
|
|
||||||
* within this range, st draws when content stops arriving (idle). mostly it's
|
|
||||||
* near minlatency, but it waits longer for slow updates to avoid partial draw.
|
|
||||||
* low minlatency will tear/flicker more, as it can "detect" idle too early.
|
|
||||||
*/
|
|
||||||
static double minlatency = 8;
|
|
||||||
static double maxlatency = 33;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
||||||
@ -93,60 +84,45 @@ char *termname = "st-256color";
|
|||||||
*/
|
*/
|
||||||
unsigned int tabspaces = 8;
|
unsigned int tabspaces = 8;
|
||||||
|
|
||||||
/* bg opacity */
|
|
||||||
float alpha = 0.8;
|
|
||||||
|
|
||||||
/* Terminal colors (16 first used in escape sequence) */
|
/* Terminal colors (16 first used in escape sequence) */
|
||||||
static const char *colorname[] = {
|
static const char *colorname[] = {
|
||||||
/* 8 normal colors */
|
/* 8 normal colors */
|
||||||
[0] = "#000000", /* black */
|
"black",
|
||||||
[1] = "#ff5555", /* red */
|
"red3",
|
||||||
[2] = "#50fa7b", /* green */
|
"green3",
|
||||||
[3] = "#f1fa8c", /* yellow */
|
"yellow3",
|
||||||
[4] = "#bd93f9", /* blue */
|
"blue2",
|
||||||
[5] = "#ff79c6", /* magenta */
|
"magenta3",
|
||||||
[6] = "#8be9fd", /* cyan */
|
"cyan3",
|
||||||
[7] = "#bbbbbb", /* white */
|
"gray90",
|
||||||
|
|
||||||
/* 8 bright colors */
|
/* 8 bright colors */
|
||||||
[8] = "#44475a", /* black */
|
"gray50",
|
||||||
[9] = "#ff5555", /* red */
|
"red",
|
||||||
[10] = "#50fa7b", /* green */
|
"green",
|
||||||
[11] = "#f1fa8c", /* yellow */
|
"yellow",
|
||||||
[12] = "#bd93f9", /* blue */
|
"#5c5cff",
|
||||||
[13] = "#ff79c6", /* magenta */
|
"magenta",
|
||||||
[14] = "#8be9fd", /* cyan */
|
"cyan",
|
||||||
[15] = "#ffffff", /* white */
|
"white",
|
||||||
|
|
||||||
/* special colors */
|
[255] = 0,
|
||||||
[256] = "#222222", /* background */
|
|
||||||
[257] = "#ffffff", /* foreground */
|
|
||||||
|
|
||||||
/* more colors can be added after 255 to use with DefaultXX */
|
/* more colors can be added after 255 to use with DefaultXX */
|
||||||
"#cccccc",
|
"#cccccc",
|
||||||
"#555555",
|
"#555555",
|
||||||
"gray90", /* default foreground colour */
|
|
||||||
"black", /* default background colour */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default colors (colorname index)
|
* Default colors (colorname index)
|
||||||
* foreground, background, cursor
|
* foreground, background, cursor, reverse cursor
|
||||||
*/
|
*/
|
||||||
unsigned int defaultfg = 257;
|
unsigned int defaultfg = 7;
|
||||||
unsigned int defaultbg = 256;
|
unsigned int defaultbg = 0;
|
||||||
unsigned int defaultcs = 257;
|
static unsigned int defaultcs = 256;
|
||||||
static unsigned int defaultrcs = 257;
|
static unsigned int defaultrcs = 257;
|
||||||
|
|
||||||
/*
|
|
||||||
* Colors used, when the specific fg == defaultfg. So in reverse mode this
|
|
||||||
* will reverse too. Another logic would only make the simple feature too
|
|
||||||
* complex.
|
|
||||||
*/
|
|
||||||
unsigned int defaultitalic = 7;
|
|
||||||
unsigned int defaultunderline = 7;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default shape of cursor
|
* Default shape of cursor
|
||||||
* 2: Block ("█")
|
* 2: Block ("█")
|
||||||
@ -183,54 +159,14 @@ static unsigned int defaultattr = 11;
|
|||||||
*/
|
*/
|
||||||
static uint forcemousemod = ShiftMask;
|
static uint forcemousemod = ShiftMask;
|
||||||
|
|
||||||
/*
|
|
||||||
* Xresources preferences to load at startup
|
|
||||||
*/
|
|
||||||
ResourcePref resources[] = {
|
|
||||||
{ "font", STRING, &font },
|
|
||||||
{ "color0", STRING, &colorname[0] },
|
|
||||||
{ "color1", STRING, &colorname[1] },
|
|
||||||
{ "color2", STRING, &colorname[2] },
|
|
||||||
{ "color3", STRING, &colorname[3] },
|
|
||||||
{ "color4", STRING, &colorname[4] },
|
|
||||||
{ "color5", STRING, &colorname[5] },
|
|
||||||
{ "color6", STRING, &colorname[6] },
|
|
||||||
{ "color7", STRING, &colorname[7] },
|
|
||||||
{ "color8", STRING, &colorname[8] },
|
|
||||||
{ "color9", STRING, &colorname[9] },
|
|
||||||
{ "color10", STRING, &colorname[10] },
|
|
||||||
{ "color11", STRING, &colorname[11] },
|
|
||||||
{ "color12", STRING, &colorname[12] },
|
|
||||||
{ "color13", STRING, &colorname[13] },
|
|
||||||
{ "color14", STRING, &colorname[14] },
|
|
||||||
{ "color15", STRING, &colorname[15] },
|
|
||||||
{ "background", STRING, &colorname[256] },
|
|
||||||
{ "foreground", STRING, &colorname[257] },
|
|
||||||
{ "cursorColor", STRING, &colorname[258] },
|
|
||||||
{ "termname", STRING, &termname },
|
|
||||||
{ "shell", STRING, &shell },
|
|
||||||
{ "minlatency", INTEGER, &minlatency },
|
|
||||||
{ "maxlatency", INTEGER, &maxlatency },
|
|
||||||
{ "blinktimeout", INTEGER, &blinktimeout },
|
|
||||||
{ "bellvolume", INTEGER, &bellvolume },
|
|
||||||
{ "tabspaces", INTEGER, &tabspaces },
|
|
||||||
{ "borderpx", INTEGER, &borderpx },
|
|
||||||
{ "cwscale", FLOAT, &cwscale },
|
|
||||||
{ "chscale", FLOAT, &chscale },
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal mouse shortcuts.
|
* Internal mouse shortcuts.
|
||||||
* Beware that overloading Button1 will disable the selection.
|
* Beware that overloading Button1 will disable the selection.
|
||||||
*/
|
*/
|
||||||
static MouseShortcut mshortcuts[] = {
|
static MouseShortcut mshortcuts[] = {
|
||||||
/* mask button function argument release */
|
/* mask button function argument release */
|
||||||
{ ShiftMask, Button4, kscrollup, {.i = 1} },
|
|
||||||
{ ShiftMask, Button5, kscrolldown, {.i = 1} },
|
|
||||||
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
||||||
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
||||||
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -252,10 +188,6 @@ static Shortcut shortcuts[] = {
|
|||||||
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
||||||
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
||||||
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
||||||
{ MODKEY, XK_l, copyurl, {.i = 0} },
|
|
||||||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
|
||||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
|
||||||
{ TERMMOD, XK_Escape, keyboard_select,{.i = 0} },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
16
config.mk
16
config.mk
@ -1,11 +1,10 @@
|
|||||||
# st version
|
# st version
|
||||||
VERSION = 0.9
|
VERSION = 0.8.3
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
APPPREFIX = $(PREFIX)/share/applications
|
|
||||||
MANPREFIX = $(PREFIX)/share/man
|
MANPREFIX = $(PREFIX)/share/man
|
||||||
|
|
||||||
X11INC = /usr/X11R6/include
|
X11INC = /usr/X11R6/include
|
||||||
@ -16,12 +15,10 @@ 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`
|
||||||
`$(PKG_CONFIG) --cflags harfbuzz`
|
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
||||||
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender \
|
|
||||||
`$(PKG_CONFIG) --libs fontconfig` \
|
`$(PKG_CONFIG) --libs fontconfig` \
|
||||||
`$(PKG_CONFIG) --libs freetype2` \
|
`$(PKG_CONFIG) --libs freetype2`
|
||||||
`$(PKG_CONFIG) --libs harfbuzz`
|
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
||||||
@ -31,9 +28,8 @@ STLDFLAGS = $(LIBS) $(LDFLAGS)
|
|||||||
# OpenBSD:
|
# OpenBSD:
|
||||||
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
|
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
|
||||||
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
|
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
|
||||||
# `$(PKG_CONFIG) --libs fontconfig` \
|
# `pkg-config --libs fontconfig` \
|
||||||
# `$(PKG_CONFIG) --libs freetype2`
|
# `pkg-config --libs freetype2`
|
||||||
#MANPREFIX = ${PREFIX}/man
|
|
||||||
|
|
||||||
# compiler and linker
|
# compiler and linker
|
||||||
# CC = c99
|
# CC = c99
|
||||||
|
124
hb.c
124
hb.c
@ -1,124 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <X11/Xft/Xft.h>
|
|
||||||
#include <X11/cursorfont.h>
|
|
||||||
#include <hb.h>
|
|
||||||
#include <hb-ft.h>
|
|
||||||
|
|
||||||
#include "st.h"
|
|
||||||
#include "hb.h"
|
|
||||||
|
|
||||||
#define FEATURE(c1,c2,c3,c4) { .tag = HB_TAG(c1,c2,c3,c4), .value = 1, .start = HB_FEATURE_GLOBAL_START, .end = HB_FEATURE_GLOBAL_END }
|
|
||||||
#define BUFFER_STEP 256
|
|
||||||
|
|
||||||
hb_font_t *hbfindfont(XftFont *match);
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
XftFont *match;
|
|
||||||
hb_font_t *font;
|
|
||||||
} HbFontMatch;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
size_t capacity;
|
|
||||||
HbFontMatch *fonts;
|
|
||||||
} HbFontCache;
|
|
||||||
|
|
||||||
static HbFontCache hbfontcache = { 0, NULL };
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
size_t capacity;
|
|
||||||
Rune *runes;
|
|
||||||
} RuneBuffer;
|
|
||||||
|
|
||||||
static RuneBuffer hbrunebuffer = { 0, NULL };
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Poplulate the array with a list of font features, wrapped in FEATURE macro,
|
|
||||||
* e. g.
|
|
||||||
* FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
|
|
||||||
*/
|
|
||||||
hb_feature_t features[] = { };
|
|
||||||
|
|
||||||
void
|
|
||||||
hbunloadfonts()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < hbfontcache.capacity; i++) {
|
|
||||||
hb_font_destroy(hbfontcache.fonts[i].font);
|
|
||||||
XftUnlockFace(hbfontcache.fonts[i].match);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hbfontcache.fonts != NULL) {
|
|
||||||
free(hbfontcache.fonts);
|
|
||||||
hbfontcache.fonts = NULL;
|
|
||||||
}
|
|
||||||
hbfontcache.capacity = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
hb_font_t *
|
|
||||||
hbfindfont(XftFont *match)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < hbfontcache.capacity; i++) {
|
|
||||||
if (hbfontcache.fonts[i].match == match)
|
|
||||||
return hbfontcache.fonts[i].font;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Font not found in cache, caching it now. */
|
|
||||||
hbfontcache.fonts = realloc(hbfontcache.fonts, sizeof(HbFontMatch) * (hbfontcache.capacity + 1));
|
|
||||||
FT_Face face = XftLockFace(match);
|
|
||||||
hb_font_t *font = hb_ft_font_create(face, NULL);
|
|
||||||
if (font == NULL)
|
|
||||||
die("Failed to load Harfbuzz font.");
|
|
||||||
|
|
||||||
hbfontcache.fonts[hbfontcache.capacity].match = match;
|
|
||||||
hbfontcache.fonts[hbfontcache.capacity].font = font;
|
|
||||||
hbfontcache.capacity += 1;
|
|
||||||
|
|
||||||
return font;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hbtransform(HbTransformData *data, XftFont *xfont, const Glyph *glyphs, int start, int length) {
|
|
||||||
ushort mode = USHRT_MAX;
|
|
||||||
unsigned int glyph_count;
|
|
||||||
int rune_idx, glyph_idx, end = start + length;
|
|
||||||
|
|
||||||
hb_font_t *font = hbfindfont(xfont);
|
|
||||||
if (font == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
hb_buffer_t *buffer = hb_buffer_create();
|
|
||||||
hb_buffer_set_direction(buffer, HB_DIRECTION_LTR);
|
|
||||||
|
|
||||||
/* Resize the buffer if required length is larger. */
|
|
||||||
if (hbrunebuffer.capacity < length) {
|
|
||||||
hbrunebuffer.capacity = (length / BUFFER_STEP + 1) * BUFFER_STEP;
|
|
||||||
hbrunebuffer.runes = realloc(hbrunebuffer.runes, hbrunebuffer.capacity * sizeof(Rune));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill buffer with codepoints. */
|
|
||||||
for (rune_idx = 0, glyph_idx = start; glyph_idx < end; glyph_idx++, rune_idx++) {
|
|
||||||
hbrunebuffer.runes[rune_idx] = glyphs[glyph_idx].u;
|
|
||||||
mode = glyphs[glyph_idx].mode;
|
|
||||||
if (mode & ATTR_WDUMMY)
|
|
||||||
hbrunebuffer.runes[rune_idx] = 0x0020;
|
|
||||||
}
|
|
||||||
hb_buffer_add_codepoints(buffer, hbrunebuffer.runes, length, 0, length);
|
|
||||||
|
|
||||||
/* Shape the segment. */
|
|
||||||
hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
|
|
||||||
|
|
||||||
/* Get new glyph info. */
|
|
||||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, &glyph_count);
|
|
||||||
hb_glyph_position_t *pos = hb_buffer_get_glyph_positions(buffer, &glyph_count);
|
|
||||||
|
|
||||||
/* Fill the output. */
|
|
||||||
data->buffer = buffer;
|
|
||||||
data->glyphs = info;
|
|
||||||
data->positions = pos;
|
|
||||||
data->count = glyph_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hbcleanup(HbTransformData *data) {
|
|
||||||
hb_buffer_destroy(data->buffer);
|
|
||||||
memset(data, 0, sizeof(HbTransformData));
|
|
||||||
}
|
|
14
hb.h
14
hb.h
@ -1,14 +0,0 @@
|
|||||||
#include <X11/Xft/Xft.h>
|
|
||||||
#include <hb.h>
|
|
||||||
#include <hb-ft.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
hb_buffer_t *buffer;
|
|
||||||
hb_glyph_info_t *glyphs;
|
|
||||||
hb_glyph_position_t *positions;
|
|
||||||
unsigned int count;
|
|
||||||
} HbTransformData;
|
|
||||||
|
|
||||||
void hbunloadfonts();
|
|
||||||
void hbtransform(HbTransformData *, XftFont *, const Glyph *, int, int);
|
|
||||||
void hbcleanup(HbTransformData *);
|
|
12
st.desktop
12
st.desktop
@ -1,12 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Exec=st
|
|
||||||
TryExec=st
|
|
||||||
Icon=utilities-terminal
|
|
||||||
Terminal=false
|
|
||||||
Categories=System;TerminalEmulator;
|
|
||||||
|
|
||||||
Name=st
|
|
||||||
GenericName=Terminal
|
|
||||||
Comment=st is a simple terminal implementation for X
|
|
||||||
StartupWMClass=st-256color
|
|
14
st.h
14
st.h
@ -11,8 +11,7 @@
|
|||||||
#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
|
#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
|
||||||
#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
|
#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
|
||||||
#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
|
#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
|
||||||
#define ATTRCMP(a, b) (((a).mode & (~ATTR_WRAP)) != ((b).mode & (~ATTR_WRAP)) || \
|
#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \
|
||||||
(a).fg != (b).fg || \
|
|
||||||
(a).bg != (b).bg)
|
(a).bg != (b).bg)
|
||||||
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
|
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
|
||||||
(t1.tv_nsec-t2.tv_nsec)/1E6)
|
(t1.tv_nsec-t2.tv_nsec)/1E6)
|
||||||
@ -82,20 +81,17 @@ void die(const char *, ...);
|
|||||||
void redraw(void);
|
void redraw(void);
|
||||||
void draw(void);
|
void draw(void);
|
||||||
|
|
||||||
void kscrolldown(const Arg *);
|
|
||||||
void kscrollup(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 *);
|
||||||
void toggleprinter(const Arg *);
|
void toggleprinter(const Arg *);
|
||||||
void copyurl(const Arg *);
|
|
||||||
|
|
||||||
int tattrset(int);
|
int tattrset(int);
|
||||||
void tnew(int, int);
|
void tnew(int, int);
|
||||||
void tresize(int, int);
|
void tresize(int, int);
|
||||||
void tsetdirtattr(int);
|
void tsetdirtattr(int);
|
||||||
void ttyhangup(void);
|
void ttyhangup(void);
|
||||||
int ttynew(const char *, char *, const char *, char **);
|
int ttynew(char *, char *, 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);
|
||||||
@ -113,8 +109,7 @@ 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(const char *);
|
char *xstrdup(char *);
|
||||||
int trt_kbdselect(KeySym, char *, int);
|
|
||||||
|
|
||||||
/* config.h globals */
|
/* config.h globals */
|
||||||
extern char *utmp;
|
extern char *utmp;
|
||||||
@ -123,10 +118,7 @@ extern char *stty_args;
|
|||||||
extern char *vtiden;
|
extern char *vtiden;
|
||||||
extern wchar_t *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;
|
|
||||||
extern float alpha;
|
|
||||||
|
3
st.info
3
st.info
@ -158,7 +158,6 @@ st-mono| simpleterm monocolor,
|
|||||||
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,
|
||||||
@ -184,8 +183,6 @@ st-mono| simpleterm monocolor,
|
|||||||
# XTerm extensions
|
# XTerm extensions
|
||||||
rmxx=\E[29m,
|
rmxx=\E[29m,
|
||||||
smxx=\E[9m,
|
smxx=\E[9m,
|
||||||
# disabled rep for now: causes some issues with older ncurses versions.
|
|
||||||
# rep=%p1%c\E[%p2%{1}%-%db,
|
|
||||||
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
|
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
|
||||||
Tc,
|
Tc,
|
||||||
Ms=\E]52;%p1%s;%p2%s\007,
|
Ms=\E]52;%p1%s;%p2%s\007,
|
||||||
|
7
win.h
7
win.h
@ -21,24 +21,19 @@ enum win_mode {
|
|||||||
MODE_NUMLOCK = 1 << 17,
|
MODE_NUMLOCK = 1 << 17,
|
||||||
MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
|
MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
|
||||||
|MODE_MOUSEMANY,
|
|MODE_MOUSEMANY,
|
||||||
MODE_KBDSELECT = 1 << 18,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void xbell(void);
|
void xbell(void);
|
||||||
void xclipcopy(void);
|
void xclipcopy(void);
|
||||||
void xdrawcursor(int, int, Glyph, int, int, Glyph, Line, int);
|
void xdrawcursor(int, int, Glyph, int, int, Glyph);
|
||||||
void xdrawline(Line, int, int, int);
|
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 toggle_winmode(int);
|
|
||||||
void keyboard_select(const Arg *);
|
|
||||||
void xximspot(int, int);
|
void xximspot(int, int);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user