Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't bind key ctrl-backspace (regression) #1975

Closed
dorsiflexion opened this issue Jul 3, 2023 · 4 comments
Closed

Can't bind key ctrl-backspace (regression) #1975

dorsiflexion opened this issue Jul 3, 2023 · 4 comments
Assignees
Labels
bug Unexpected problem or unintended behavior
Milestone

Comments

@dorsiflexion
Copy link

Bug summary

Ctrl-Backspace seems to be impossible to use as a key binding. This is a regression as it was possible prior to version 4.0.

Steps to reproduce

1. Press alt+k, followed by ctrl+backspace.

Current behavior

The output is: backspace /input delete_previous_char

Expected behavior

The output is: ctrl-backspace /input delete_previous_char

Suggested solutions

?

Additional information

Alternatively:

/key bind ctrl-backspace /input delete_previous_word doesn't work either.


  • WeeChat version: 4.0.1
  • OS, distribution and version: Arch Linux
  • Terminal: Alacritty 0.12.2
  • Terminal multiplexer (screen/tmux/…/none):  none
@dorsiflexion dorsiflexion added the bug Unexpected problem or unintended behavior label Jul 3, 2023
@flashcode flashcode self-assigned this Jul 3, 2023
@flashcode
Copy link
Member

flashcode commented Jul 3, 2023

Hi,

This is intentional, but probably we're lacking some doc to explain how to do it.

In fact WeeChat can not reliably distinguish backspace from ctrl-backspace: both keys have different raw code, but WeeChat can not know which one is backspace and which one is ctrl-backspace.

Then one way to bind ctrl-backspace is to bind the raw key code, which could be ctrl-h (this one is ctrl-backspace for me):

/key bind ctrl-h /print ctrl-h

Then try to press backspace and ctrl-backspace, you should have a different behavior.

If not working, try:

/key bind ctrl-? /print ctrl-?

If working fine, I'll update /help key to mention this.

@trygveaa
Copy link
Contributor

trygveaa commented Jul 3, 2023

To add to that, the reason WeeChat can't know which of these keys is which is that in a terminal emulator, backspace and ctrl-backspace maps to the ctrl-h and ctrl-? keys. However, which maps to which depends on which terminal emulator you're using and the configuration of that terminal emulator. So when WeeChat receives ctrl-h or ctrl-? there's no way for it to know if it came from a backspace press or a ctrl-backspace press. For more details about this, see this discussion: https://comp.terminals.narkive.com/i3ywh6Rv/backspace-h-vs-linux-vs-terminfo

To figure out what your terminal emulator sends, you can run /debug key in WeeChat and press ctrl-backspace.

Technically, in some terminal emulators it is possible to reliably distinguish between these keys by enabling an alternate keyboard protocol. However, this is not something WeeChat supports.

@flashcode
Copy link
Member

I propose to add this text in /help key:

For some keys you might need to use /debug key, that also displays
the raw key code that can be used as well (for example ctrl+backspace
could be ctrl-h or ctrl-?, depending on your terminal and other settings).

@dorsiflexion
Copy link
Author

Binding ctrl-h works for me. Thanks a lot. 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants