Skip to content

Add SIGTSTP / suspend / Control-Z / ^Z handling #78

Description

@iconoclasthero

Please considering adding a suspend handler for toolong. Textualize appears to offer a way to SIGSTP
https://textual.textualize.io/api/app/#textual.app.App.action_suspend_process
https://textual.textualize.io/api/app/#textual.app.App.app_suspend_signal
https://textual.textualize.io/api/app/#textual.app.App.action_suspend_process

#!/home/$USER/.local/share/pipx/venvs/toolong/bin/python3
import sys

# 1. Import toolong's loop and core interface class
from toolong.cli import run as original_run
from toolong.ui import UI

# 2. Save the original mount routine so we don't break the layout boot-up
original_on_mount = UI.on_mount

# 3. Create a custom mount function that runs right as the UI loads
def custom_on_mount(self) -> None:
    # First, let toolong boot up its standard interface screens
    original_on_mount(self)

    # Force 'ctrl+z' straight into Textual's active runtime key manager
    self.bind("ctrl+z", "suspend_process", description="Suspend", show=False)

# 4. Overwrite toolong's mount method with our modified one
UI.on_mount = custom_on_mount

# 5. Execute the app normally
if __name__ == "__main__":
    sys.argv = ["toolong"] + sys.argv[1:]
    original_run()

Enabled suspend but the log never populated so it seems like it should work if added directly to the source instead of trying to inject it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions