suspend
dev_tool.tui.suspend
log = logging.getLogger(__name__)
module-attribute
HAS_JOB_CONTROL = hasattr(signal, 'SIGTSTP') and hasattr(signal, 'SIGCONT')
module-attribute
INPUT_POLL_SECONDS = 0.1
module-attribute
TerminalSuspension
A class that keeps terminal state correct across Ctrl+Z and fg.
A blessed terminal applies cbreak mode, the alternate screen and cursor visibility once, when its context is entered. Suspending the process hands the terminal back to the shell, which restores the modes it wants and never reinstates the application's, so a resumed application is left in canonical mode and receives no keystrokes until Enter is pressed. The alternate screen is reverted before the process stops, and a resume is recorded so the caller can enter its terminal context again.
The constructor for the TerminalSuspension class.
Parameters:
-
terminal(Terminal) –The blessed Terminal instance.
Source code in dev_tool/tui/suspend.py
handlers = {}
instance-attribute
resumed = False
instance-attribute
terminal = terminal
instance-attribute
__enter__
The context manager entry method that installs the handlers.
Returns:
-
Self–The TerminalSuspension instance.
__exit__
The context manager exit method that restores the handlers.
Parameters:
-
exc_type(type[BaseException] | None) –The exception type, if an exception was raised.
-
exc_val(BaseException | None) –The exception value, if an exception was raised.
-
traceback(object) –The traceback, if an exception was raised.
Source code in dev_tool/tui/suspend.py
acknowledge
A method that consumes a recorded resume.
Returns:
-
bool–True if the application was resumed since the last call.
install
A method that installs the suspend and continue handlers.
Source code in dev_tool/tui/suspend.py
restore
A method that restores the handlers that were replaced.
Source code in dev_tool/tui/suspend.py
restore_terminal
A function that reverts the alternate screen and cursor visibility.
Parameters:
-
terminal(Terminal) –The blessed Terminal instance.