Implemented rendering of notes in events/appts as well
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
b144b19964
commit
5f47194b3b
42
src/day.c
42
src/day.c
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user