Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-134746: implement Ctrl+Alt+L clear display keymap in pyREPL#138521
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
python-cla-botbot commentedSep 5, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
StanFromIreland left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Please undo all of the unrelated changes.
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
510c8e7 to17ecbe7CompareMost changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
sharmaigne commentedSep 5, 2025
Done! Sorry, forgot to turn off the formatter. |
Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
sharmaigne commentedSep 5, 2025
corona10 commentedSep 5, 2025
|
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Donghee Na <donghee.na92@gmail.com>
corona10 commentedSep 5, 2025
Traceback (most recent call last): |
sharmaigne commentedSep 5, 2025
@corona10 reran the test suite, should be good now |
| MOVE_UP = "\x1b[{}A" | ||
| MOVE_DOWN = "\x1b[{}B" | ||
| CLEAR = "\x1b[H\x1b[J" | ||
| CLEAR_ALL= "\x1b[3J\x1b[2J\x1b[H" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| CLEAR_ALL="\x1b[3J\x1b[2J\x1b[H" | |
| CLEAR_ALL="\x1b[H\x1b[3J\x1b[J" |
Using this works for me in the new virtual console on Windows. Also more symmetric to theCLEAR above.
| def clear_all(self) -> None: | ||
| """Clear screen and scrollback buffer.""" | ||
| self.__write("\x1b[3J\x1b[2J\x1b[H") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| self.__write("\x1b[3J\x1b[2J\x1b[H") | |
| self.__write("\x1b[H\x1b[3J\x1b[2J") |
Altough both worked for me on Ubuntu 24.0.4.3 LTS, maybe starting with\x1b[H is better?
Since it is used like so for clear
cpython/Lib/_pyrepl/terminfo.py
Line 176 in1c984ba
| "clear":b"\x1b[H\x1b[2J",# Clear screen and home cursor |
cpython/Lib/_pyrepl/terminfo.py
Line 250 in1c984ba
| "clear":b"\x1b[H\x1b[J",# Clear screen and home cursor (different from ansi!) |
And for symmetry with Windows (see below)?
| def clear_all(self) -> None: | ||
| """Clear screen and scrollback buffer.""" | ||
| self.__write("\x1b[3J\x1b[2J\x1b[H") | ||
| self.clear() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This writes another "clear" sequence to the terminal, which did not play nicely on Ubuntu 24.0.4.3 LTS for me.
Replacing this with
self.__gone_tall=1self.__move=self.__move_tallself.posxy=0,0self.screen= []
did work for me, though. But I suggest to extract that in a new method (maybe called_clear?) to avoid repetition. Can be used in
cpython/Lib/_pyrepl/unix_console.py
Lines 350 to 353 in1c984ba
| self.posxy=0,0 | |
| self.__gone_tall=0 | |
| self.__move=self.__move_short | |
| self.__offset=0 |
and the
self.screen = [] a few lines above, too.| def clear_all(self) -> None: | ||
| """Clear screen and scrollback buffer.""" | ||
| self.__write(CLEAR_ALL) | ||
| self.clear() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
See my comments wrt to Unix above. Although on Windows this does no harm for me, I'd suggest to extract that, too. Please note that#138732 should be merged first, though, since this is the reason forself.screen = [""] here vsself.screen = [] inprepare (see#138732 (comment)).
chris-eibl commentedSep 14, 2025
In the legacy console on Windows this command is not executed, because in cpython/Lib/_pyrepl/windows_console.py Lines 471 to 481 in1c984ba
|
chris-eibl commentedSep 23, 2025
To smoothly work on Windows in the virtual console (AKA Windows Terminal),#139263 is needed, too. |
Uh oh!
There was an error while loading.Please reload this page.
Changes:
clear_all()method to console files that does whatclear()does + clears scrollbackCtrl+Alt+LkeymapNote:
description of clear_display behavior: Clear the screen and, if possible, the terminal's scrollback buffer, then redraw the current line, leaving the current line at the top of the screen.
Manually tested for unix but not yet tested for windows