[bugs] Re: [PATCH] Fix no-colour theme

In colour customization, pressing cancel ('ESC' by default) will
deselect all colours and put calcurse in no-color mode. For this
to work, all colour changes must be performed with the routines
custom_apply_attr()/custom_remove_attr(). Fixed for the getstring
cursor, the scroll window border and the week number.

In addition, the week number is unconditionally coloured as the
rest of the calendar contents whether CAL is selected or not.
---
I overlooked getstring() in the previous mail.

 src/getstring.c   |  4 ++--
 src/ui-calendar.c | 13 ++++---------
 src/wins.c        |  4 ++--
 3 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/getstring.c b/src/getstring.c
index 52b54a0..e511750 100644
--- a/src/getstring.c
+++ b/src/getstring.c
@@ -69,8 +69,8 @@ static void getstr_print(WINDOW * win, int x, int y,
 	mvwprintw(win, y, col - 2, " %c", c);
 
 	/* print cursor */
-	wmove(win, y, st->ci[st->pos].dpyoff - st->ci[st->scrpos].dpyoff);
-	wchgat(win, 1, A_REVERSE, COLR_CUSTOM, NULL);
+	mvwaddch(win, y, st->ci[st->pos].dpyoff - st->ci[st->scrpos].dpyoff,
+		SPACE | A_REVERSE);
 }
 
 /* Delete a character at the given position in string. */
diff --git a/src/ui-calendar.c b/src/ui-calendar.c
index 46b0e77..85dbbf2 100644
--- a/src/ui-calendar.c
+++ b/src/ui-calendar.c
@@ -67,7 +67,7 @@ void ui_calendar_view_next(void)
 		ui_calendar_view = 0;
 
 	/* The calendar panel needs to be erased when switching views. */
-	monthly_view_cache_month = 0;
+	werase(sw_cal.inner);
 }
 
 void ui_calendar_view_prev(void)
@@ -77,7 +77,7 @@ void ui_calendar_view_prev(void)
 	ui_calendar_view--;
 
 	/* The calendar panel needs to be erased when switching views. */
-	monthly_view_cache_month = 0;
+	werase(sw_cal.inner);
 }
 
 void ui_calendar_set_view(int view)
@@ -314,15 +314,10 @@ static void draw_week_number(struct scrollwin *sw, struct tm t)
 	int weeknum = ISO8601weeknum(&t);
 
 	WINS_CALENDAR_LOCK;
-	werase(sw_cal.inner);
-	custom_apply_attr(sw->inner, ATTR_HIGHEST);
-	if (wins_slctd() == CAL)
-		wattron(sw->win, COLOR_PAIR(COLR_CUSTOM));
+	custom_apply_attr(sw->win, ATTR_HIGHEST);
 	mvwprintw(sw->win, conf.compact_panels ? 0 : 2, sw->w - 9,
 		  "(# %02d)", weeknum);
-	if (wins_slctd() == CAL)
-		wattroff(sw->win, COLOR_PAIR(COLR_CUSTOM));
-	custom_remove_attr(sw->inner, ATTR_HIGHEST);
+	custom_remove_attr(sw->win, ATTR_HIGHEST);
 	WINS_CALENDAR_UNLOCK;
 }
 
diff --git a/src/wins.c b/src/wins.c
index 31864e9..e020851 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -337,7 +337,7 @@ void wins_scrollwin_delete(struct scrollwin *sw)
 void wins_scrollwin_draw_deco(struct scrollwin *sw, int hilt)
 {
 	if (hilt)
-		wattron(sw->win, A_BOLD | COLOR_PAIR(COLR_CUSTOM));
+		custom_apply_attr(sw->win, ATTR_HIGHEST);
 
 	box(sw->win, 0, 0);
 
@@ -348,7 +348,7 @@ void wins_scrollwin_draw_deco(struct scrollwin *sw, int hilt)
 	}
 
 	if (hilt)
-		wattroff(sw->win, A_BOLD | COLOR_PAIR(COLR_CUSTOM));
+		custom_remove_attr(sw->win, ATTR_HIGHEST);
 
 	if (!conf.compact_panels)
 		print_in_middle(sw->win, 1, 0, sw->w, sw->label);
-- 
2.14.2.666.gea220ee40

Links