1

I'm currently using the python prompt-toolkit module to emulate a shell and would like to capture CTRL-Z to force the running command to be back grounded in a way that makes sense for my application.

The problem I'm having is the KeyBinding events only trigger while a prompt session is actively running and I would like to use the input processing and key binding code between prompt sessions.

For example:

while True:
    line = await prompt_toolkit.prompt_async(">")
    # Parse line and run coroutine
    if ctrl_z_detected:
        # Don't wait for the coroutine to finish, show a new prompt
        continue
    else:
        # Wait for coroutine to finish

I realize the code won't flow like that exactly, but you should get the idea.

So the question I have is whether the input processing and key binding code can be used by themselves in a smaller async task without a full prompt_toolkit application to do what I want?

Neuron
  • 5,141
  • 5
  • 38
  • 59
Jaime
  • 1,182
  • 2
  • 12
  • 29

0 Answers0