diff options
Diffstat (limited to 'src/ui-todo.c')
-rw-r--r-- | src/ui-todo.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/src/ui-todo.c b/src/ui-todo.c index b546720..46933b3 100644 --- a/src/ui-todo.c +++ b/src/ui-todo.c @@ -1,7 +1,7 @@ /* * Calcurse - text-based organizer * - * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org> + * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -158,11 +158,11 @@ void ui_todo_pipe(void) return; wins_prepare_external(); - if ((pid = shell_exec(NULL, &pout, *arg, arg))) { + if ((pid = shell_exec(NULL, &pout, NULL, 0, *arg, arg))) { fpout = fdopen(pout, "w"); todo_write(item, fpout); fclose(fpout); - child_wait(NULL, &pout, pid); + child_wait(NULL, &pout, NULL, pid); press_any_key(); } wins_unprepare_external(); @@ -207,14 +207,16 @@ void ui_todo_draw(int n, WINDOW *win, int y, int hilt, void *cb_data) if (hilt) custom_apply_attr(win, ATTR_HIGHEST); - if (utf8_strwidth(todo->mesg) < width) { - mesg = todo->mesg; - } else { + mesg = todo->mesg; + if (mesg[0] == '\0') + mesg = EMPTY_EVENT_DESC_DEFAULT; + + if (utf8_strwidth(mesg) >= width) { width -= 3; - for (j = 0; todo->mesg[j] && width > 0; j++) { - if (!UTF8_ISCONT(todo->mesg[j])) - width -= utf8_width(&todo->mesg[j]); - buf[j] = todo->mesg[j]; + for (j = 0; mesg[j] && width > 0; j++) { + if (!UTF8_ISCONT(mesg[j])) + width -= utf8_width(&mesg[j]); + buf[j] = mesg[j]; } if (j) { buf[j - 1] = '.'; @@ -314,7 +316,32 @@ void ui_todo_popup_item(void) if (!item) return; - item_in_popup(NULL, NULL, item->mesg, _("TODO:")); + if (item->note) { + /* Assign a sane default note size that will cleanly + * truncate long notes */ + const char *note_heading = _("Note:"); + size_t note_size = 3500; + char note[note_size]; + char *notepath, *msg; + FILE *fp; + + asprintf(¬epath, "%s%s", path_notes, item->note); + fp = fopen(notepath, "r"); + if (fp == NULL) { + item_in_popup(NULL, NULL, item->mesg, _("TODO:")); + return; + } + + note_read_contents(note, note_size, fp); + fclose(fp); + mem_free(notepath); + + asprintf(&msg, "%s\n\n%s\n%s", item->mesg, note_heading, note); + item_in_popup(NULL, NULL, msg, _("TODO:")); + mem_free(msg); + } else { + item_in_popup(NULL, NULL, item->mesg, _("TODO:")); + } } void ui_todo_flag(void) |