gh-119548: Add a 'clear' command to the REPL (#119549)

This commit is contained in:
Pablo Galindo Salgado 2024-05-25 17:15:54 +01:00 committed by GitHub
parent a531fd7fdb
commit e3bac04c37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View file

@ -238,6 +238,7 @@ class Reader:
cxy: tuple[int, int] = field(init=False)
lxy: tuple[int, int] = field(init=False)
calc_screen: CalcScreen = field(init=False)
scheduled_commands: list[str] = field(default_factory=list)
def __post_init__(self) -> None:
# Enable the use of `insert` without a `prepare` call - necessary to
@ -557,6 +558,10 @@ class Reader:
self.restore()
raise
while self.scheduled_commands:
cmd = self.scheduled_commands.pop()
self.do_cmd((cmd, []))
def last_command_is(self, cls: type) -> bool:
if not self.last_command:
return False