gchp / rustbox

Rust implementation of the termbox library
MIT License
466 stars 48 forks source link

Backspace does not work #52

Open benaryorg opened 8 years ago

benaryorg commented 8 years ago

I tried to react to a Key::Backspace in my program but I did not receive it, so I displayed the event that occurred and it was read as a KeyEvent(Ctrl('h')).

I don't know if rustbox or the underlying libraries are the problem but I will investigate further.

benaryorg commented 8 years ago

Tested using:

droundy commented 8 years ago

Control h is backspace in ASCII, so perhaps a translation is in order?

On Sun, Oct 4, 2015, 5:36 AM Katze notifications@github.com wrote:

Tested using:

  • desktop
    • enlightenment
    • none (tty) Backspace works here
  • terminal
    • terminology
    • xterm

— Reply to this email directly or view it on GitHub https://github.com/gchp/rustbox/issues/52#issuecomment-145330176.

benaryorg commented 8 years ago

So if I just do it like I did in this Gist everything is fine?

gchp commented 8 years ago

Interesting. What is the value of your $TERM environment variable?

benaryorg commented 8 years ago
echo $TERM

prints xterm.

gchp commented 8 years ago

Hmm. I've tried running this in a few different ways, and I always get the same result which is that Ctrl-h and backspace are different keys.

Can you give some more information on your environment, and what you are running to get this happening? Is the example in the gist above what you are using to re-produce this?

Sorry for the inconvenience!

benaryorg commented 8 years ago

The gist above is exactly what I used to test with.

I just made a new gist containing my current test program. It uses rustbox 0.7.2.

If I now run this and press the Backspace-key it prints Ctrl('h') instead of Key::Backspace.

It only behaves so when I run it under X (window manager, terminal and so on do not seem to matter at all). When I use it on a tty, everything runs fine.

I am running:

Edit: if you need any more detailed information about e.g. compile options of these programs, just tell me.

jmacdonald commented 7 years ago

@benaryorg just a head's up: I ran into the same issue with xterm on Arch Linux. Installing xfce4-terminal resolved the issue (it has more robust backspace handling). I also noticed that Vim has a :fixdel command to work around this sort of thing.

I'm willing to bet termbox itself exhibits this bug, although I've not yet tested it. Might be out of scope for Rustbox to fix issues with older terminals like these?

benaryorg commented 7 years ago

If your delete key terminal code is wrong, but the code for backspace is alright, you can put this in your .vimrc: :fixdel

I did read the whole entry of fixdel but it does seem to fix Delete and not Backspace at least from what I understood.

Furthermore the terminal I've used first (terminology) is part of the Enlightenment project which is being actively supported, to my knowledge. At least enlightenment itself keeps having releases, as do the underlying libraries efl and elementary which are also used by terminology.

Edit: But shouldn't at least xterm be supported as it is the reference terminal emulator just about everywhere.