summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/calcurse.h1
-rw-r--r--src/day.c55
2 files changed, 56 insertions, 0 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index 45c01e5..f753d97 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -637,6 +637,7 @@ struct day_item *day_get_item (int);
int day_item_nb (long, int, int);
void day_edit_note (char *);
void day_view_note (char *);
+void day_pipe_item (struct conf *);
/* dmon.c */
void dmon_start (int);
diff --git a/src/day.c b/src/day.c
index 7ad0b27..ffbe567 100644
--- a/src/day.c
+++ b/src/day.c
@@ -1098,3 +1098,58 @@ day_view_note (char *pager)
(void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, p->note);
wins_launch_external (fullname, pager);
}
+
+/* Pipe an appointment or event to an external program. */
+void
+day_pipe_item (struct conf *conf)
+{
+ char cmd[BUFSIZ] = "";
+ int pout;
+ int pid;
+ FILE *fpout;
+ int item_num;
+ long date;
+ struct day_item *p;
+ struct recur_apoint *ra;
+ struct apoint *a;
+ struct recur_event *re;
+ struct event *e;
+
+ status_mesg (_("Pipe item to external command:"), "");
+ if (getstring (win[STA].p, cmd, BUFSIZ, 0, 1) != GETSTRING_VALID)
+ return;
+
+ wins_prepare_external ();
+ if ((pid = shell_exec (NULL, &pout, cmd)))
+ {
+ fpout = fdopen (pout, "w");
+
+ item_num = apoint_hilt ();
+ p = day_get_item (item_num);
+ date = calendar_get_slctd_day_sec ();
+ switch (p->type)
+ {
+ case RECUR_EVNT:
+ re = recur_get_event (date, day_item_nb (date, item_num, RECUR_EVNT));
+ recur_event_write (re, fpout);
+ break;
+ case EVNT:
+ e = event_get (date, day_item_nb (date, item_num, EVNT));
+ event_write (e, fpout);
+ break;
+ case RECUR_APPT:
+ ra = recur_get_apoint (date, day_item_nb (date, item_num, RECUR_APPT));
+ recur_apoint_write (ra, fpout);
+ break;
+ case APPT:
+ a = apoint_get (date, day_item_nb (date, item_num, APPT));
+ apoint_write (a, fpout);
+ break;
+ }
+
+ fclose (fpout);
+ child_wait (NULL, &pout, pid);
+ press_any_key ();
+ }
+ wins_unprepare_external ();
+}