summaryrefslogtreecommitdiff
path: root/src/args.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-11-11 10:04:16 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2011-11-14 11:08:14 +0100
commit349bd3f88b094d3e17a84308f9ae4cf0a16d6727 (patch)
tree2e7a59eb27b432e1893126e7818b1ff0da58f620 /src/args.c
parentd32d811623ac130df58a5f02f168f48caa23ef9a (diff)
downloadcalcurse-349bd3f88b094d3e17a84308f9ae4cf0a16d6727.zip
Use a dynamic method to print todo items to stdout
This goes in line with the other commits adding print_*() support. Following format specifiers are allowed: * p: Print the priority of the item * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/args.c')
-rw-r--r--src/args.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/args.c b/src/args.c
index a944513..9ace459 100644
--- a/src/args.c
+++ b/src/args.c
@@ -246,7 +246,7 @@ todo_arg (int priority, int print_note, regex_t *regex)
{
llist_item_t *i;
int title = 1;
- char *titlestr, priority_str[BUFSIZ] = "";
+ char *titlestr;
char *all_todos_title = _("to do:\n");
char *completed_title = _("completed tasks:\n");
@@ -260,15 +260,6 @@ todo_arg (int priority, int print_note, regex_t *regex)
} \
} while (0)
-#define DISPLAY_TODO do { \
- (void)snprintf (priority_str, BUFSIZ, "%d. ", abs (todo->id)); \
- fputs (priority_str, stdout); \
- fputs (todo->mesg, stdout); \
- fputs ("\n", stdout); \
- if (print_note && todo->note) \
- print_notefile (stdout, todo->note, 1); \
- } while (0)
-
LLIST_FOREACH (&todolist, i)
{
struct todo *todo = LLIST_TS_GET_DATA (i);
@@ -280,7 +271,9 @@ todo_arg (int priority, int print_note, regex_t *regex)
if (priority == 0)
{
DISPLAY_TITLE;
- DISPLAY_TODO;
+ print_todo ("%p. %m\n", todo);
+ if (print_note && todo->note)
+ print_notefile (stdout, todo->note, 1);
}
}
else
@@ -288,13 +281,14 @@ todo_arg (int priority, int print_note, regex_t *regex)
if (priority < 0 || todo->id == priority)
{
DISPLAY_TITLE;
- DISPLAY_TODO;
+ print_todo ("%p. %m\n", todo);
+ if (print_note && todo->note)
+ print_notefile (stdout, todo->note, 1);
}
}
}
#undef DISPLAY_TITLE
-#undef DISPLAY_TODO
}
/* Print the next appointment within the upcoming 24 hours. */