diff options
author | Ambika Eshwar <cepheac@protonmail.ch> | 2020-10-06 02:32:59 -0400 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2020-10-11 09:59:37 -0400 |
commit | 5f47194b3b5fc16b3fbda04a8d31f0a1c0713330 (patch) | |
tree | 0da876571944139c9d37048ed0bfc30def5678f8 | |
parent | b144b19964fcd5cfb99526641751823dea9bee9d (diff) | |
download | calcurse-5f47194b3b5fc16b3fbda04a8d31f0a1c0713330.tar.gz calcurse-5f47194b3b5fc16b3fbda04a8d31f0a1c0713330.zip |
Implemented rendering of notes in events/appts as well
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r-- | src/day.c | 42 |
1 files changed, 38 insertions, 4 deletions
@@ -581,9 +581,27 @@ void day_write_stdout(time_t date, const char *fmt_apt, const char *fmt_rapt, /* Display an item inside a popup window. */ void day_popup_item(struct day_item *day) { + const char *note_heading = _("Note:"); + size_t note_size = 3500; + if (day->type == EVNT || day->type == RECUR_EVNT) { - item_in_popup(NULL, NULL, day_item_get_mesg(day), - _("Event:")); + if (day_item_get_note(day)) { + char note[note_size]; + char *notepath, *msg; + FILE *fp; + + asprintf(¬epath, "%s%s", path_notes, day_item_get_note(day)); + fp = fopen(notepath, "r"); + note_read_contents(note, note_size, fp); + fclose(fp); + mem_free(notepath); + + asprintf(&msg, "%s\n\n%s\n%s", day_item_get_mesg(day), note_heading, note); + item_in_popup(NULL, NULL, msg, _("Event:")); + mem_free(msg); + } else { + item_in_popup(NULL, NULL, day_item_get_mesg(day), _("Event:")); + } } else if (day->type == APPT || day->type == RECUR_APPT) { char a_st[100], a_end[100]; @@ -593,8 +611,24 @@ void day_popup_item(struct day_item *day) apt_tmp.start = day->start; apt_tmp.dur = day_item_get_duration(day); apoint_sec2str(&apt_tmp, ui_day_sel_date(), a_st, a_end); - item_in_popup(a_st, a_end, day_item_get_mesg(day), - _("Appointment:")); + + if (day_item_get_note(day)) { + char note[note_size]; + char *notepath, *msg; + FILE *fp; + + asprintf(¬epath, "%s%s", path_notes, day_item_get_note(day)); + fp = fopen(notepath, "r"); + note_read_contents(note, note_size, fp); + fclose(fp); + mem_free(notepath); + + asprintf(&msg, "%s\n\n%s\n%s", day_item_get_mesg(day), note_heading, note); + item_in_popup(a_st, a_end, msg, _("Appointment:")); + mem_free(msg); + } else { + item_in_popup(a_st, a_end, day_item_get_mesg(day), _("Appointment:")); + } } else { EXIT(_("unknown item type")); /* NOTREACHED */ |