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

Backspace with modifiers not recognised as backspace #504

Closed
fabi321 opened this issue Oct 29, 2020 · 10 comments
Closed

Backspace with modifiers not recognised as backspace #504

fabi321 opened this issue Oct 29, 2020 · 10 comments

Comments

@fabi321
Copy link

fabi321 commented Oct 29, 2020

Describe the bug
If I press backspace together with a modifier like ctrl or shift, it gets interpreted as char + modifier.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://gitlab.com/kuenstler/yint-rs
  2. compile and run it
  3. press any modifier + backspace
  4. See error

Expected behavior
In case of ctrl + backspace, it should delete unicode words. in other cases it should delete the last unicode grapheme.

OS

  • Linux

Terminal/Console

  • VSCode terminal: ctrl -> w, shift -> h, alt -> delete (0x7f)
  • Konsole: ctrl -> h, shift -> backspace, alt -> delete (0x7f)
  • Ubuntu console window: like Konsole

Language
German

@TimonPost
Copy link
Member

I can not give you a definitive answer. Terminal input sequence codes are terrible to work with. Your language, key-board layout can play a role here. However, if you enable raw mode keep in mind any behavior like deleting the last word will not work anymore. It's your responsibility to get it to work.

@fabi321
Copy link
Author

fabi321 commented Oct 29, 2020

Yeah, of course, I implemented something that works on ctrl + backspace and it never receives any ctrl + backspace. That's some custom behavior I programmed, but it never gets to action since it never gets any ctrl + backspace.

@fabi321
Copy link
Author

fabi321 commented Oct 29, 2020

on Konsole, ctrl + backspace yields ^H (0x08), while on VSCode, ctrl + backspace yields ^W (0x17)

@TimonPost
Copy link
Member

TimonPost commented Oct 30, 2020

Hrm...

Looking through some terminal sequence documentation I see that ^ H represents backspace with the 0X08 hex code, in vt100 terminals. https://www.real-world-systems.com/docs/ANSIcode.html

I will have to dive into the ANSI code parsing of crossterm to see why this is not throwing a backspace event. It could be the case it is not yet supported in combinations with CTRL.

@fabi321
Copy link
Author

fabi321 commented Oct 30, 2020

As far as I've understood the /src/event/sys/unix/parse.rs code, the following lines in parse_event

        c @ b'\x01'..=b'\x1A' => Ok(Some(InternalEvent::Event(Event::Key(KeyEvent::new(
            KeyCode::Char((c as u8 - 0x1 + b'a') as char),
            KeyModifiers::CONTROL,
        ))))),

(line 83 and following)
are responsible for those characters

@fabi321
Copy link
Author

fabi321 commented Oct 30, 2020

I wrote a possible solution at #506 , feel free to change the style

@fabi321
Copy link
Author

fabi321 commented Oct 30, 2020

Maybe it would be a cleaner solution, if one added another KeyCode type ControlCode to raise the programmers awareness for other control codes like ^W (which I hardcoded to ctrl + backspace).

@David-Else
Copy link

Could someone fix this? It is a real show stopper for people used to the ctrl backspace for deleting a word shortcut.

@jrnxf
Copy link

jrnxf commented Apr 27, 2022

Also would love to see this added! Was banging my head against the wall trying to figure out why there were no modifiers when I hit backspace until I realized this just wasn't supported lol

@TimonPost
Copy link
Member

TimonPost commented Jun 30, 2022

Closing in favor of #685.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants