diff options
author | vg <vgm+dev@devys.org> | 2024-04-11 11:51:23 +0200 |
---|---|---|
committer | vg <vgm+dev@devys.org> | 2024-04-11 11:51:23 +0200 |
commit | e95f2f6ad1f174f0f1a3b86f030cdfb86be13a67 (patch) | |
tree | 4b38ab09af875a53e273a69725c02f631cfdb006 | |
parent | aa255fd04883c009948e47508b4121ff1fb3e6f5 (diff) | |
download | scripts-e95f2f6ad1f174f0f1a3b86f030cdfb86be13a67.tar.gz scripts-e95f2f6ad1f174f0f1a3b86f030cdfb86be13a67.tar.bz2 scripts-e95f2f6ad1f174f0f1a3b86f030cdfb86be13a67.zip |
improve curser save/restore to cope with window resizing
-rwxr-xr-x | scripts/fancy_sleep.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/fancy_sleep.py b/scripts/fancy_sleep.py index a87b33c..e65ad94 100755 --- a/scripts/fancy_sleep.py +++ b/scripts/fancy_sleep.py @@ -191,7 +191,6 @@ def test_parse_time(): def fancy_sleep_display(target_time): print() print('\n'*5, '\x1b[5A', sep='', end='') - print('\x1b[s', end='') # save cursor original_termios_attr = termios.tcgetattr(sys.stdin) noecho_termios_attr = original_termios_attr[:] noecho_termios_attr[3] &= ~termios.ECHO @@ -205,10 +204,11 @@ def fancy_sleep_display(target_time): minutes = int(delta / 60) % 60 seconds = int(delta) % 60 - print('\x1b[u', end='') # restore cursor + print('\x1b[s', end='') # save cursor time_string = '%02d:%02d:%02d' % (hours, minutes, seconds) #print('\rremainining time: %s' % time_string, end='') print_translated(time_string) + print('\x1b[u', end='') # restore cursor time.sleep(1) finally: |