contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.37k stars 102 forks source link

Can't delete over previous search string #1353

Open cqexbesd opened 8 months ago

cqexbesd commented 8 months ago

Contour Terminal version

0.4.0-master-9c3073db

Installer source

Github: source code cloned

Operating System

Arch Linux as of a few days ago

Architecture

x86-64

Other Software

No response

Steps to reproduce

  1. Go into vi mode (^shift-space)
  2. Search for something (/something)
  3. Hit return
  4. Enter search mode (/)
  5. Try using backspace to delete the previous search string
  6. Note that ^U still works

Expected Behavior

Backspace would delete single characters

Actual Behavior

Nothing happens when pressing backspace (Debug[default]: sendKeyEvent: 16777219 "\b" QFlags<Qt::KeyboardModifier>(NoModifier) ((null):0, (null))).

^BS seems to move the cursor forward (Debug[default]: sendKeyEvent: 16777219 "\b" QFlags<Qt::KeyboardModifier>(ControlModifier) ((null):0, (null))) though if you later type a regular character the cursor jumps back to where it was.

^H seems to be ignored ([error] ViInputHandler: Receiving control code Control+0x48 in search mode. Ignoring.).

Additional notes

No response

christianparpart commented 8 months ago

^H is ignored, becuase the search input field is manually implemented. If you press ^H (Control + H), then it's interpreted as such - a keyboard shortcut.

Can you please run Contour with the following CLI args: contour debug gui.input,vt.input and then press Backspace on your keyboard?

This is how it looks like for me:

[2023-12-01 20:06:28.372398583.372397] [gui.input] Key Press event received:  Backspace
[2023-12-01 20:06:28.372576624.372576] [vt.input] Sending  "Backspace" Press.
[2023-12-01 20:06:28.575200045.575199] [gui.input] Key Release event received:  Backspace

Surprisingly (?) for me, pressing Backspace key in the search field, in order to delete the character left to the cursor, is actually working.

The reason why Ctrl+U is working for you, is, because I manually implemented that (because I use that a lot myself:D).

I would like to understand why you probably won't get "Backspace" events (as I posted in the logs above) rather than working around it without understanding why our two systems differ.

Can it be that you're building against Qt5 while I am using Qt6?

cqexbesd commented 8 months ago
Debug[default]: sendKeyEvent:  16777219   "\b"   QFlags<Qt::KeyboardModifier>(NoModifier) ((null):0, (null))
[2023-12-01 21:59:43.273265039.273264] [gui.input] Key Press event received:  Backspace
[2023-12-01 21:59:43.273314683.273314] [vt.input] Sending raw input to stdin: \x08
Debug[default]: sendKeyEvent:  16777219   "\b"   QFlags<Qt::KeyboardModifier>(NoModifier) ((null):0, (null))
[2023-12-01 21:59:43.386451039.386450] [gui.input] Key Release event received:  Backspace

So my BS key sends the ASCII BS - but yours sends "Backspace" - is this an extended keyboard mode thing? ^BS sends 7f (ASCII DEL) but if you have to handle each character I guess it sort of makes sense that moves the cursor on the screen but not internally.

(update: according to od when Contour says its sending Backspace things are receiving DEL(7f) and if I press Delete it sends some escape sequence. stty says erase is ^H (ASCII BS) so maybe the search field should respect the termios settings? Sending BS or DEL is complicated I know)

As an experiment I bound Backspace to Backspace in my config and the log now looks like:

Debug[default]: sendKeyEvent:  16777219   "\b"   QFlags<Qt::KeyboardModifier>(NoModifier) ((null):0, (null))
[2023-12-01 22:07:35.708984434.708984] [gui.input] Key Press event received:  Backspace
[2023-12-01 22:07:35.709484950.709484] [vt.input] Sending  "Backspace" Press.
Failed to open VDPAU backend libvdpau_radeonsi.so: cannot open shared object file: No such file or directory
Debug[default]: sendKeyEvent:  16777219   "\b"   QFlags<Qt::KeyboardModifier>(NoModifier) ((null):0, (null))
[2023-12-01 22:07:35.797433080.797432] [gui.input] Key Release event received:  Backspace

Backspacing in search now works, though the shared library error was unexpected.

ldd says I'm using QT6.

christianparpart commented 8 months ago

Ok, let me simply also act on \x08 then. I'll keep you posted. Thx :)