lxqt / qtermwidget

The terminal widget for QTerminal
https://lxqt.github.io
GNU General Public License v2.0
502 stars 256 forks source link

Ctrl+h produces <BS> in Neovim #235

Open skeate opened 5 years ago

skeate commented 5 years ago
Expected Behavior

In Neovim, enter insert mode and press ctrl+v ctrl+h. Output should be ^H.

Current Behavior

Output is

Context

This seems to be a regression, as the Arch binary version works as expected. I tried building qterminal & qtermwidget from source to see if I might be able to track down the problem myself, but curiously the problem still occurs when building tag 0.9.0.

Many people map <C-W> h to <C-H> for easier window navigation, so this probably will affect a number of people if it winds up in a release.

System Information
yan12125 commented 5 years ago

This behavior is changed in https://github.com/lxqt/qtermwidget/commit/b5da2e2dacf91da5aad720a81ab5606996586532 and it's the correct version. Maybe qtermwidget can have an option to use non-standard behavior like VTE to achieve compatibility with specific applications.

skeate commented 5 years ago

This is a bit beyond my depth, so apologies if this isn't relevant; just trying to relay some info that might be.

There was an old issue about this in the Neovim repo: https://github.com/neovim/neovim/issues/2048 Specifically with the recommendation to modify the terminfo: https://github.com/neovim/neovim/issues/2048#issuecomment-78045837

Also, that commit messages suggests the change is to behave like other terminals, but in gnome-terminal the expected behavior I mentioned is the actual behavior.

yan12125 commented 5 years ago

Thanks for the thread! Maybe my interpretation is wrong about Ctrl-H.

That's a long thread and I need some time to read them all :)

Also, that commit messages suggests the change is to behave like other terminals, but in gnome-terminal the expected behavior I mentioned is the actual behavior.

I was trying to make qtermwidget to behave like xterm, which is the standard for terminals using TERM=xterm.

yan12125 commented 5 years ago

After reading most comments in the long thread and some relevant discussions, I decide to add an option to allow qtermwidget to behave like gnome-terminal.

Notes to my self:

Ctrl-H is "ASCII backspace" but terminals ought to be sending ASCII DEL for the Backspace key instead. This may or maynot agree with what their terminfo file says, however, so it's all a huge mess.

IMO that's crazy, but seems there's no better option.

Screwtapello commented 4 years ago

IMO that's crazy, but seems there's no better option.

As some added historical context I learned recently:

So, if you're emulating a VT100, then backspace should be ^H, if you're emulating a VT200 or above (like xterm does) then backspace should be ^?. Either way, the terminal emulator should set stty erase to match whatever encoding it's chosen for the backspace key.

huyiqun commented 3 years ago

Facing the same problem in qterminal, curious to know if this will be fixed.

yan12125 commented 2 years ago

Either way, the terminal emulator should set stty erase to match whatever encoding it's chosen for the backspace key.

Sounds reasonable. Needs to investigate how to achieve that from qtermwidget. Probably invoking ioctls after allocating ptys?

gsantner commented 2 years ago

Hello, is there any fix already available, or a plan to fix it?

I used many different terminal-emulator applications (and also the non-gui fallback shell) - and qterminal is the only terminal application which not works correctly in this regard.
Pressing backspace does something complete else then in any other emulator (moving cursor position upwards), and trying to edit text this way is a chore, as it does something else then removing a character.

Is there any chance for this to be fixed, so backspace works properly like everywhere else?

Just for comparision - 4 different terminal applications. As it was mentioned somewhere that there is an option""to simulate gnome-terminal behaviour"". Not sure about that, i.e. KDE's Qt based konsole also does it right and that out of the box.

screenrecord-2022-11-13_15 27 16

Versions tried: 0.17.0, 0.16.1

ssb22 commented 1 month ago

Emacs users are also affected, since Ctrl-H is the default shortcut key for accessing Emacs's help system—otherwise you have to use e.g. M-x describe-function instead of Ctrl-H f. (My desktop Emacs runs on X11, but I also use it from the terminal when connecting to another machine over SSH.)

In QTerminal 1.4.0, Ctl-H works properly for me if I set File - Preferences - Behavior - Emulation to linux instead of default.

Borwe commented 3 weeks ago

Emacs users are also affected, since Ctrl-H is the default shortcut key for accessing Emacs's help system—otherwise you have to use e.g. M-x describe-function instead of Ctrl-H f. (My desktop Emacs runs on X11, but I also use it from the terminal when connecting to another machine over SSH.)

In QTerminal 1.4.0, Ctl-H works properly for me if I set File - Preferences - Behavior - Emulation to linux instead of default.

Same this worked for me too, I think it should be the default.