From 6d750fb74920066f3f2d49171f0bcfcf34f88aea Mon Sep 17 00:00:00 2001 From: q Date: Thu, 20 Jun 2024 15:06:36 +0300 Subject: [PATCH] new and improved --- bin/clockcurses | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/bin/clockcurses b/bin/clockcurses index 7e7be3c..a236540 100755 --- a/bin/clockcurses +++ b/bin/clockcurses @@ -143,17 +143,10 @@ def drawsplitstr(win, y, x, st): return -def drawdigital(win, y, x, t, ascii=False): - if options.seconds: - if t.tm_sec & 1: - hrs = list("%02d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec)) - else: - hrs = list("%02d %02d %02d" % (t.tm_hour, t.tm_min, t.tm_sec)) - else: - if t.tm_sec & 1: - hrs = list("%02d:%02d" % (t.tm_hour, t.tm_min)) - else: - hrs = list("%02d %02d" % (t.tm_hour, t.tm_min)) +def drawdigital(win, y, x, t, ascii=False, tick_tock=False): + c = ":" if tick_tock else " " + sec = "{:}{:02d}".format(c, t.tm_sec) if options.seconds else "" + hrs = list("{:02d}{:}{:02d}{:}".format(t.tm_hour, c, t.tm_min, sec)) for c in range(len(hrs)): drawdigit(win, y, x + 4 * c, hrs[c], ascii=ascii) @@ -283,10 +276,10 @@ def main(): for h in range(12): drawline(stdscr, cy, cx, math.pi * h / 6.0, r, 1 + r / 2, "◆", curses.color_pair(4)) if options.timer: - drawdigital(stdscr, 1, 1, timer_struct(t_h, t_m, t_s), options.ascii) - drawdigital(stdscr, 7, 1, t, options.ascii) + drawdigital(stdscr, 1, 1, timer_struct(t_h, t_m, t_s), options.ascii, tick_tock) + drawdigital(stdscr, 7, 1, t, options.ascii, tick_tock) else: - drawdigital(stdscr, 1, 1, t, options.ascii) + drawdigital(stdscr, 1, 1, t, options.ascii, tick_tock) is_alarm = drawalarms(stdscr, 1, 35, t, alarms, tick_tock) stdscr.refresh() userinput = readinput(stdscr, options.refresh)