From f90d8b8bccc8f410dd6dc36a028889ea3169b26b Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 4 Feb 2019 14:16:11 +0100 Subject: [PATCH] cal: use standout mode on monochrome terminals The function colors_init() checks for colors, it means it fails on monochrome terminals, but cal(1) in this case still need to highlight the current day. Reported-by: Nuno Silva Signed-off-by: Karel Zak --- misc-utils/cal.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 4dff491fb6..bd643f3b49 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -550,9 +550,21 @@ int main(int argc, char **argv) headers_init(&ctl); - if (!colors_init(ctl.colormode, "cal")) { - ctl.req.day = 0; - ctl.weektype &= ~WEEK_NUM_MASK; + if (colors_init(ctl.colormode, "cal") == 0) { + /* + * If standout mode available (Senter and Sexit are set) and + * user or terminal-colors.d do not disable colors than + * ignore colors_init(). + */ + if (*Senter && *Sexit && colors_mode() != UL_COLORMODE_NEVER) { + /* let use standout mode */ + ; + } else { + /* disable */ + Senter = Sexit = '\0'; + ctl.req.day = 0; + ctl.weektype &= ~WEEK_NUM_MASK; + } } if (yflag || Yflag) { -- 2.47.3