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.
Changes fromall commits
d2eab6f17ecbe7457e1e2236dd1314422a4c0f2687d9fc1c9eb8b0228da3576File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -114,6 +114,11 @@ def clear(self) -> None: | ||
| """Wipe the screen""" | ||
| ... | ||
| @abstractmethod | ||
| def clear_all(self) -> None: | ||
sharmaigne marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| """Clear screen and scrollback buffer.""" | ||
| ... | ||
| @abstractmethod | ||
| def finish(self) -> None: | ||
| """Move the cursor to the end of the display and otherwise get | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -561,6 +561,11 @@ def clear(self): | ||||||||||
| self.posxy = 0, 0 | ||||||||||
| self.screen = [] | ||||||||||
| def clear_all(self) -> None: | ||||||||||
| """Clear screen and scrollback buffer.""" | ||||||||||
| self.__write("\x1b[3J\x1b[2J\x1b[H") | ||||||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
Altough both worked for me on Ubuntu 24.0.4.3 LTS, maybe starting with cpython/Lib/_pyrepl/terminfo.py Line 176 in1c984ba
cpython/Lib/_pyrepl/terminfo.py Line 250 in1c984ba
And for symmetry with Windows (see below)? | ||||||||||
| self.clear() | ||||||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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 cpython/Lib/_pyrepl/unix_console.py Lines 350 to 353 in1c984ba
and the self.screen = [] a few lines above, too. | ||||||||||
| @property | ||||||||||
| def input_hook(self): | ||||||||||
| # avoid inline imports here so the repl doesn't get flooded | ||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -111,6 +111,7 @@ def __init__(self, err: int | None, descr: str | None = None) -> None: | ||||||
| MOVE_UP = "\x1b[{}A" | ||||||
| MOVE_DOWN = "\x1b[{}B" | ||||||
| CLEAR = "\x1b[H\x1b[J" | ||||||
| CLEAR_ALL= "\x1b[3J\x1b[2J\x1b[H" | ||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Suggested change
Using this works for me in the new virtual console on Windows. Also more symmetric to the | ||||||
| # State of control keys: https://learn.microsoft.com/en-us/windows/console/key-event-record-str | ||||||
| ALT_ACTIVE = 0x01 | 0x02 | ||||||
| @@ -516,6 +517,12 @@ def clear(self) -> None: | ||||||
| self.posxy = 0, 0 | ||||||
| self.screen = [""] | ||||||
| def clear_all(self) -> None: | ||||||
| """Clear screen and scrollback buffer.""" | ||||||
| self.__write(CLEAR_ALL) | ||||||
| self.clear() | ||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 for | ||||||
| def finish(self) -> None: | ||||||
| """Move the cursor to the end of the display and otherwise get | ||||||
| ready for end. XXX could be merged with restore? Hmm.""" | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Added a new ``clear_display`` command in the REPL. ``Ctrl+Alt+L`` now clears | ||
| the screen and, if possible, the terminal’s scrollback buffer, then redraws | ||
| the current line at the top of the screen. | ||
| Manually tested on Unix; Windows behavior not yet verified. |
Uh oh!
There was an error while loading.Please reload this page.