aboutsummaryrefslogtreecommitdiffstats
path: root/src/todo.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-07-07 18:23:30 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-07-21 18:13:40 +0200
commit87664095cdd2c85d50e1be42442c0c24b611c7dc (patch)
tree48146b5854874fd8c699ab3348b4151905e09760 /src/todo.c
parent40772daaf4d241a71f6eba5190cf8cd03d028880 (diff)
downloadcalcurse-87664095cdd2c85d50e1be42442c0c24b611c7dc.tar.gz
calcurse-87664095cdd2c85d50e1be42442c0c24b611c7dc.zip
Refactor out note functions
* Add new note_edit() and note_view() helper functions. Use these instead of copy-pasted code in *_note_edit(). * Move all note-related functions (note_edit(), note_view(), note_erase()) to a new source file "note.c". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/todo.c')
-rw-r--r--src/todo.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/src/todo.c b/src/todo.c
index c11a676..c489f51 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -471,37 +471,16 @@ todo_update_panel (int which_pan)
void
todo_edit_note (char *editor)
{
- struct todo *i;
- char fullname[BUFSIZ];
- char *filename;
-
- i = todo_get_item (hilt);
- if (i->note == NULL)
- {
- if ((filename = new_tempfile (path_notes, NOTESIZ)) != NULL)
- i->note = filename;
- else
- return;
- }
- (void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, i->note);
- wins_launch_external (fullname, editor);
-
- if (io_file_is_empty (fullname) > 0)
- erase_note (&i->note, ERASE_FORCE);
+ struct todo *i = todo_get_item (hilt);
+ edit_note (&i->note, editor);
}
/* View a note previously attached to a todo */
void
todo_view_note (char *pager)
{
- struct todo *i;
- char fullname[BUFSIZ];
-
- i = todo_get_item (hilt);
- if (i->note == NULL)
- return;
- (void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, i->note);
- wins_launch_external (fullname, pager);
+ struct todo *i = todo_get_item (hilt);
+ view_note (i->note, pager);
}
/* Pipe a todo item to an external program. */