aboutsummaryrefslogtreecommitdiffstats
path: root/src/day.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/day.c')
-rw-r--r--src/day.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/day.c b/src/day.c
index 7eb6693..78f4acf 100644
--- a/src/day.c
+++ b/src/day.c
@@ -1,7 +1,7 @@
/*
* Calcurse - text-based organizer
*
- * Copyright (c) 2004-2022 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
@@ -198,7 +198,8 @@ static void day_add_item(int type, time_t start, time_t order, union aptev_ptr i
/* Get the message of an item. */
char *day_item_get_mesg(struct day_item *day)
{
- switch (day->type) {
+ switch (day->type)
+ {
case APPT:
return day->item.apt->mesg;
case EVNT:
@@ -212,6 +213,15 @@ char *day_item_get_mesg(struct day_item *day)
}
}
+/* Get the display message of an item. */
+char *day_item_get_display_mesg(struct day_item *day)
+{
+ char *msg = day_item_get_mesg(day);
+ if (msg[0] == '\0')
+ return EMPTY_EVENT_DESC_DEFAULT;
+ return msg;
+}
+
/* Get the note attached to an item. */
char *day_item_get_note(struct day_item *day)
{
@@ -529,7 +539,7 @@ day_display_item(struct day_item *day, WINDOW *win, int incolor, int width,
if (width <= 0)
return;
- char *mesg = day_item_get_mesg(day);
+ char *mesg = day_item_get_display_mesg(day);
ch_recur = (day->type == RECUR_EVNT) ? '*' : ' ';
ch_note = day_item_get_note(day) ? '>' : ' ';
@@ -624,15 +634,19 @@ void day_popup_item(struct day_item *day)
asprintf(&notepath, "%s%s", path_notes, day_item_get_note(day));
fp = fopen(notepath, "r");
+ if (fp == NULL) {
+ item_in_popup(NULL, NULL, day_item_get_mesg(day), _("Event:"));
+ return;
+ }
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);
+ asprintf(&msg, "%s\n\n%s\n%s", day_item_get_display_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:"));
+ item_in_popup(NULL, NULL, day_item_get_display_mesg(day), _("Event:"));
}
} else if (day->type == APPT || day->type == RECUR_APPT) {
char a_st[100], a_end[100];
@@ -651,15 +665,19 @@ void day_popup_item(struct day_item *day)
asprintf(&notepath, "%s%s", path_notes, day_item_get_note(day));
fp = fopen(notepath, "r");
+ if (fp == NULL) {
+ item_in_popup(a_st, a_end, day_item_get_mesg(day), _("Appointment:"));
+ return;
+ }
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);
+ asprintf(&msg, "%s\n\n%s\n%s", day_item_get_display_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:"));
+ item_in_popup(a_st, a_end, day_item_get_display_mesg(day), _("Appointment:"));
}
} else {
EXIT(_("unknown item type"));