8000 capsules: BUGFIX: backspace/delete would send an extra EOL char by george-cosma · Pull Request #3654 · tock/tock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

capsules: BUGFIX: backspace/delete would send an extra EOL char #3654

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

Merged
merged 4 commits into from
Sep 9, 2023

Conversation

george-cosma
Copy link
Contributor
@george-cosma george-cosma commented Sep 4, 2023

Pull Request Overview

Whilst working on tockloader-rs/listen-prototype I've noticed a few peculiarities with the handling of backspace & delete. To cut a very long story short - every time backspace/delete/ANSI Delete is pressed in the process-console, an additional "null"/"end of line" byte is send. Python tockloader does not have an issue with this because its terminal emulator automatically converts it into a unicode character. The issue comes when developing for tockloader-rs where there isn't (or I haven't found) a fully-functional terminal emulator. As such, all bytes are treated as-is.

This also means null is a by out-of-place. Tock sends , which in effect should just delete the last byte. For the Unicode Null this works. For run-of-the-mill null, this doesn't work, and in fact it deletes the byte behind the . I don't know why this happens, but the same effect can be had by just sending .

Moreover, delete (ascii) was handled the same as backspace, which is confusing. ANSI Escape Sequence Delete is being handled properly (minus the null shenanigans). I've just made a logical short-circuit to make the code believe it is dealing with the escape sequence rather than a del byte.

Testing Strategy

I tested this using this branch of tockloader-rs, without the fixes implemented in the aforementioned pull request.

cargo run -- listen

Board: microbit v2

TODO or Help Wanted

The short-circuit condition to make a "DEL" char be treated the same as the escape sequence is a bit wonky. It works, but it I'd like a second opinion if we can leave it as-is or maybe extract the handling of "delete" (either) into a function or something else.

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

Copy link
Contributor
@bradjc bradjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be great if you could add this case to https://github.com/tock/tock/blob/master/tools/check_process_console.py

@george-cosma
Copy link
Contributor Author
george-cosma commented Sep 7, 2023

I've moved the "DEL" logic to next_state() and I've modified the "deleting" test to run same checks for both types of delete sequences.

I also had to modify the evaluation function of the tests because they were interpreting <space><backspace> quite literally. Of course, in actuality this has no effect over the actual output as all it does is cover up a remaining character from the previous message. As an alternative to it, I've tried to send an escape sequence to clear the line, but no luck. Neither versions of tockloader would actually interpret the escape sequence.

@george-cosma george-cosma requested a review from bradjc September 7, 2023 14:10
@bradjc bradjc enabled auto-merge September 9, 2023 16:34
@bradjc bradjc added this pull request to the merge queue Sep 9, 2023
Merged via the queue into tock:master with commit 290e6b3 Sep 9, 2023
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

Successfully merging this pull request may close these issues.

2 participants
0