diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-19 02:19:48 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-19 02:19:48 -0400 |
commit | d9ed3612b9550ec3b82427a0ef822e8c8418ac89 (patch) | |
tree | f98625589832aad76dfa619342040d5aca298e19 /cmd2/cmd2.py | |
parent | bd34fee86d66a610d1e0bb392186dc73e883e2db (diff) | |
download | cmd2-git-d9ed3612b9550ec3b82427a0ef822e8c8418ac89.tar.gz |
Moving cursor to beginning of line before printing alert
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 874fdf6c..d817e461 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -3233,6 +3233,9 @@ Script should contain one command per line, just like command would be typed in terminal_str += (ansi.clear_line() + Cursor.UP(1)) * (num_input_lines - 1) terminal_str += ansi.clear_line() + # Move the cursor to the beginning of the first input line + terminal_str += '\r' + # Print the alert terminal_str += alert_msg + '\n' @@ -3245,7 +3248,7 @@ Script should contain one command per line, just like command would be typed in # Redraw the prompt and input line rl_force_redisplay() - def worker(self): + def alerter(self): import time while True: alert_msg = "\n***********************************************\n" \ @@ -3256,7 +3259,7 @@ Script should contain one command per line, just like command would be typed in def do_alert(self, args): import threading - printer = threading.Thread(target=self.worker, daemon=True) + printer = threading.Thread(target=self.alerter, daemon=True) printer.start() def cmdloop(self, intro: Optional[str]=None) -> None: |