Implemented rendering of notes in events/appts as well

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Ambika Eshwar 2020-10-06 02:32:59 -04:00 committed by Lukas Fleischer
parent b144b19964
commit 5f47194b3b

View File

@ -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. */ /* Display an item inside a popup window. */
void day_popup_item(struct day_item *day) 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) { if (day->type == EVNT || day->type == RECUR_EVNT) {
item_in_popup(NULL, NULL, day_item_get_mesg(day), if (day_item_get_note(day)) {
_("Event:")); char note[note_size];
char *notepath, *msg;
FILE *fp;
asprintf(&notepath, "%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) { } else if (day->type == APPT || day->type == RECUR_APPT) {
char a_st[100], a_end[100]; 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.start = day->start;
apt_tmp.dur = day_item_get_duration(day); apt_tmp.dur = day_item_get_duration(day);
apoint_sec2str(&apt_tmp, ui_day_sel_date(), a_st, a_end); 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(&notepath, "%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 { } else {
EXIT(_("unknown item type")); EXIT(_("unknown item type"));
/* NOTREACHED */ /* NOTREACHED */