commit 60054053e61ef2a52972df990db6e1872fbd20cb
parent dd480c555e3df34d72ff732171590ccf15a3e884
Author: q <qwolkensperg@gmail.com>
Date: Fri, 26 Jun 2020 22:46:34 -0400
current build
Diffstat:
13 files changed, 0 insertions(+), 1408 deletions(-)
diff --git a/FAQ b/FAQ
@@ -1,250 +0,0 @@
-## Why does st not handle utmp entries?
-
-Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task.
-
-
-## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
-
-It means that st 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 can manually run `tic -sx st.info`.
-
-
-## 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
- terminfo. What you see is the current state of the “xterm compliance”.
-* Some programs don’t complain about the lacking st description and default to
- another terminal. In that case see the question about terminfo.
-
-
-## How do I scroll back up?
-
-* Using a terminal multiplexer.
- * `st -e tmux` using C-b [
- * `st -e screen` using C-a ESC
-* Using the excellent tool of [scroll](https://git.suckless.org/scroll/).
-* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/).
-
-
-## I would like to have utmp and/or scroll functionality by default
-
-You can add the absolute patch of both programs in your config.h
-file. You only have to modify the value of utmp and scroll variables.
-
-
-## Why doesn't the Del key work in some programs?
-
-Taken from the terminfo manpage:
-
- If the terminal has a keypad that transmits codes when the keys
- are pressed, this information can be given. Note that it is not
- possible to handle terminals where the keypad only works in
- local (this applies, for example, to the unshifted HP 2621 keys).
- If the keypad can be set to transmit or not transmit, give these
- codes as smkx and rmkx. Otherwise the keypad is assumed to
- always transmit.
-
-In the st case smkx=E[?1hE= and rmkx=E[?1lE>, so it is mandatory that
-applications which want to test against keypad keys send these
-sequences.
-
-But buggy applications (like bash and irssi, for example) don't do this. A fast
-solution for them is to use the following command:
-
- $ printf '\033[?1h\033=' >/dev/tty
-
-or
- $ tput smkx
-
-In the case of bash, readline is used. Readline has a different note in its
-manpage about this issue:
-
- enable-keypad (Off)
- When set to On, readline will try to enable the
- application keypad when it is called. Some systems
- need this to enable arrow keys.
-
-Adding this option to your .inputrc will fix the keypad problem for all
-applications using readline.
-
-If you are using zsh, then read the zsh FAQ
-<http://zsh.sourceforge.net/FAQ/zshfaq03.html#l25>:
-
- It should be noted that the O / [ confusion can occur with other keys
- such as Home and End. Some systems let you query the key sequences
- sent by these keys from the system's terminal database, terminfo.
- Unfortunately, the key sequences given there typically apply to the
- mode that is not the one zsh uses by default (it's the "application"
- mode rather than the "raw" mode). Explaining the use of terminfo is
- outside of the scope of this FAQ, but if you wish to use the key
- sequences given there you can tell the line editor to turn on
- "application" mode when it starts and turn it off when it stops:
-
- function zle-line-init () { echoti smkx }
- function zle-line-finish () { echoti rmkx }
- zle -N zle-line-init
- zle -N zle-line-finish
-
-Putting these lines into your .zshrc will fix the problems.
-
-
-## How can I use meta in 8bit mode?
-
-St supports meta in 8bit mode, but the default terminfo entry doesn't
-use this capability. If you want it, you have to use the 'st-meta' value
-in TERM.
-
-
-## I cannot compile st in OpenBSD
-
-OpenBSD lacks librt, despite it being mandatory in POSIX
-<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tag_20_11_13>.
-If you want to compile st for OpenBSD you have to remove -lrt from config.mk, and
-st will compile without any loss of functionality, because all the functions are
-included in libc on this platform.
-
-
-## The Backspace Case
-
-St is emulating the Linux way of handling backspace being delete and delete being
-backspace.
-
-This is an issue that was discussed in suckless mailing list
-<https://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
-terminal users wants its backspace to be how he feels it:
-
- Well, I am going to comment why I want to change the behaviour
- of this key. When ASCII was defined in 1968, communication
- with computers was done using punched cards, or hardcopy
- terminals (basically a typewriter machine connected with the
- computer using a serial port). ASCII defines DELETE as 7F,
- because, in punched-card terms, it means all the holes of the
- card punched; it is thus a kind of 'physical delete'. In the
- same way, the BACKSPACE key was a non-destructive backspace,
- as on a typewriter. So, if you wanted to delete a character,
- you had to BACKSPACE and then DELETE. Another use of BACKSPACE
- was to type accented characters, for example 'a BACKSPACE `'.
- The VT100 had no BACKSPACE key; it was generated using the
- CONTROL key as another control character (CONTROL key sets to
- 0 b7 b6 b5, so it converts H (code 0x48) into BACKSPACE (code
- 0x08)), but it had a DELETE key in a similar position where
- the BACKSPACE key is located today on common PC keyboards.
- All the terminal emulators emulated the difference between
- these keys correctly: the backspace key generated a BACKSPACE
- (^H) and delete key generated a DELETE (^?).
-
- But a problem arose when Linus Torvalds wrote Linux. Unlike
- earlier terminals, the Linux virtual terminal (the terminal
- emulator integrated in the kernel) returned a DELETE when
- backspace was pressed, due to the VT100 having a DELETE key in
- the same position. This created a lot of problems (see [1]
- and [2]). Since Linux has become the king, a lot of terminal
- emulators today generate a DELETE when the backspace key is
- pressed in order to avoid problems with Linux. The result is
- that the only way of generating a BACKSPACE on these systems
- is by using CONTROL + H. (I also think that emacs had an
- important point here because the CONTROL + H prefix is used
- in emacs in some commands (help commands).)
-
- From point of view of the kernel, you can change the key
- for deleting a previous character with stty erase. When you
- connect a real terminal into a machine you describe the type
- of terminal, so getty configures the correct value of stty
- erase for this terminal. In the case of terminal emulators,
- however, you don't have any getty that can set the correct
- value of stty erase, so you always get the default value.
- For this reason, it is necessary to add 'stty erase ^H' to your
- profile if you have changed the value of the backspace key.
- Of course, another solution is for st itself to modify the
- value of stty erase. I usually have the inverse problem:
- when I connect to non-Unix machines, I have to press CONTROL +
- h to get a BACKSPACE. The inverse problem occurs when a user
- connects to my Unix machines from a different system with a
- correct backspace key.
-
- [1] http://www.ibb.net/~anne/keyboard.html
- [2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
-
-
-## But I really want the old grumpy behaviour of my terminal
-
-Apply [1].
-
-[1] 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.
diff --git a/LEGACY b/LEGACY
@@ -1,17 +0,0 @@
-A STATEMENT ON LEGACY SUPPORT
-
-In the terminal world there is much cruft that comes from old and unsup‐
-ported terminals that inherit incompatible modes and escape sequences
-which noone is able to know, except when he/she comes from that time and
-developed a graphical vt100 emulator at that time.
-
-One goal of st is to only support what is really needed. When you en‐
-counter a sequence which you really need, implement it. But while you
-are at it, do not add the other cruft you might encounter while sneek‐
-ing at other terminal emulators. History has bloated them and there is
-no real evidence that most of the sequences are used today.
-
-
-Christoph Lohmann <20h@r-36.net>
-2012-09-13T07:00:36.081271045+02:00
-
diff --git a/README b/README
@@ -1,34 +0,0 @@
-st - simple terminal
---------------------
-st is a simple terminal emulator for X which sucks less.
-
-
-Requirements
-------------
-In order to build st you need the Xlib header files.
-
-
-Installation
-------------
-Edit config.mk to match your local setup (st is installed into
-the /usr/local namespace by default).
-
-Afterwards enter the following command to build and install st (if
-necessary as root):
-
- make clean install
-
-
-Running st
-----------
-If you did not install st with make clean install, you must compile
-the st terminfo entry with the following command:
-
- tic -sx st.info
-
-See the man page for additional details.
-
-Credits
--------
-Based on Aurélien APTEL <aurelien dot aptel at gmail dot com> bt source code.
-
diff --git a/TODO b/TODO
@@ -1,28 +0,0 @@
-vt emulation
-------------
-
-* double-height support
-
-code & interface
-----------------
-
-* add a simple way to do multiplexing
-
-drawing
--------
-* add diacritics support to xdraws()
- * switch to a suckless font drawing library
-* make the font cache simpler
-* add better support for brightening of the upper colors
-
-bugs
-----
-
-* fix shift up/down (shift selection in emacs)
-* remove DEC test sequence when appropriate
-
-misc
-----
-
- $ grep -nE 'XXX|TODO' st.c
-
diff --git a/st b/st
Binary files differ.
diff --git a/st-alpha-0.8.2.diff b/st-alpha-0.8.2.diff
@@ -1,163 +0,0 @@
-diff --git a/config.def.h b/config.def.h
-index 0e01717..e116631 100644
---- a/config.def.h
-+++ b/config.def.h
-@@ -82,6 +82,9 @@ char *termname = "st-256color";
- */
- unsigned int tabspaces = 8;
-
-+/* bg opacity */
-+float alpha = 0.8;
-+
- /* Terminal colors (16 first used in escape sequence) */
- static const char *colorname[] = {
- /* 8 normal colors */
-@@ -109,6 +112,7 @@ static const char *colorname[] = {
- /* more colors can be added after 255 to use with DefaultXX */
- "#cccccc",
- "#555555",
-+ "black",
- };
-
-
-@@ -117,7 +121,7 @@ static const char *colorname[] = {
- * foreground, background, cursor, reverse cursor
- */
- unsigned int defaultfg = 7;
--unsigned int defaultbg = 0;
-+unsigned int defaultbg = 258;
- static unsigned int defaultcs = 256;
- static unsigned int defaultrcs = 257;
-
-diff --git a/config.mk b/config.mk
-index 0cbb002..1d2f0e2 100644
---- a/config.mk
-+++ b/config.mk
-@@ -16,7 +16,7 @@ PKG_CONFIG = pkg-config
- INCS = -I$(X11INC) \
- `$(PKG_CONFIG) --cflags fontconfig` \
- `$(PKG_CONFIG) --cflags freetype2`
--LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
-+LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\
- `$(PKG_CONFIG) --libs fontconfig` \
- `$(PKG_CONFIG) --libs freetype2`
-
-diff --git a/st.h b/st.h
-index 38c61c4..b7634ab 100644
---- a/st.h
-+++ b/st.h
-@@ -120,3 +120,4 @@ extern char *termname;
- extern unsigned int tabspaces;
- extern unsigned int defaultfg;
- extern unsigned int defaultbg;
-+extern float alpha;
-diff --git a/x.c b/x.c
-index 0422421..588dec3 100644
---- a/x.c
-+++ b/x.c
-@@ -98,6 +98,7 @@ typedef struct {
- XSetWindowAttributes attrs;
- int scr;
- int isfixed; /* is fixed geometry? */
-+ int depth; /* bit depth */
- int l, t; /* left and top offset */
- int gm; /* geometry mask */
- } XWindow;
-@@ -229,6 +230,7 @@ static char *usedfont = NULL;
- static double usedfontsize = 0;
- static double defaultfontsize = 0;
-
-+static char *opt_alpha = NULL;
- static char *opt_class = NULL;
- static char **opt_cmd = NULL;
- static char *opt_embed = NULL;
-@@ -688,7 +690,7 @@ xresize(int col, int row)
-
- XFreePixmap(xw.dpy, xw.buf);
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
-- DefaultDepth(xw.dpy, xw.scr));
-+ xw.depth);
- XftDrawChange(xw.draw, xw.buf);
- xclear(0, 0, win.w, win.h);
-
-@@ -748,6 +750,13 @@ xloadcols(void)
- else
- die("could not allocate color %d\n", i);
- }
-+
-+ /* set alpha value of bg color */
-+ if (opt_alpha)
-+ alpha = strtof(opt_alpha, NULL);
-+ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
-+ dc.col[defaultbg].pixel &= 0x00FFFFFF;
-+ dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
- loaded = 1;
- }
-
-@@ -1004,11 +1013,23 @@ xinit(int cols, int rows)
- Window parent;
- pid_t thispid = getpid();
- XColor xmousefg, xmousebg;
-+ XWindowAttributes attr;
-+ XVisualInfo vis;
-
- if (!(xw.dpy = XOpenDisplay(NULL)))
- die("can't open display\n");
- xw.scr = XDefaultScreen(xw.dpy);
-- xw.vis = XDefaultVisual(xw.dpy, xw.scr);
-+
-+ if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) {
-+ parent = XRootWindow(xw.dpy, xw.scr);
-+ xw.depth = 32;
-+ } else {
-+ XGetWindowAttributes(xw.dpy, parent, &attr);
-+ xw.depth = attr.depth;
-+ }
-+
-+ XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis);
-+ xw.vis = vis.visual;
-
- /* font */
- if (!FcInit())
-@@ -1018,7 +1039,7 @@ xinit(int cols, int rows)
- xloadfonts(usedfont, 0);
-
- /* colors */
-- xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
-+ xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None);
- xloadcols();
-
- /* adjust fixed window geometry */
-@@ -1038,19 +1059,15 @@ xinit(int cols, int rows)
- | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
- xw.attrs.colormap = xw.cmap;
-
-- if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
-- parent = XRootWindow(xw.dpy, xw.scr);
- xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
-- win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
-+ win.w, win.h, 0, xw.depth, InputOutput,
- xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
- | CWEventMask | CWColormap, &xw.attrs);
-
- memset(&gcvalues, 0, sizeof(gcvalues));
- 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 = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth);
-+ dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues);
- XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
- XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
-
-@@ -1894,6 +1911,9 @@ main(int argc, char *argv[])
- case 'a':
- allowaltscreen = 0;
- break;
-+ case 'A':
-+ opt_alpha = EARGF(usage());
-+ break;
- case 'c':
- opt_class = EARGF(usage());
- break;
diff --git a/st-blinking_cursor-20200531-a2a7044.diff b/st-blinking_cursor-20200531-a2a7044.diff
@@ -1,150 +0,0 @@
-From bff176133618854676bbdc74c0099f184d3da365 Mon Sep 17 00:00:00 2001
-From: Steve Ward <planet36@gmail.com>
-Date: Sun, 31 May 2020 22:48:25 -0400
-Subject: [PATCH] Allow blinking cursor
-
----
- config.def.h | 19 +++++++++++++------
- x.c | 42 ++++++++++++++++++++++++++++++++----------
- 2 files changed, 45 insertions(+), 16 deletions(-)
-
-diff --git a/config.def.h b/config.def.h
-index 6f05dce..3dbe915 100644
---- a/config.def.h
-+++ b/config.def.h
-@@ -133,13 +133,20 @@ static unsigned int defaultcs = 256;
- static unsigned int defaultrcs = 257;
-
- /*
-- * Default shape of cursor
-- * 2: Block ("█")
-- * 4: Underline ("_")
-- * 6: Bar ("|")
-- * 7: Snowman ("☃")
-+ * https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81
-+ * Default style of cursor
-+ * 0: Blinking block
-+ * 1: Blinking block (default)
-+ * 2: Steady block ("█")
-+ * 3: Blinking underline
-+ * 4: Steady underline ("_")
-+ * 5: Blinking bar
-+ * 6: Steady bar ("|")
-+ * 7: Blinking st cursor
-+ * 8: Steady st cursor
- */
--static unsigned int cursorshape = 2;
-+static unsigned int cursorstyle = 1;
-+static Rune stcursor = 0x2603; /* snowman (U+2603) */
-
- /*
- * Default columns and rows numbers
-diff --git a/x.c b/x.c
-index 210f184..bd80a5e 100644
---- a/x.c
-+++ b/x.c
-@@ -253,6 +253,7 @@ static char *opt_name = NULL;
- static char *opt_title = NULL;
-
- static int oldbutton = 3; /* button event on startup: 3 = release */
-+static int cursorblinks = 0;
-
- void
- clipcopy(const Arg *dummy)
-@@ -1526,16 +1527,19 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
- /* draw the new one */
- if (IS_SET(MODE_FOCUSED)) {
- switch (win.cursor) {
-- case 7: /* st extension */
-- g.u = 0x2603; /* snowman (U+2603) */
-+ case 0: /* Blinking block */
-+ case 1: /* Blinking block (default) */
-+ if (IS_SET(MODE_BLINK))
-+ break;
- /* FALLTHROUGH */
-- case 0: /* Blinking Block */
-- case 1: /* Blinking Block (Default) */
-- case 2: /* Steady Block */
-+ case 2: /* Steady block */
- xdrawglyph(g, cx, cy);
- break;
-- case 3: /* Blinking Underline */
-- case 4: /* Steady Underline */
-+ case 3: /* Blinking underline */
-+ if (IS_SET(MODE_BLINK))
-+ break;
-+ /* FALLTHROUGH */
-+ case 4: /* Steady underline */
- XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + (cy + 1) * win.ch - \
-@@ -1543,12 +1547,23 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
- win.cw, cursorthickness);
- break;
- case 5: /* Blinking bar */
-+ if (IS_SET(MODE_BLINK))
-+ break;
-+ /* FALLTHROUGH */
- case 6: /* Steady bar */
- XftDrawRect(xw.draw, &drawcol,
- borderpx + cx * win.cw,
- borderpx + cy * win.ch,
- cursorthickness, win.ch);
- break;
-+ case 7: /* Blinking st cursor */
-+ if (IS_SET(MODE_BLINK))
-+ break;
-+ /* FALLTHROUGH */
-+ case 8: /* Steady st cursor */
-+ g.u = stcursor;
-+ xdrawglyph(g, cx, cy);
-+ break;
- }
- } else {
- XftDrawRect(xw.draw, &drawcol,
-@@ -1690,9 +1705,12 @@ xsetmode(int set, unsigned int flags)
- int
- xsetcursor(int cursor)
- {
-- if (!BETWEEN(cursor, 0, 7)) /* 7: st extension */
-+ if (!BETWEEN(cursor, 0, 8)) /* 7-8: st extensions */
- return 1;
- win.cursor = cursor;
-+ cursorblinks = win.cursor == 0 || win.cursor == 1 ||
-+ win.cursor == 3 || win.cursor == 5 ||
-+ win.cursor == 7;
- return 0;
- }
-
-@@ -1936,6 +1954,10 @@ run(void)
- if (FD_ISSET(ttyfd, &rfd) || xev) {
- if (!drawing) {
- trigger = now;
-+ if (IS_SET(MODE_BLINK)) {
-+ win.mode ^= MODE_BLINK;
-+ }
-+ lastblink = now;
- drawing = 1;
- }
- timeout = (maxlatency - TIMEDIFF(now, trigger)) \
-@@ -1946,7 +1968,7 @@ run(void)
-
- /* idle detected or maxlatency exhausted -> draw */
- timeout = -1;
-- if (blinktimeout && tattrset(ATTR_BLINK)) {
-+ if (blinktimeout && (cursorblinks || tattrset(ATTR_BLINK))) {
- timeout = blinktimeout - TIMEDIFF(now, lastblink);
- if (timeout <= 0) {
- if (-timeout > blinktimeout) /* start visible */
-@@ -1982,7 +2004,7 @@ main(int argc, char *argv[])
- {
- xw.l = xw.t = 0;
- xw.isfixed = False;
-- xsetcursor(cursorshape);
-+ xsetcursor(cursorstyle);
-
- ARGBEGIN {
- case 'a':
---
-2.20.1
-
diff --git a/st-font2-20190416-ba72400.diff b/st-font2-20190416-ba72400.diff
@@ -1,167 +0,0 @@
-From ba724004c6a368e452114f7dc147a9978fe0f3b4 Mon Sep 17 00:00:00 2001
-From: Kirill Bugaev <kirill.bugaev87@gmail.com>
-Date: Tue, 16 Apr 2019 04:31:30 +0800
-Subject: [PATCH] This patch allows to add spare font besides default. Some
- glyphs can be not present in default font. For this glyphs st uses
- font-config and try to find them in font cache first. This patch append fonts
- defined in font2 variable to the beginning of font cache. So they will be
- used first for glyphs that absent in default font.
-
----
- config.def.h | 6 +++
- x.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 107 insertions(+)
-
-diff --git a/config.def.h b/config.def.h
-index 482901e..676719e 100644
---- a/config.def.h
-+++ b/config.def.h
-@@ -6,6 +6,12 @@
- * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
- */
- static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
-+/* Spare fonts */
-+static char *font2[] = {
-+/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */
-+/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */
-+};
-+
- static int borderpx = 2;
-
- /*
-diff --git a/x.c b/x.c
-index 5828a3b..d37e59d 100644
---- a/x.c
-+++ b/x.c
-@@ -149,6 +149,8 @@ static void xhints(void);
- static int xloadcolor(int, const char *, Color *);
- static int xloadfont(Font *, FcPattern *);
- static void xloadfonts(char *, double);
-+static int xloadsparefont(FcPattern *, int);
-+static void xloadsparefonts(void);
- static void xunloadfont(Font *);
- static void xunloadfonts(void);
- static void xsetenv(void);
-@@ -296,6 +298,7 @@ zoomabs(const Arg *arg)
- {
- xunloadfonts();
- xloadfonts(usedfont, arg->f);
-+ xloadsparefonts();
- cresize(0, 0);
- redraw();
- xhints();
-@@ -977,6 +980,101 @@ xloadfonts(char *fontstr, double fontsize)
- FcPatternDestroy(pattern);
- }
-
-+int
-+xloadsparefont(FcPattern *pattern, int flags)
-+{
-+ FcPattern *match;
-+ FcResult result;
-+
-+ match = FcFontMatch(NULL, pattern, &result);
-+ if (!match) {
-+ return 1;
-+ }
-+
-+ if (!(frc[frclen].font = XftFontOpenPattern(xw.dpy, match))) {
-+ FcPatternDestroy(match);
-+ return 1;
-+ }
-+
-+ frc[frclen].flags = flags;
-+ /* Believe U+0000 glyph will present in each default font */
-+ frc[frclen].unicodep = 0;
-+ frclen++;
-+
-+ return 0;
-+}
-+
-+void
-+xloadsparefonts(void)
-+{
-+ FcPattern *pattern;
-+ double sizeshift, fontval;
-+ int fc;
-+ char **fp;
-+
-+ if (frclen != 0)
-+ die("can't embed spare fonts. cache isn't empty");
-+
-+ /* Calculate count of spare fonts */
-+ fc = sizeof(font2) / sizeof(*font2);
-+ if (fc == 0)
-+ return;
-+
-+ /* Allocate memory for cache entries. */
-+ if (frccap < 4 * fc) {
-+ frccap += 4 * fc - frccap;
-+ frc = xrealloc(frc, frccap * sizeof(Fontcache));
-+ }
-+
-+ for (fp = font2; fp - font2 < fc; ++fp) {
-+
-+ if (**fp == '-')
-+ pattern = XftXlfdParse(*fp, False, False);
-+ else
-+ pattern = FcNameParse((FcChar8 *)*fp);
-+
-+ if (!pattern)
-+ die("can't open spare font %s\n", *fp);
-+
-+ if (defaultfontsize > 0) {
-+ sizeshift = usedfontsize - defaultfontsize;
-+ if (sizeshift != 0 &&
-+ FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
-+ FcResultMatch) {
-+ fontval += sizeshift;
-+ FcPatternDel(pattern, FC_PIXEL_SIZE);
-+ FcPatternDel(pattern, FC_SIZE);
-+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fontval);
-+ }
-+ }
-+
-+ FcPatternAddBool(pattern, FC_SCALABLE, 1);
-+
-+ FcConfigSubstitute(NULL, pattern, FcMatchPattern);
-+ XftDefaultSubstitute(xw.dpy, xw.scr, pattern);
-+
-+ if (xloadsparefont(pattern, FRC_NORMAL))
-+ die("can't open spare font %s\n", *fp);
-+
-+ FcPatternDel(pattern, FC_SLANT);
-+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
-+ if (xloadsparefont(pattern, FRC_ITALIC))
-+ die("can't open spare font %s\n", *fp);
-+
-+ FcPatternDel(pattern, FC_WEIGHT);
-+ FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
-+ if (xloadsparefont(pattern, FRC_ITALICBOLD))
-+ die("can't open spare font %s\n", *fp);
-+
-+ FcPatternDel(pattern, FC_SLANT);
-+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
-+ if (xloadsparefont(pattern, FRC_BOLD))
-+ die("can't open spare font %s\n", *fp);
-+
-+ FcPatternDestroy(pattern);
-+ }
-+}
-+
- void
- xunloadfont(Font *f)
- {
-@@ -1057,6 +1155,9 @@ xinit(int cols, int rows)
- usedfont = (opt_font == NULL)? font : opt_font;
- xloadfonts(usedfont, 0);
-
-+ /* spare fonts */
-+ xloadsparefonts();
-+
- /* colors */
- xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
- xloadcols();
---
-2.21.0
-
diff --git a/st-scrollback-20200419-72e3f6c.diff b/st-scrollback-20200419-72e3f6c.diff
@@ -1,351 +0,0 @@
-diff --git a/config.def.h b/config.def.h
-index 0895a1f..eef24df 100644
---- a/config.def.h
-+++ b/config.def.h
-@@ -188,6 +188,8 @@ static Shortcut shortcuts[] = {
- { TERMMOD, XK_Y, selpaste, {.i = 0} },
- { ShiftMask, XK_Insert, selpaste, {.i = 0} },
- { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
-+ { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
-+ { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
- };
-
- /*
-diff --git a/st.c b/st.c
-index 0ce6ac2..641edc0 100644
---- a/st.c
-+++ b/st.c
-@@ -35,6 +35,7 @@
- #define ESC_ARG_SIZ 16
- #define STR_BUF_SIZ ESC_BUF_SIZ
- #define STR_ARG_SIZ ESC_ARG_SIZ
-+#define HISTSIZE 2000
-
- /* macros */
- #define IS_SET(flag) ((term.mode & (flag)) != 0)
-@@ -42,6 +43,9 @@
- #define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
- #define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
- #define ISDELIM(u) (u && wcschr(worddelimiters, u))
-+#define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - \
-+ term.scr + HISTSIZE + 1) % HISTSIZE] : \
-+ term.line[(y) - term.scr])
-
- enum term_mode {
- MODE_WRAP = 1 << 0,
-@@ -117,6 +121,9 @@ typedef struct {
- int col; /* nb col */
- Line *line; /* screen */
- Line *alt; /* alternate screen */
-+ Line hist[HISTSIZE]; /* history buffer */
-+ int histi; /* history index */
-+ int scr; /* scroll back */
- int *dirty; /* dirtyness of lines */
- TCursor c; /* cursor */
- int ocx; /* old cursor col */
-@@ -185,8 +192,8 @@ static void tnewline(int);
- static void tputtab(int);
- static void tputc(Rune);
- static void treset(void);
--static void tscrollup(int, int);
--static void tscrolldown(int, int);
-+static void tscrollup(int, int, int);
-+static void tscrolldown(int, int, int);
- static void tsetattr(int *, int);
- static void tsetchar(Rune, Glyph *, int, int);
- static void tsetdirt(int, int);
-@@ -415,10 +422,10 @@ tlinelen(int y)
- {
- int i = term.col;
-
-- if (term.line[y][i - 1].mode & ATTR_WRAP)
-+ if (TLINE(y)[i - 1].mode & ATTR_WRAP)
- return i;
-
-- while (i > 0 && term.line[y][i - 1].u == ' ')
-+ while (i > 0 && TLINE(y)[i - 1].u == ' ')
- --i;
-
- return i;
-@@ -527,7 +534,7 @@ selsnap(int *x, int *y, int direction)
- * Snap around if the word wraps around at the end or
- * beginning of a line.
- */
-- prevgp = &term.line[*y][*x];
-+ prevgp = &TLINE(*y)[*x];
- prevdelim = ISDELIM(prevgp->u);
- for (;;) {
- newx = *x + direction;
-@@ -542,14 +549,14 @@ selsnap(int *x, int *y, int direction)
- yt = *y, xt = *x;
- else
- yt = newy, xt = newx;
-- if (!(term.line[yt][xt].mode & ATTR_WRAP))
-+ if (!(TLINE(yt)[xt].mode & ATTR_WRAP))
- break;
- }
-
- if (newx >= tlinelen(newy))
- break;
-
-- gp = &term.line[newy][newx];
-+ gp = &TLINE(newy)[newx];
- delim = ISDELIM(gp->u);
- if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim
- || (delim && gp->u != prevgp->u)))
-@@ -570,14 +577,14 @@ selsnap(int *x, int *y, int direction)
- *x = (direction < 0) ? 0 : term.col - 1;
- if (direction < 0) {
- for (; *y > 0; *y += direction) {
-- if (!(term.line[*y-1][term.col-1].mode
-+ if (!(TLINE(*y-1)[term.col-1].mode
- & ATTR_WRAP)) {
- break;
- }
- }
- } else if (direction > 0) {
- for (; *y < term.row-1; *y += direction) {
-- if (!(term.line[*y][term.col-1].mode
-+ if (!(TLINE(*y)[term.col-1].mode
- & ATTR_WRAP)) {
- break;
- }
-@@ -608,13 +615,13 @@ getsel(void)
- }
-
- if (sel.type == SEL_RECTANGULAR) {
-- gp = &term.line[y][sel.nb.x];
-+ gp = &TLINE(y)[sel.nb.x];
- lastx = sel.ne.x;
- } else {
-- gp = &term.line[y][sel.nb.y == y ? sel.nb.x : 0];
-+ gp = &TLINE(y)[sel.nb.y == y ? sel.nb.x : 0];
- lastx = (sel.ne.y == y) ? sel.ne.x : term.col-1;
- }
-- last = &term.line[y][MIN(lastx, linelen-1)];
-+ last = &TLINE(y)[MIN(lastx, linelen-1)];
- while (last >= gp && last->u == ' ')
- --last;
-
-@@ -849,6 +856,9 @@ void
- ttywrite(const char *s, size_t n, int may_echo)
- {
- const char *next;
-+ Arg arg = (Arg) { .i = term.scr };
-+
-+ kscrolldown(&arg);
-
- if (may_echo && IS_SET(MODE_ECHO))
- twrite(s, n, 1);
-@@ -1060,13 +1070,53 @@ tswapscreen(void)
- }
-
- void
--tscrolldown(int orig, int n)
-+kscrolldown(const Arg* a)
-+{
-+ int n = a->i;
-+
-+ if (n < 0)
-+ n = term.row + n;
-+
-+ if (n > term.scr)
-+ n = term.scr;
-+
-+ if (term.scr > 0) {
-+ term.scr -= n;
-+ selscroll(0, -n);
-+ tfulldirt();
-+ }
-+}
-+
-+void
-+kscrollup(const Arg* a)
-+{
-+ int n = a->i;
-+
-+ if (n < 0)
-+ n = term.row + n;
-+
-+ if (term.scr <= HISTSIZE-n) {
-+ term.scr += n;
-+ selscroll(0, n);
-+ tfulldirt();
-+ }
-+}
-+
-+void
-+tscrolldown(int orig, int n, int copyhist)
- {
- int i;
- Line temp;
-
- LIMIT(n, 0, term.bot-orig+1);
-
-+ if (copyhist) {
-+ term.histi = (term.histi - 1 + HISTSIZE) % HISTSIZE;
-+ temp = term.hist[term.histi];
-+ term.hist[term.histi] = term.line[term.bot];
-+ term.line[term.bot] = temp;
-+ }
-+
- tsetdirt(orig, term.bot-n);
- tclearregion(0, term.bot-n+1, term.col-1, term.bot);
-
-@@ -1076,17 +1126,28 @@ tscrolldown(int orig, int n)
- term.line[i-n] = temp;
- }
-
-- selscroll(orig, n);
-+ if (term.scr == 0)
-+ selscroll(orig, n);
- }
-
- void
--tscrollup(int orig, int n)
-+tscrollup(int orig, int n, int copyhist)
- {
- int i;
- Line temp;
-
- LIMIT(n, 0, term.bot-orig+1);
-
-+ if (copyhist) {
-+ term.histi = (term.histi + 1) % HISTSIZE;
-+ temp = term.hist[term.histi];
-+ term.hist[term.histi] = term.line[orig];
-+ term.line[orig] = temp;
-+ }
-+
-+ if (term.scr > 0 && term.scr < HISTSIZE)
-+ term.scr = MIN(term.scr + n, HISTSIZE-1);
-+
- tclearregion(0, orig, term.col-1, orig+n-1);
- tsetdirt(orig+n, term.bot);
-
-@@ -1096,7 +1157,8 @@ tscrollup(int orig, int n)
- term.line[i+n] = temp;
- }
-
-- selscroll(orig, -n);
-+ if (term.scr == 0)
-+ selscroll(orig, -n);
- }
-
- void
-@@ -1135,7 +1197,7 @@ tnewline(int first_col)
- int y = term.c.y;
-
- if (y == term.bot) {
-- tscrollup(term.top, 1);
-+ tscrollup(term.top, 1, 1);
- } else {
- y++;
- }
-@@ -1300,14 +1362,14 @@ void
- tinsertblankline(int n)
- {
- if (BETWEEN(term.c.y, term.top, term.bot))
-- tscrolldown(term.c.y, n);
-+ tscrolldown(term.c.y, n, 0);
- }
-
- void
- tdeleteline(int n)
- {
- if (BETWEEN(term.c.y, term.top, term.bot))
-- tscrollup(term.c.y, n);
-+ tscrollup(term.c.y, n, 0);
- }
-
- int32_t
-@@ -1738,11 +1800,11 @@ csihandle(void)
- break;
- case 'S': /* SU -- Scroll <n> line up */
- DEFAULT(csiescseq.arg[0], 1);
-- tscrollup(term.top, csiescseq.arg[0]);
-+ tscrollup(term.top, csiescseq.arg[0], 0);
- break;
- case 'T': /* SD -- Scroll <n> line down */
- DEFAULT(csiescseq.arg[0], 1);
-- tscrolldown(term.top, csiescseq.arg[0]);
-+ tscrolldown(term.top, csiescseq.arg[0], 0);
- break;
- case 'L': /* IL -- Insert <n> blank lines */
- DEFAULT(csiescseq.arg[0], 1);
-@@ -2248,7 +2310,7 @@ eschandle(uchar ascii)
- return 0;
- case 'D': /* IND -- Linefeed */
- if (term.c.y == term.bot) {
-- tscrollup(term.top, 1);
-+ tscrollup(term.top, 1, 1);
- } else {
- tmoveto(term.c.x, term.c.y+1);
- }
-@@ -2261,7 +2323,7 @@ eschandle(uchar ascii)
- break;
- case 'M': /* RI -- Reverse index */
- if (term.c.y == term.top) {
-- tscrolldown(term.top, 1);
-+ tscrolldown(term.top, 1, 1);
- } else {
- tmoveto(term.c.x, term.c.y-1);
- }
-@@ -2482,7 +2544,7 @@ twrite(const char *buf, int buflen, int show_ctrl)
- void
- tresize(int col, int row)
- {
-- int i;
-+ int i, j;
- int minrow = MIN(row, term.row);
- int mincol = MIN(col, term.col);
- int *bp;
-@@ -2519,6 +2581,14 @@ tresize(int col, int row)
- term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty));
- term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs));
-
-+ for (i = 0; i < HISTSIZE; i++) {
-+ term.hist[i] = xrealloc(term.hist[i], col * sizeof(Glyph));
-+ for (j = mincol; j < col; j++) {
-+ term.hist[i][j] = term.c.attr;
-+ term.hist[i][j].u = ' ';
-+ }
-+ }
-+
- /* resize each row to new width, zero-pad if needed */
- for (i = 0; i < minrow; i++) {
- term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph));
-@@ -2577,7 +2647,7 @@ drawregion(int x1, int y1, int x2, int y2)
- continue;
-
- term.dirty[y] = 0;
-- xdrawline(term.line[y], x1, y, x2);
-+ xdrawline(TLINE(y), x1, y, x2);
- }
- }
-
-@@ -2598,8 +2668,9 @@ draw(void)
- cx--;
-
- drawregion(0, 0, term.col, term.row);
-- xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
-- term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
-+ if (term.scr == 0)
-+ xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
-+ term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
- term.ocx = cx;
- term.ocy = term.c.y;
- xfinishdraw();
-diff --git a/st.h b/st.h
-index d978458..b9a4eeb 100644
---- a/st.h
-+++ b/st.h
-@@ -81,6 +81,8 @@ void die(const char *, ...);
- void redraw(void);
- void draw(void);
-
-+void kscrolldown(const Arg *);
-+void kscrollup(const Arg *);
- void printscreen(const Arg *);
- void printsel(const Arg *);
- void sendbreak(const Arg *);
diff --git a/st-scrollback-mouse-20191024-a2c479c.diff b/st-scrollback-mouse-20191024-a2c479c.diff
@@ -1,13 +0,0 @@
-diff --git a/config.def.h b/config.def.h
-index ec1b576..4b3bf15 100644
---- a/config.def.h
-+++ b/config.def.h
-@@ -163,6 +163,8 @@ static uint forcemousemod = ShiftMask;
- */
- static MouseShortcut mshortcuts[] = {
- /* 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, Button4, ttysend, {.s = "\031"} },
- { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
diff --git a/st-vertcenter-20180320-6ac8c8a.diff b/st-vertcenter-20180320-6ac8c8a.diff
@@ -1,51 +0,0 @@
---- a/x.c Tue Mar 20 00:28:57 2018
-+++ b/x.c Tue Mar 20 00:29:02 2018
-@@ -80,6 +80,7 @@
- int w, h; /* window width and height */
- int ch; /* char height */
- int cw; /* char width */
-+ int cyo; /* char y offset */
- int mode; /* window state/mode flags */
- int cursor; /* cursor style */
- } TermWindow;
-@@ -949,6 +950,7 @@
- /* Setting character width and height. */
- win.cw = ceilf(dc.font.width * cwscale);
- win.ch = ceilf(dc.font.height * chscale);
-+ win.cyo = ceilf(dc.font.height * (chscale - 1) / 2);
-
- FcPatternDel(pattern, FC_SLANT);
- FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
-@@ -1130,7 +1132,7 @@
- FcCharSet *fccharset;
- int i, f, numspecs = 0;
-
-- for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) {
-+ for (i = 0, xp = winx, yp = winy + font->ascent + win.cyo; i < len; ++i) {
- /* Fetch rune and mode for current glyph. */
- rune = glyphs[i].u;
- mode = glyphs[i].mode;
-@@ -1155,7 +1157,7 @@
- font = &dc.bfont;
- frcflags = FRC_BOLD;
- }
-- yp = winy + font->ascent;
-+ yp = winy + font->ascent + win.cyo;
- }
-
- /* Lookup character index with default font. */
-@@ -1371,12 +1373,12 @@
-
- /* Render underline and strikethrough. */
- if (base.mode & ATTR_UNDERLINE) {
-- XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
-+ XftDrawRect(xw.draw, fg, winx, winy + win.cyo + dc.font.ascent + 1,
- width, 1);
- }
-
- if (base.mode & ATTR_STRUCK) {
-- XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
-+ XftDrawRect(xw.draw, fg, winx, winy + win.cyo + 2 * dc.font.ascent / 3,
- width, 1);
- }
-
diff --git a/st-xresources-20200604-9ba7ecf.diff b/st-xresources-20200604-9ba7ecf.diff
@@ -1,184 +0,0 @@
-From 2752a599ee01305a435729bfacf43b1dde7cf0ef Mon Sep 17 00:00:00 2001
-From: Benji Encalada Mora <benji@encalada.dev>
-Date: Thu, 4 Jun 2020 00:41:10 -0500
-Subject: [PATCH] fix: replace xfps and actionfps variables
-
----
- config.def.h | 36 ++++++++++++++++++++++++
- x.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++---
- 2 files changed, 110 insertions(+), 4 deletions(-)
-
-diff --git a/config.def.h b/config.def.h
-index 6f05dce..9b99782 100644
---- a/config.def.h
-+++ b/config.def.h
-@@ -168,6 +168,42 @@ static unsigned int defaultattr = 11;
- */
- 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.
- * Beware that overloading Button1 will disable the selection.
-diff --git a/x.c b/x.c
-index 210f184..76f167f 100644
---- a/x.c
-+++ b/x.c
-@@ -14,6 +14,7 @@
- #include <X11/keysym.h>
- #include <X11/Xft/Xft.h>
- #include <X11/XKBlib.h>
-+#include <X11/Xresource.h>
-
- char *argv0;
- #include "arg.h"
-@@ -45,6 +46,19 @@ typedef struct {
- signed char appcursor; /* application cursor */
- } Key;
-
-+/* Xresources preferences */
-+enum resource_type {
-+ STRING = 0,
-+ INTEGER = 1,
-+ FLOAT = 2
-+};
-+
-+typedef struct {
-+ char *name;
-+ enum resource_type type;
-+ void *dst;
-+} ResourcePref;
-+
- /* X modifiers */
- #define XK_ANY_MOD UINT_MAX
- #define XK_NO_MOD 0
-@@ -828,8 +842,8 @@ xclear(int x1, int y1, int x2, int y2)
- void
- xhints(void)
- {
-- XClassHint class = {opt_name ? opt_name : termname,
-- opt_class ? opt_class : termname};
-+ XClassHint class = {opt_name ? opt_name : "st",
-+ opt_class ? opt_class : "St"};
- XWMHints wm = {.flags = InputHint, .input = 1};
- XSizeHints *sizeh;
-
-@@ -1104,8 +1118,6 @@ xinit(int cols, int rows)
- pid_t thispid = getpid();
- XColor xmousefg, xmousebg;
-
-- if (!(xw.dpy = XOpenDisplay(NULL)))
-- die("can't open display\n");
- xw.scr = XDefaultScreen(xw.dpy);
- xw.vis = XDefaultVisual(xw.dpy, xw.scr);
-
-@@ -1964,6 +1976,59 @@ run(void)
- }
- }
-
-+int
-+resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
-+{
-+ char **sdst = dst;
-+ int *idst = dst;
-+ float *fdst = dst;
-+
-+ char fullname[256];
-+ char fullclass[256];
-+ char *type;
-+ XrmValue ret;
-+
-+ snprintf(fullname, sizeof(fullname), "%s.%s",
-+ opt_name ? opt_name : "st", name);
-+ snprintf(fullclass, sizeof(fullclass), "%s.%s",
-+ opt_class ? opt_class : "St", name);
-+ fullname[sizeof(fullname) - 1] = fullclass[sizeof(fullclass) - 1] = '\0';
-+
-+ XrmGetResource(db, fullname, fullclass, &type, &ret);
-+ if (ret.addr == NULL || strncmp("String", type, 64))
-+ return 1;
-+
-+ switch (rtype) {
-+ case STRING:
-+ *sdst = ret.addr;
-+ break;
-+ case INTEGER:
-+ *idst = strtoul(ret.addr, NULL, 10);
-+ break;
-+ case FLOAT:
-+ *fdst = strtof(ret.addr, NULL);
-+ break;
-+ }
-+ return 0;
-+}
-+
-+void
-+config_init(void)
-+{
-+ char *resm;
-+ XrmDatabase db;
-+ ResourcePref *p;
-+
-+ XrmInitialize();
-+ resm = XResourceManagerString(xw.dpy);
-+ if (!resm)
-+ return;
-+
-+ db = XrmGetStringDatabase(resm);
-+ for (p = resources; p < resources + LEN(resources); p++)
-+ resource_load(db, p->name, p->type, p->dst);
-+}
-+
- void
- usage(void)
- {
-@@ -2037,6 +2102,11 @@ run:
-
- setlocale(LC_CTYPE, "");
- XSetLocaleModifiers("");
-+
-+ if(!(xw.dpy = XOpenDisplay(NULL)))
-+ die("Can't open display\n");
-+
-+ config_init();
- cols = MAX(cols, 1);
- rows = MAX(rows, 1);
- tnew(cols, rows);
---
-2.26.2
-
diff --git a/x.o b/x.o
Binary files differ.