From 0e709a08e2d80bb43dcfe57279f89e490d9fe219 Mon Sep 17 00:00:00 2001 From: Zvonimir Rudinski Date: Sun, 7 Jan 2024 12:16:42 +0100 Subject: [PATCH] add todo count in the bottom bar --- main.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index a5b5ab2..1d9647f 100644 --- a/main.c +++ b/main.c @@ -75,9 +75,26 @@ void draw_header(int width) { void draw_footer(int width, int height) { move(height - 1, 0); - for (int i = 0; i < width - 1; i++) { + addch(' '); + int todos_count = arrlen(todos); + int marked_count = 0; + + for (int i = 0; i < todos_count; i++) { + if (todos[i].completed) { + marked_count++; + } + } + + // get the length of the string + int length = snprintf(NULL, 0, "%d/%d", marked_count, todos_count); + // print the string + printw("%d/%d", marked_count, todos_count); + + // print the rest of the line + for (int i = length; i < width - 1; i++) { addch(' '); } + attroff(COLOR_PAIR(BORDERS_PAIR)); }