kakoune: Backspace key does not register under Xterm
Question
I’ve been postponing this issue for quite a while. It only happens under xterm.
At first I thought this annoying problem could have been caused by the initialization file, then I invoked kak -n
but the problem persisted.
Backspace seems to work under kitty, or under kde’s konsole, or even under xfce4-terminal emulators.
It also works [backspace key] with the combination of either vim, neovim under xterm, or even emacs -nw
Modifying xorg configuration file for the keyboard layout and its options made no difference either.
KeyPress event, serial 37, synthetic NO, window 0x5000001,
root 0x118, subw 0x0, time 385042, (110,-245), root:(661,91),
state 0x0, keycode 22 (keysym 0xff08, BackSpace), same_screen YES,
XLookupString gives 1 bytes: (08) "
XmbLookupString gives 1 bytes: (08) "
XFilterEvent returns: False
Heck. Changing even the physical board made also no difference.
It does not happen with the combination of kak any other terminal emulators, but with the same token, the other editors do not have the issue either registering the backspace
key under xterm.
This is a good one. (Sarcastically speaking)
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 16 (14 by maintainers)
Recent versions of Kakoune do not depend on ncurses anymore.
I wrote up a bit about the history of Backspace handling in #3863. In brief:
^H
(byte 0x08).^?
(byte 0x7F), but can be switched into a compatibility mode that sends 0x08, by default or at runtimestty erase
telnet
is designed to support different backspace conventions on the host versus the clientterminfo
database has thekbs
capability to define what the backspace key sendst_kb
andt_kD
options, as well as the special:fixdel
command to sort them outptyInitialErase
,ttyModes
,backarrowKey
, andbackarrowKeyIsErase
, plus with potentially consultingterminfo
and the VT200 runtime compatibility switchIn short, there’s a lot of places that can be misconfigured, and a lot of apps (including shells) always treat both
^H
and^?
as “backspace” just in case, so if things are misconfigured they can still work in some apps but not others.Kakoune (since #3863) checks the
stty erase
value at startup, and whatever the kernel thinks the backspace key is, that’s what it treats as backspace.Nope. If you run
cat
and hit the backspace key, it should not print anything, it should backspace over previous characters you’ve typed. If something appears, that means the kernel’s idea of backspace is different from the terminal’s. You can either reconfigure the kernel (withstty erase
) or reconfigure the terminal, but once they agree, Kakoune should work.Some questions:
stty -a | grep -o ' erase[^;]*'
print inside xterm?cat
inside xterm and press the backspace key, does it print anything?As a concrete example, Debian policy is that the Backspace key should always produce
^?
, not<c-h>
, and every terminal emulator packaged in Debian behaves that way, by patching the source code if necessary. Other distros may have different policies, third-party packages may have different policies, and of course defaults can be changed (for example, to interoperate with systems with the opposite default).