Skip to content

Commit

Permalink
Merge branch 'ctrl-z' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed May 23, 2018
2 parents 7a040be + 0b2f887 commit 3e76725
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doitlive/keyboard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import os
import shlex
import signal
import subprocess
from tempfile import NamedTemporaryFile

Expand All @@ -16,6 +17,7 @@
ESC = '\x1b'
BACKSPACE = '\x7f'
CTRLC = '\x03'
CTRLZ = '\x1a'
RETURNS = {'\r', '\n'}

def wait_for(chars):
Expand Down Expand Up @@ -51,6 +53,14 @@ def magictype(text, prompt_template='default', speed=1):
if cursor_position >= len(text):
echo("\r", nl=True)
break
elif in_char == CTRLZ and hasattr(signal, 'SIGTSTP'):
# Background process
os.kill(0, signal.SIGTSTP)
# When doitlive is back in foreground, clear the terminal
# and resume where we left off
click.clear()
echo_prompt(prompt_template)
echo(text[:cursor_position], nl=False)
else:
if cursor_position < len(text):
echo(char, nl=False)
Expand Down

0 comments on commit 3e76725

Please sign in to comment.