From 9e8f3dec7c4332a1e316b485ae9a3132aed7c6d9 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 25 Mar 2021 18:26:07 +0100 Subject: stopwatch: add lap counter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- stopwatch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stopwatch.c b/stopwatch.c index 19aba4f..8d5b783 100644 --- a/stopwatch.c +++ b/stopwatch.c @@ -29,6 +29,7 @@ display_stopwatch(int timerfd) uintmax_t total_overrun = 0, h, m, s, d, first_overrun = 0; int paused = 0, have_first = 0; struct itimerspec old_time, zero_time; + size_t lap = 1; ssize_t r; char c; @@ -68,7 +69,8 @@ display_stopwatch(int timerfd) h = total_overrun / 10 / 60 / 60; if (quadsize) printf("\033#5"); - printf("%ju:%02ju:%02ju.%ju", h, m, s, d); + printf("Lap %2zu: %ju:%02ju:%02ju.%ju", lap, h, m, s, d); + lap++; if (!have_first) { have_first = 1; first_overrun = total_overrun; -- cgit v1.2.3-70-g09d2