Michael van Elst wrote: > p...@szwajn.net (pl) writes: > > Why is DEL deletes characters from the left (making BackSpace > > redundant), while on X (from base) it behaves as expected (removes > > from right)? How can I make it behave as in X11?
I would want to see the output of "stty -a" and see what the erase settings are set to in the tty driver. > > I know there's some historical background ongoing, but so far I > > know DEL removed chars from right since ever on IBM PC, so logical > > for me would be making such behaviour default at least on i386 and > > amd64 ports. DEL has never removed characters to the right in my experience. However the Keypad Delete to the right is usually configured that way. > > If that's important: both DEL and BS generate same control key "^?" On a standard PC keyboard there is usually a key labeled "Del" which is the Keypad Delete and distinct from the Backspace key. > A standard PC keyboard has a ... Excellent descriptions! > xterm then(*) interprets the symbols and generates "^H" for "Backspace" > and "^[[3~" for Delete (unless you have configured "DEL is Delete", > then it generates a "^?"). My personal opinion is that Xterm does this the wrong way around. > Other terminal programs use different, even more complex, methods > to map the key symbols to some character sequence. Frustratingly true! Having both Backspace BS ^H and DEL ^? date from paper tape and punch cards. If a hole has been punched in paper tape then it cannot be filled back in again. But the entire character can be deleted. Therefore both keys are needed. If a mistake has been made then Backspace (^H) until the punch is over the character to be deleted and then punch all of the holes with DEL (^?) causing the character to be deleted. Upon reading in DEL characters are ignored. Therefore when dealing with paper BOTH keys are necessary. When CRTs came along the choice of which key to use was rather arbitrary and different vendors made different choices. My memory of events (which is to say possibly faulty) is that IBM and therefore others such as HP chose the Backspace key ^H for the stty erase setting by default while others (fuzzy memory) chose DEL for the stty erase setting. Definitely HP-UX as I used it for many years. Prior to that other characters such as '#' and '@' were used for an erase character. Using ^H for erase creates problems of overloading that useful key in Emacs and Emacs has always had workarounds needed for such environments. Emacs on HP-UX always (annoyingly to me) required workarounds swapping ^H and ^?. Meanwhile when the Linux kernel came around it chose to use DEL as the stty erase character. This makes more sense to me. Personally I prefer that configuration. Everything just works much more nicely that way. Because of the huge popularity of the Linux kernel that has driven default choices in many terminal emulators. (But not Xterm which as described has a complicated configuration capability. I actually have many more notes about it than already mentioned.) > Some programs (usually those that do line-editing themselves) > handle this themselves. They either copy the behaviour of the > terminal driver, or (like tmux) have a hardcoded behaviour, > or (like tcsh) accept "^H" and "^?" as equal. Programs such as tcsh (and bash) which are hard coded to accept ^H and ^? as equal do so out of frustration of the user having things inconsistently configured. Which is great. The shell knows what the user is trying to do. But it does lead to people truly not understanding why things work sometimes and don't work other times. > The currently most common (but not the original) behaviour is > to make the "Backarrow" key generate "^H" and use that for the > erase operation, and since that is handled by the defaults almost > everywhere, I'm changing only the keyboard map if I have a PS/2 > keyboard. And for a dissenting opinion I always choose the reverse. I always have Backspace produce a DEL character. I feel that creates the most rationally consistent configuration. (Noting again that the Backspace producing DEL is distinct and separate from the Keypad Delete key.) Bob