diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-11-09 18:29:22 +0100 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-11-14 11:08:14 +0100 |
commit | 330ca4d3cbd702f4f0e7689a1da4f77945f768e0 (patch) | |
tree | 233a65e28b80e86ee11039814793e534a3bedc84 /src/args.c | |
parent | edad2f39db6d7ad4bcb41d04298b87c0de26fe1a (diff) | |
download | calcurse-330ca4d3cbd702f4f0e7689a1da4f77945f768e0.zip |
Use a dynamic method to print appointments to stdout
Add a flexible helper function print_apoint() and use it whenever we
print appointments to stdout. This reduces the number of copy-pasted
code and eventually allows for specifying custom format strings.
Following format specifiers are supported:
* s: Print the start time of the appointment as UNIX time stamp
* S: Print the start time of the appointment using the "hh:mm" format
* d: Print the duration of the appointment in seconds
* e: Print the end time of the appointment as UNIX time stamp
* E: Print the end time of the appointment using the "hh:mm" format
* 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.c | 20 |
1 files changed, 2 insertions, 18 deletions
@@ -357,8 +357,6 @@ app_arg (int add_line, struct date *day, long date, int print_note, long today; unsigned print_date = 1; int app_found = 0; - char apoint_start_time[HRMIN_SIZE]; - char apoint_end_time[HRMIN_SIZE]; if (date == 0) today = get_sec_date (*day); @@ -468,14 +466,7 @@ app_arg (int add_line, struct date *day, long date, int print_note, arg_print_date (today); print_date = 0; } - apoint_sec2str (apt, today, apoint_start_time, apoint_end_time); - fputs (" - ", stdout); - fputs (apoint_start_time, stdout); - fputs (" -> ", stdout); - fputs (apoint_end_time, stdout); - fputs ("\n\t", stdout); - fputs (apt->mesg, stdout); - fputs ("\n", stdout); + print_apoint (" - %S -> %E\n\t%m\n", today, apt); if (print_note && apt->note) print_notefile (stdout, apt->note, 2); i = LLIST_TS_FIND_NEXT (i, today, apoint_inday); @@ -494,16 +485,9 @@ app_arg (int add_line, struct date *day, long date, int print_note, print_date = 0; } apt = apoint_recur_s2apoint_s (ra); - apoint_sec2str (apt, today, apoint_start_time, apoint_end_time); + print_apoint (" - %S -> %E\n\t%m\n", today, apt); mem_free (apt->mesg); mem_free (apt); - fputs (" - ", stdout); - fputs (apoint_start_time, stdout); - fputs (" -> ", stdout); - fputs (apoint_end_time, stdout); - fputs ("\n\t", stdout); - fputs (ra->mesg, stdout); - fputs ("\n", stdout); if (print_note && ra->note) print_notefile (stdout, ra->note, 2); apt = NULL; |