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>
This commit is contained in:
parent
7b350ac58f
commit
ce6f8bf85b
25
src/day.c
25
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. */
|
/* Get the message of an item. */
|
||||||
char *day_item_get_mesg(struct day_item *day)
|
char *day_item_get_mesg(struct day_item *day)
|
||||||
{
|
{
|
||||||
char *message;
|
|
||||||
switch (day->type)
|
switch (day->type)
|
||||||
{
|
{
|
||||||
case APPT:
|
case APPT:
|
||||||
return day->item.apt->mesg;
|
return day->item.apt->mesg;
|
||||||
case EVNT:
|
case EVNT:
|
||||||
message = day->item.ev->mesg;
|
return day->item.ev->mesg;
|
||||||
if (*message == '\0')
|
|
||||||
return EMPTY_EVENT_DESC_DEFAULT;
|
|
||||||
return message;
|
|
||||||
case RECUR_APPT:
|
case RECUR_APPT:
|
||||||
return day->item.rapt->mesg;
|
return day->item.rapt->mesg;
|
||||||
case RECUR_EVNT:
|
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. */
|
/* Get the note attached to an item. */
|
||||||
char *day_item_get_note(struct day_item *day)
|
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)
|
if (width <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char *mesg = day_item_get_mesg(day);
|
char *mesg = day_item_get_display_mesg(day);
|
||||||
|
|
||||||
ch_recur = (day->type == RECUR_EVNT) ? '*' : ' ';
|
ch_recur = (day->type == RECUR_EVNT) ? '*' : ' ';
|
||||||
ch_note = day_item_get_note(day) ? '>' : ' ';
|
ch_note = day_item_get_note(day) ? '>' : ' ';
|
||||||
@ -633,11 +638,11 @@ void day_popup_item(struct day_item *day)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
mem_free(notepath);
|
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:"));
|
item_in_popup(NULL, NULL, msg, _("Event:"));
|
||||||
mem_free(msg);
|
mem_free(msg);
|
||||||
} else {
|
} 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) {
|
} else if (day->type == APPT || day->type == RECUR_APPT) {
|
||||||
char a_st[100], a_end[100];
|
char a_st[100], a_end[100];
|
||||||
@ -660,11 +665,11 @@ void day_popup_item(struct day_item *day)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
mem_free(notepath);
|
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:"));
|
item_in_popup(a_st, a_end, msg, _("Appointment:"));
|
||||||
mem_free(msg);
|
mem_free(msg);
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
EXIT(_("unknown item type"));
|
EXIT(_("unknown item type"));
|
||||||
|
@ -207,14 +207,16 @@ void ui_todo_draw(int n, WINDOW *win, int y, int hilt, void *cb_data)
|
|||||||
if (hilt)
|
if (hilt)
|
||||||
custom_apply_attr(win, ATTR_HIGHEST);
|
custom_apply_attr(win, ATTR_HIGHEST);
|
||||||
|
|
||||||
if (utf8_strwidth(todo->mesg) < width) {
|
mesg = todo->mesg;
|
||||||
mesg = todo->mesg;
|
if (mesg[0] == '\0')
|
||||||
} else {
|
mesg = EMPTY_EVENT_DESC_DEFAULT;
|
||||||
|
|
||||||
|
if (utf8_strwidth(mesg) >= width) {
|
||||||
width -= 3;
|
width -= 3;
|
||||||
for (j = 0; todo->mesg[j] && width > 0; j++) {
|
for (j = 0; mesg[j] && width > 0; j++) {
|
||||||
if (!UTF8_ISCONT(todo->mesg[j]))
|
if (!UTF8_ISCONT(mesg[j]))
|
||||||
width -= utf8_width(&todo->mesg[j]);
|
width -= utf8_width(&mesg[j]);
|
||||||
buf[j] = todo->mesg[j];
|
buf[j] = mesg[j];
|
||||||
}
|
}
|
||||||
if (j) {
|
if (j) {
|
||||||
buf[j - 1] = '.';
|
buf[j - 1] = '.';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user