aboutsummaryrefslogtreecommitdiffstats
path: root/src/day.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2022-12-25 16:30:21 -0500
committerLukas Fleischer <lfleischer@calcurse.org>2022-12-25 16:36:27 -0500
commitce6f8bf85b54640b467c59318b7506e4db18bd83 (patch)
tree5372002ac1e91f2b511e1c8be3a08dcbb1e9c4ac /src/day.c
parent7b350ac58f34c81d01f5cd6b0b36f6ec5c93c68e (diff)
downloadcalcurse-ce6f8bf85b54640b467c59318b7506e4db18bd83.tar.gz
calcurse-ce6f8bf85b54640b467c59318b7506e4db18bd83.zip
Extend default description to all item types
Show default description "(empty description)" for all types of items (appointments, events, recurring appointments/events, TODOs). Follow-up to 7b350ac (Add text for displaying empty event description, 2022-06-21). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/day.c')
-rw-r--r--src/day.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/day.c b/src/day.c
index a6f338b..a86a91d 100644
--- a/src/day.c
+++ b/src/day.c
@@ -198,16 +198,12 @@ 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)
{
- char *message;
switch (day->type)
{
case APPT:
return day->item.apt->mesg;
case EVNT:
- message = day->item.ev->mesg;
- if (*message == '\0')
- return EMPTY_EVENT_DESC_DEFAULT;
- return message;
+ return day->item.ev->mesg;
case RECUR_APPT:
return day->item.rapt->mesg;
case RECUR_EVNT:
@@ -217,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)
{
@@ -534,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) ? '>' : ' ';
@@ -633,11 +638,11 @@ void day_popup_item(struct day_item *day)
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];
@@ -660,11 +665,11 @@ void day_popup_item(struct day_item *day)
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"));