aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvg <vgm+dev@devys.org>2024-04-11 11:51:23 +0200
committervg <vgm+dev@devys.org>2024-04-11 11:51:23 +0200
commite95f2f6ad1f174f0f1a3b86f030cdfb86be13a67 (patch)
tree4b38ab09af875a53e273a69725c02f631cfdb006
parentaa255fd04883c009948e47508b4121ff1fb3e6f5 (diff)
downloadscripts-e95f2f6ad1f174f0f1a3b86f030cdfb86be13a67.tar.gz
scripts-e95f2f6ad1f174f0f1a3b86f030cdfb86be13a67.tar.bz2
scripts-e95f2f6ad1f174f0f1a3b86f030cdfb86be13a67.zip
improve curser save/restore to cope with window resizing
-rwxr-xr-xscripts/fancy_sleep.py4
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: