aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2013-05-14 11:16:39 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2013-05-14 11:23:27 +0200
commit9e86e258f2a34a94e63665dd31571bbfb124d0f9 (patch)
treedb7d2c2ceeac1bb47c1031d2aca3b58d0e0ffbf4 /src
parentce93fa8adbeb31d160cba198e50e3f828e8def50 (diff)
downloadcalcurse-9e86e258f2a34a94e63665dd31571bbfb124d0f9.tar.gz
calcurse-9e86e258f2a34a94e63665dd31571bbfb124d0f9.zip
Refactor display_item_date()
Replace nested case differentiations by initializing every single character for each flag separately and joining all characters afterwards. This makes it much easier to extend the function later. Note that the same approach is already used in display_item(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r--src/day.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/day.c b/src/day.c
index 48a6f18..4691f01 100644
--- a/src/day.c
+++ b/src/day.c
@@ -401,6 +401,7 @@ display_item_date(struct day_item *day, int incolor, long date, int y,
{
WINDOW *win;
char a_st[100], a_end[100];
+ char ch_recur, ch_notify;
/* FIXME: Redesign apoint_sec2str() and remove the need for a temporary
* appointment item here. */
@@ -412,18 +413,11 @@ display_item_date(struct day_item *day, int incolor, long date, int y,
apoint_sec2str(&apt_tmp, date, a_st, a_end);
if (incolor == 0)
custom_apply_attr(win, ATTR_HIGHEST);
-
- if (day->type == RECUR_EVNT || day->type == RECUR_APPT) {
- if (day_item_get_state(day) & APOINT_NOTIFY)
- mvwprintw(win, y, x, " *!%s -> %s", a_st, a_end);
- else
- mvwprintw(win, y, x, " * %s -> %s", a_st, a_end);
- } else if (day_item_get_state(day) & APOINT_NOTIFY) {
- mvwprintw(win, y, x, " -!%s -> %s", a_st, a_end);
- } else {
- mvwprintw(win, y, x, " - %s -> %s", a_st, a_end);
- }
-
+ ch_recur = (day->type == RECUR_EVNT ||
+ day->type == RECUR_APPT) ? '*' : '-';
+ ch_notify = (day_item_get_state(day) & APOINT_NOTIFY) ? '!' : ' ';
+ mvwprintw(win, y, x, " %c%c%s -> %s", ch_recur, ch_notify,
+ a_st, a_end);
if (incolor == 0)
custom_remove_attr(win, ATTR_HIGHEST);
}