From e95f2f6ad1f174f0f1a3b86f030cdfb86be13a67 Mon Sep 17 00:00:00 2001 From: vg Date: Thu, 11 Apr 2024 11:51:23 +0200 Subject: improve curser save/restore to cope with window resizing --- scripts/fancy_sleep.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') 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: -- cgit v1.2.3