aboutsummaryrefslogtreecommitdiffstats
path: root/src/day.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-06-25 13:34:28 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-06-30 14:34:34 +0200
commit3763aa1ebff3cf60e20e083d28af7000e8646b5b (patch)
tree7aa1910305de4b60a95e70827b1aa641a938a224 /src/day.c
parent244b6c927db34cea9cc83486510af60fd6ae7926 (diff)
downloadcalcurse-3763aa1ebff3cf60e20e083d28af7000e8646b5b.tar.gz
calcurse-3763aa1ebff3cf60e20e083d28af7000e8646b5b.zip
src/day.c: Add day_write_stdout()
This function allows for writing stored items to stdout in a fashion similar to day_write_pad(). This will be used as a convenience wrapper when switching to day_store_items() in non-interactive mode and also allows for easily implementing a "pipe-day" feature. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/day.c')
-rw-r--r--src/day.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/day.c b/src/day.c
index d4badae..fb3a9e7 100644
--- a/src/day.c
+++ b/src/day.c
@@ -455,6 +455,35 @@ void day_write_pad(long date, int width, int length, int incolor)
}
}
+/* Write the appointments and events for the selected day to stdout. */
+void day_write_stdout(long date, const char *fmt_apt, const char *fmt_rapt,
+ const char *fmt_ev, const char *fmt_rev)
+{
+ llist_item_t *i;
+
+ LLIST_FOREACH(&day_items, i) {
+ struct day_item *day = LLIST_TS_GET_DATA(i);
+
+ switch (day->type) {
+ case APPT:
+ print_apoint(fmt_apt, date, day->item.apt);
+ break;
+ case EVNT:
+ print_event(fmt_ev, date, day->item.ev);
+ break;
+ case RECUR_APPT:
+ print_recur_apoint(fmt_rapt, date, day->start, day->item.rapt);
+ break;
+ case RECUR_EVNT:
+ print_recur_event(fmt_rev, date, day->item.rev);
+ break;
+ default:
+ EXIT(_("unknown item type"));
+ /* NOTREACHED */
+ }
+ }
+}
+
/* Display an item inside a popup window. */
void day_popup_item(void)
{