+
+## 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.