summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-07-02 09:41:54 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-07-05 16:25:32 +0200
commit9e60084262e3e85900a42001ca11876e5c452d32 (patch)
treec2eaef81e9b3eae6d04d444eea806b0880bcdb7a
parentc3f532d814e555abf67efb136491956428f19965 (diff)
downloadcalcurse-9e60084262e3e85900a42001ca11876e5c452d32.tar.gz
calcurse-9e60084262e3e85900a42001ca11876e5c452d32.zip
Add todo_pipe_item() function
Pipe a serialized todo item to an external process, similar to what day_pipe_item() does (cf. c3f532d814e555abf67efb136491956428f19965). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--src/calcurse.h1
-rw-r--r--src/todo.c29
2 files changed, 30 insertions, 0 deletions
diff --git a/src/calcurse.h b/src/calcurse.h
index f753d97..95382e9 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -838,6 +838,7 @@ void todo_edit_item (void);
void todo_update_panel (int);
void todo_edit_note (char *);
void todo_view_note (char *);
+void todo_pipe_item (void);
void todo_init_list (void);
void todo_free_list (void);
diff --git a/src/todo.c b/src/todo.c
index 935109f..c11a676 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -504,6 +504,35 @@ todo_view_note (char *pager)
wins_launch_external (fullname, pager);
}
+/* Pipe a todo item to an external program. */
+void
+todo_pipe_item (void)
+{
+ char cmd[BUFSIZ] = "";
+ int pout;
+ int pid;
+ FILE *fpout;
+ struct todo *todo;
+
+ 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");
+
+ todo = todo_get_item (hilt);
+ todo_write (todo, fpout);
+
+ fclose (fpout);
+ child_wait (NULL, &pout, pid);
+ press_any_key ();
+ }
+ wins_unprepare_external ();
+}
+
void
todo_free (struct todo *todo)
{