Ctrl + H is misbehaving. #676

Open
opened 2021-09-06 21:23:10 +02:00 by theteachr · 7 comments
theteachr commented 2021-09-06 21:23:10 +02:00 (Migrated from github.com)

Ctrl + H is not having the desired effect. I have a key bind set for it in Vim, but it's having the same effect as Backspace. The same key bind in tmux is not functioning either.

<kbd>Ctrl</kbd> + <kbd>H</kbd> is not having the desired effect. I have a key bind set for it in **Vim**, but it's having the same effect as <kbd>Backspace</kbd>. The same key bind in **tmux** is not functioning either.
theteachr commented 2021-09-06 21:25:33 +02:00 (Migrated from github.com)

Environment

OS: macOS 15
Terminal Version: 1.1.1

### Environment OS: macOS 15 Terminal Version: 1.1.1
fritzy commented 2021-12-21 23:28:26 +01:00 (Migrated from github.com)

@theteachr I have this exact same issue.

@theteachr I have this exact same issue.
razziel89 commented 2022-03-25 22:45:42 +01:00 (Migrated from github.com)

I am experiencing the same issue. Does anyone have an idea how that could be debugged?

Update: I suspect this might have something to do with the keymaps defined in these files:

  • qmltermwidget/lib/kb-layouts/macbook.keytab
  • qmltermwidget/lib/kb-layouts/solaris.keytab
  • qmltermwidget/lib/kb-layouts/historic/x11r5.keytab
  • qmltermwidget/lib/default.keytab
  • qmltermwidget/lib/kb-layouts/default.keytab

since they specify some specifc treatment of ctrl-h.

I am experiencing the same issue. Does anyone have an idea how that could be debugged? Update: I suspect this might have something to do with the keymaps defined in these files: - qmltermwidget/lib/kb-layouts/macbook.keytab - qmltermwidget/lib/kb-layouts/solaris.keytab - qmltermwidget/lib/kb-layouts/historic/x11r5.keytab - qmltermwidget/lib/default.keytab - qmltermwidget/lib/kb-layouts/default.keytab since they specify some specifc treatment of ctrl-h.
razziel89 commented 2022-04-01 19:10:37 +02:00 (Migrated from github.com)

I did look around a bit more and managed to find a fix that does not require modifications to cool-retro-term or qmltermwidget. I am writing it down here in case it helps someone. The fix relies on the fact that qmltermwidget allows to define an alternative directory for keytabs via an environment variable (see here). To avoid Ctrl+H behaving like backspace, do the following:

  • download the default keytab to /usr/local/share/crt_keytabs/default.keytab (on my machine, the default keytab is the one that is picked up)
  • add this line to your /etc/environment or make it available to your environment in another way: KB_LAYOUT_DIR=/usr/local/share/crt_keytabs
  • replace this line in the downloaded default.keytab by this one: key Backspace -Control : "\x7f"

Maybe the above helps someone. FYI @Swordfish90. I haven't yet tried whether it works for the appimage, too, but I would think so. You could, of course, replace /usr/local/share/crt_keytabs/default.keytab by any other directory you want.

The background I could find out in case it is interesting for someone, it was for me:

It seems as if terminals can send two different signals indicating backspace, Ctrl+H (also called ^H or \x08 in hex or \b) or Ctrl+Backspace (also called ^? or \x7f in hex). Different terminals handle things differently. You can find that out by running showkey -a and hitting backspace, end with Ctrl+D, which I did on my machine for a few:

xterm cool-retro-term konsole gnome-terminal
^? ^H ^? ^?

I've read somewhere that xterm used ^H, but the ones I have access to do not seem to do that. It looks like more terminals send ^? than ^H, which means it could maybe make sense to do the same for cool-retro-term 🤷. I did learn a lot about terminals while looking through the code, maybe this is interesting for someone else, too.

I did look around a bit more and managed to find a fix that does not require modifications to cool-retro-term or qmltermwidget. I am writing it down here in case it helps someone. The fix relies on the fact that qmltermwidget allows to define an alternative directory for keytabs via an environment variable (see [here](https://github.com/Swordfish90/qmltermwidget/blob/master/lib/tools.cpp#L14-L28)). To avoid Ctrl+H behaving like backspace, do the following: - download the [default keytab](https://github.com/Swordfish90/qmltermwidget/blob/master/lib/kb-layouts/default.keytab) to `/usr/local/share/crt_keytabs/default.keytab` (on my machine, the default keytab is the one that is picked up) - add this line to your `/etc/environment` or make it available to your environment in another way: `KB_LAYOUT_DIR=/usr/local/share/crt_keytabs` - replace [this line](https://github.com/Swordfish90/qmltermwidget/blob/master/lib/kb-layouts/default.keytab#L39) in the downloaded `default.keytab` by this one: `key Backspace -Control : "\x7f"` Maybe the above helps someone. FYI @Swordfish90. I haven't yet tried whether it works for the appimage, too, but I would think so. You could, of course, replace `/usr/local/share/crt_keytabs/default.keytab` by any other directory you want. The background I could find out in case it is interesting for someone, it was for me: It seems as if terminals can send two different signals indicating backspace, Ctrl+H (also called `^H` or `\x08` in hex or `\b`) or Ctrl+Backspace (also called `^?` or `\x7f` in hex). Different terminals handle things differently. You can find that out by running `showkey -a` and hitting backspace, end with Ctrl+D, which I did on my machine for a few: | xterm | cool-retro-term | konsole | gnome-terminal | | - | - | - | - | | ^? | ^H | ^? | ^? | I've read somewhere that xterm used ^H, but the ones I have access to do not seem to do that. It looks like more terminals send ^? than ^H, which means it could maybe make sense to do the same for cool-retro-term :shrug:. I did learn a lot about terminals while looking through the code, maybe this is interesting for someone else, too.
razziel89 commented 2022-04-01 19:20:39 +02:00 (Migrated from github.com)

Sorry, that was too quick. It seems like the environment variable is overwritten here. One resolution could be to only overwrite the environment variable if is not yet set.

UPDATE: PR suggesting a small workaround is open here.

Sorry, that was too quick. It seems like the environment variable is overwritten [here](https://github.com/Swordfish90/qmltermwidget/blob/master/src/qmltermwidget_plugin.cpp#L35). One resolution could be to only overwrite the environment variable if is not yet set. UPDATE: PR suggesting a small workaround is open [here](https://github.com/Swordfish90/qmltermwidget/pull/37).
spudlyo commented 2023-07-25 05:23:11 +02:00 (Migrated from github.com)

Look for default.keytab on your computer. On my computer it's located at:
/usr/lib/aarch64-linux-gnu/qt5/QMLTermWidget/kb-layouts/default.keytab

This file specifies how the backspace key is handled. By default it emits ^H, and when hit Ctrl-backspace it emits ^?. This is important because it also sets your erase key to ^H. You can verify this by doing:

stty -a | grep erase

When your terminal is set this way, vim, or emacs, or tmux is going to treat ^H as the erase key, and not a literal ^H. If you edit the keytab file @razziel89 suggests, this will change. If you can't find the keytab file, or don't feel like editing the keytab file, you can simply do:

stty erase ^?

This will fix ^H so it works, but you'll need to press C-backspace whenever you want to get a backspace in your shell, or you'll just see a ^H on the screen. If you change your keytab file, stty erase will automatically be set to ^?.

Look for `default.keytab` on your computer. On my computer it's located at: `/usr/lib/aarch64-linux-gnu/qt5/QMLTermWidget/kb-layouts/default.keytab` This file specifies how the backspace key is handled. By default it emits ^H, and when hit Ctrl-backspace it emits ^?. This is important because it also sets your erase key to ^H. You can verify this by doing: `stty -a | grep erase` When your terminal is set this way, vim, or emacs, or tmux is going to treat ^H as the erase key, and not a literal ^H. If you edit the keytab file @razziel89 suggests, this will change. If you can't find the keytab file, or don't feel like editing the keytab file, you can simply do: `stty erase ^?` This will fix ^H so it works, but you'll need to press C-backspace whenever you want to get a backspace in your shell, or you'll just see a ^H on the screen. If you change your keytab file, `stty erase` will automatically be set to ^?.
jayjwa commented 2024-01-25 21:44:56 +01:00 (Migrated from github.com)

I had the same issue. It's even more a problem for me because I'm using CRT to login to OpenVMS systems remotely and they don't have a DEL key (it just re-renders the previous line), only Backspace which needs to send ^?. Without changing it, I needed to use ctrl-shift-backspace to erase a character.

My system keeps the keytab at /usr/lib64/qt5/qml/QMLTermWidget/kb-layouts/default.keytab. Setting
key Backspace -Control : "\x7f"
fixes the problem. Now uxterm, urxvt, and CRT all send (backspace at top, delete key next):

showkey -a                                                

Press any keys - Ctrl-D will terminate this program

^?      127 0177 0x7f
^[[3~    27 0033 0x1b
         91 0133 0x5b
         51 0063 0x33
        126 0176 0x7e
^D        4 0004 0x04

Maybe a small note in the documentation could save people some time.

I had the same issue. It's even more a problem for me because I'm using CRT to login to OpenVMS systems remotely and they don't have a DEL key (it just re-renders the previous line), only Backspace which needs to send ^?. Without changing it, I needed to use ctrl-shift-backspace to erase a character. My system keeps the keytab at /usr/lib64/qt5/qml/QMLTermWidget/kb-layouts/default.keytab. Setting `key Backspace -Control : "\x7f"` fixes the problem. Now uxterm, urxvt, and CRT all send (backspace at top, delete key next): ``` showkey -a Press any keys - Ctrl-D will terminate this program ^? 127 0177 0x7f ^[[3~ 27 0033 0x1b 91 0133 0x5b 51 0063 0x33 126 0176 0x7e ^D 4 0004 0x04 ``` Maybe a small note in the documentation could save people some time.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seeseemelk/cool-retro-term#676
No description provided.