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
Handling of backspace/delete #25
Comments
Unless I'm mistaken, pyte does only process the stdout of processes, and you're responsible yourself to connect the terminal input to the application, and if an application was designed to run in a vt100 terminal, it will understand these escape characters. |
Stream drops input if it is \x7f (should have been handled as backspace), fails in the argument parser for \x1b[3~ (Throws KeyError due to not expecting a tilde - I have opened case 26 for that). I'm using the streams to handle terminal input. Apart from a few unhandled scenarios, such as this, streams handle this scenario very well. Handling fancy terminal input is otherwise a pain in the butt. But even if this scenario will not be officially supported, applications are allowed to output an \x7f on stdout, which would require pyte to read it, not dump it. I will also have to process the output of child processes later on, but I have not found anything but pyte that seems to have nice handling of everything these wacko terminals decide to throw at it. (So, to everyone helping pyte get along, thank you very much. You help maintain the fragments of my sanity that I have left, even if only for a bit) |
The solution I've posted in #26 should work for backspace as well. |
Yes, local extension should work. And just like that, I might make a pull request that adds the extra keys. \x7f is at least essential. |
|
That line explicitly ignores it. It's not in the basic (streams.py:61), escape (streams.py:74), sharp (streams.py:85), or csi (streams.py:90) dicts, and explicitly ignored for draw, causing it to raise no events. |
Oh, silly me, you're right. IIRC, this was done because it improved the visual appearance of Midnight Commander, but I'm not completely sure. Unfortunately, I don't have a way of checking this atm. |
Hmm, I just tested it - It works just like a space. Cursor moves right, inserts an empty character with the current graphics mode. Maybe the original issue was that it was attempted handled as backspace, causing a bad cursor move? |
Reopening temporarily until that is figured out. |
What kind of default behaviour do you expect for the I think what we need here is a simple GUI terminal app, using |
I've just tested the following in iTerm2, xterm and
iTerm2 produces Please feel free to reopen if you think this behaviour is incorrect. |
After some testing, I have noticed that handling of backspace/delete in Stream does not seem to be perfect.
My terminal emulators generally support these 4 options for backspace and delete:
Many terminals only have settings to go from ASCII DEL to CTRL-H for compatibility reasons. This option makes Emacs sad, but is sometimes required. The escape sequence appears to be the only sequence resulting in forward-delete behaviour in my shell (Although it appears broken when I ssh through tmux). Neither the ASCII del char, nor the escape sequence is handled by pyte's streams. The del char never seems to raise any events, with the escape sequence raising a debug event.
I will most likely fork it later today to add DEL to control and escape and submit a pull request, unless I forget or someone else manage to do it before me.
UPDATE:
The issue lies with ASCII DEL (\x7f) being explicitly ignored. The forward delete thing is under another issue, and closed for now. As per a comment from @superbobry this was likely to fix Midnight Commander, but I believe that it might be due to incorrect handling. \x7f is just a whitespace rendition-wise, cursor-increment and all. It's only magic when it arrives on stdin from a terminal emulator, which it tends to do quite often.
The text was updated successfully, but these errors were encountered: