Skip to content

readline: make ctrl-l clear screen & redraw line #6639

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 3 commits into from
Jul 29, 2022

Conversation

jepler
Copy link

@jepler jepler commented Jul 24, 2022

.. similar to how standard Python does it.

Closes: #6635

Copy link
Member

@gamblor21 gamblor21 left a comment

Choose a reason for hiding this comment

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

The code looks good, the control string works when I copy it to PuTTy but I'm having issues (on my end and ran out of time) testing it so I do not want to approve just by myself.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Want to make this work in Terminal too? (For displays that echo the serial output.)

@jepler
Copy link
Author

jepler commented Jul 25, 2022

If by "Terminal" you mean the mac terminal program / command window, I don't have a mac to test on. I only tried xfce4, a standard-ish terminal on Linux, based on the list of ANSI escape codes at https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences (though I was reading a different reference the wikipedia codes match)

If it's not widely compatible then we can just close this up, I'm not a terminal expert.

@tannewt
Copy link
Member

tannewt commented Jul 25, 2022

@jepler
Copy link
Author

jepler commented Jul 25, 2022

Using CSI 2 J might be worth trying, that's "clear entire screen" instead of "clear to end of screen". After the cursor has moved to 0,0 with CSI H, they should be the same, and so I chose the sequence that was shorter by 1 byte.

@jepler
Copy link
Author

jepler commented Jul 25, 2022

oh! taking a quick look at that code, it may be that the fix is to use the sequence CSI ; H as the H-parsing only comes after a ';' is encountered.

@jepler
Copy link
Author

jepler commented Jul 25, 2022

oh yes and only CSI 2 J is supported by the terminal class too

.. similar to how standard Python does it. The specific escape sequence
is chosen for compatibility with the built-in `terminalio.Terminal`.

Closes: adafruit#6635
@jepler
Copy link
Author

jepler commented Jul 26, 2022

OK it's now tested on a pyportal. In addition to the problem of the incompatible escape sequences, it was originally inside a disabled #if block, but one that is enabled in the 'unix port' which is where I had tested initially.

Co-authored-by: Scott Shawcroft <[email protected]>
@jepler jepler requested a review from tannewt July 26, 2022 16:39
Copy link
Member

@gamblor21 gamblor21 left a comment

Choose a reason for hiding this comment

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

Works in PuTTY now. The ifdef was why it wasn't working for me before.

@tannewt
Copy link
Member

tannewt commented Jul 26, 2022

#6608 includes a fix for the build that runs out of space.

@jepler jepler enabled auto-merge July 29, 2022 01:14
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thank you!

@jepler jepler merged commit 2e39610 into adafruit:main Jul 29, 2022
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.

echo ctrl-L in repl
3 participants