----
On Thu, 6 Mar 2025 at 07:09, Michael van Elst <mlel...@serpens.de> 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 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. > >If that's important: both DEL and BS generate same control key "^?" > > Hmm. > > > A standard PC keyboard has a "Backarrow" key and a "Delete" key. > > On a PS/2 keyboard: > The "Backarrow" key generates a scancode 14, mapped to symbol "Delete" > The "Delete" key generates a scancode 211, mapped to symbol "Delete" > > On a USB keyboard: > The "Backarrow" key generates a usage code 42, mapped to symbol > "Backspace". > The "Delete" key generates a usage code 76, mapped to symbol "Delete". > > The console generates a "^H" for "Backspace" and a "^?" for "Delete". > > There is no PS/2 key that would generate "Backspace", you can enter > a "^H" with "Ctrl"+"H". > > > X11 has its own mappings. > > The "Backarrow" key generates a keycode 22, mapped to symbol "Backspace". > The "Delete" key generates a keycode 107, mapped to symbol "Delete". > > 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 "^?"). > > (*) xterm tries to deduce that behaviour from other sources, in > particular the "ptyInitialErase" resource, data from the tty driver > (i.e. if canonical mode uses ^H or ^? as erase character) and the > termcap entry. Then it checks the backarrowKeyIsErase resource > to modify it further. And finally an application can modify the > behaviour using escape sequences and the user can switch using > a menu entry. > > Other terminal programs use different, even more complex, methods > to map the key symbols to some character sequence. > > > > The terminal driver has configured an 'erase' character, that is > used to remove the last character entered (i.e. the "backspace" > operation to delete left from the cursor). This should better > be the same as the character generated by the "Backarrow" key, > which can be a problem of its own. > > 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. > > > > 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. > > In /etc/rc.conf I set wscons=YES to enable the wsconsole. You > probably have that as default. > > In /etc/wscons.conf I have added the following line: > > setvar wskbd map+ \"keycode\ 14\ =\ Cmd_ResetEmul\ BackSpace\ Delete\" > > This makes the "Backarrow" key (code 14) generate a "^H" on the > console and "Shift" + "Backarrow" generates a "^?". I think this response merits an addition to the wiki. > > > Greetings >