summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriadna Vigo <arivigodr@gmail.com>2020-12-10 17:32:46 +0100
committerAriadna Vigo <arivigodr@gmail.com>2020-12-10 17:32:46 +0100
commit23e7d86accde787066fdc0551f4f8156eefb94c2 (patch)
treec61fbabaa451734c6e0a9e729c63ae586182d190
parent9467174c1170f283486a4db8f9d3c725f05d6e8b (diff)
The status indicator works no longer flashes
-rw-r--r--config.def.h7
-rw-r--r--minitimer.c12
2 files changed, 7 insertions, 12 deletions
diff --git a/config.def.h b/config.def.h
index b90153a..e36700e 100644
--- a/config.def.h
+++ b/config.def.h
@@ -14,11 +14,10 @@ static const char fifobase[] = "/tmp/minitimer.";
static const char outputfmt[] = "%02d:%02d:%02d";
/*
- * indic_char1, indic_char2: These characters will alternate with each other
- * every second in a flashing effect when the timer is running.
+ * status_ind: This character is printed before the timer when running (also
+ * when running in the background when showing a lap).
*/
-static const char indic_char1 = '*';
-static const char indic_char2 = ' ';
+static const char status_ind = '*';
/*
* time_incr_secs: Increment the timer by how many seconds when pressing '+'.
diff --git a/minitimer.c b/minitimer.c
index 189ead9..8627f76 100644
--- a/minitimer.c
+++ b/minitimer.c
@@ -39,7 +39,7 @@ static void time_inc(struct time *the_time, int secs);
static int parse_time(char *time_str, struct time *the_time);
static struct termios ui_setup(struct termios *old);
-static void ui_update(const struct time *the_time);
+static void ui_update(const struct time *the_time, int status);
static int poll_event(int fifofd);
static void
@@ -160,21 +160,18 @@ ui_setup(struct termios *old)
}
static void
-ui_update(const struct time *the_time)
+ui_update(const struct time *the_time, int status)
{
static struct time output;
- static int indic = 0;
if (the_time != NULL)
output = *the_time;
printf("\r");
+ putchar((status > 0) ? status_ind : ' ');
printf(outputfmt, output.hrs, output.mins, output.secs);
- printf(" %c", (indic > 0) ? indic_char1 : indic_char2);
fflush(stdout);
-
- indic ^= 1;
}
static int
@@ -280,9 +277,8 @@ main(int argc, char *argv[])
goto exit;
}
+ ui_update((ui_active > 0) ? &the_time : NULL, timer_runs);
if (timer_runs > 0) {
- ui_update((ui_active > 0) ? &the_time : NULL);
-
time_inc(&the_time, delta);
sleep(1);
}