Skip to content

Commit

Permalink
Experimental suspend context manager
Browse files Browse the repository at this point in the history
Pulling out the very core of Textualize#1541 to start to build it up again and
experiment and test (getting into the forge so I can then pull it down onto
Windows and test there).
  • Loading branch information
davep committed Jan 22, 2024
1 parent 82a91ab commit 004513c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
Generator,
Generic,
Iterable,
Iterator,
List,
Sequence,
Type,
Expand Down Expand Up @@ -3292,3 +3293,11 @@ def action_command_palette(self) -> None:
"""Show the Textual command palette."""
if self.use_command_palette and not CommandPalette.is_open(self):
self.push_screen(CommandPalette(), callback=self.call_next)

@contextmanager
def suspend(self) -> Iterator[None]:
if self._driver is not None:
self._driver.stop_application_mode()
with redirect_stdout(sys.__stdout__), redirect_stderr(sys.__stderr__):
yield
self._driver.start_application_mode()

0 comments on commit 004513c

Please sign in to comment.