Implemented rendering of notes in todo view
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
1b40844aa3
commit
b144b19964
@ -1019,6 +1019,7 @@ void edit_note(char **, const char *);
|
|||||||
void view_note(const char *, const char *);
|
void view_note(const char *, const char *);
|
||||||
void erase_note(char **);
|
void erase_note(char **);
|
||||||
void note_read(char *, FILE *);
|
void note_read(char *, FILE *);
|
||||||
|
void note_read_contents(char *, size_t, FILE *);
|
||||||
void note_gc(void);
|
void note_gc(void);
|
||||||
|
|
||||||
/* notify.c */
|
/* notify.c */
|
||||||
|
11
src/note.c
11
src/note.c
@ -155,6 +155,17 @@ void note_read(char *buffer, FILE * fp)
|
|||||||
buffer[MAX_NOTESIZ] = '\0';
|
buffer[MAX_NOTESIZ] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read the contents of a note file */
|
||||||
|
void note_read_contents(char *buffer, size_t buffer_len, FILE * fp)
|
||||||
|
{
|
||||||
|
size_t read_count = fread(buffer, 1, buffer_len, fp);
|
||||||
|
if (read_count != buffer_len)
|
||||||
|
buffer[read_count] = '\0';
|
||||||
|
else
|
||||||
|
memcpy(&buffer[buffer_len - 4], "...\0", 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
note_gc_extract_key(struct note_gc_hash *data, const char **key, int *len)
|
note_gc_extract_key(struct note_gc_hash *data, const char **key, int *len)
|
||||||
{
|
{
|
||||||
|
@ -314,7 +314,27 @@ void ui_todo_popup_item(void)
|
|||||||
if (!item)
|
if (!item)
|
||||||
return;
|
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");
|
||||||
|
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)
|
void ui_todo_flag(void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user