summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriadna Vigo <arivigodr@gmail.com>2020-12-24 21:51:44 +0100
committerAriadna Vigo <arivigodr@gmail.com>2020-12-24 21:51:44 +0100
commitafc8e7967d41a51f34688f8005a415f793c8f163 (patch)
tree3a85b0e071e8a6645ca58dce0d39a9c76172959d
parente3aa7ec78941b2e2a300597179091d0934ea8be1 (diff)
Split up printing routines
-rw-r--r--cras.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/cras.c b/cras.c
index 6034e6e..533fdf0 100644
--- a/cras.c
+++ b/cras.c
@@ -36,6 +36,7 @@ enum {
static void die(const char *fmt, ...);
static void printf_color(const char *ansi_color, const char *fmt, ...);
static void print_task(Task task, int i);
+static void print_task_list(TaskLst list);
static void print_short_output(TaskLst list);
static void print_output(TaskLst list);
static void read_crasfile(TaskLst *list, const char *crasfile);
@@ -100,20 +101,10 @@ print_task(Task task, int i)
}
static void
-print_short_output(TaskLst list)
+print_task_list(TaskLst list)
{
- printf_color(task_todo_color, "%d", task_lst_count_todo(list));
- printf("/");
- printf_color(task_done_color, "%d", task_lst_count_done(list));
-}
-
-static void
-print_output(TaskLst list)
-{
- int i;
Task *ptr;
-
- printf("Due date: %s\n", ctime(&list.expiry));
+ int i;
for(i = 0, ptr = list.first; ptr != NULL; ptr = ptr->next) {
print_task(*ptr, i);
@@ -122,7 +113,21 @@ print_output(TaskLst list)
if (i > 0)
putchar('\n');
+}
+static void
+print_short_output(TaskLst list)
+{
+ printf_color(task_todo_color, "%d", task_lst_count_todo(list));
+ printf("/");
+ printf_color(task_done_color, "%d", task_lst_count_done(list));
+}
+
+static void
+print_output(TaskLst list)
+{
+ printf("Due date: %s\n", ctime(&list.expiry));
+ print_task_list(list);
print_short_output(list);
printf(" to do/done");
}