-
-
Notifications
You must be signed in to change notification settings - Fork 33k
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 our terms of service and privacy 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?
Changes from all commits
d2eab6f
17ecbe7
457e1e2
236dd13
14422a4
c0f2687
d9fc1c9
eb8b022
8da3576
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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") | ||||||||||
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 in 1c984ba
cpython/Lib/_pyrepl/terminfo.py Line 250 in 1c984ba
And for symmetry with Windows (see below)? |
||||||||||
self.clear() | ||||||||||
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 = 1
self.__move = self.__move_tall
self.posxy = 0, 0
self.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 in 1c984ba
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" | ||||||
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() | ||||||
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.