diff --git a/man/remind.1 b/man/remind.1 index 5b52f36b..b80f4e1f 100644 --- a/man/remind.1 +++ b/man/remind.1 @@ -95,6 +95,14 @@ black-on-dark color or a white-on-light color is converted to grey so that the reminder is still visible. If \fIn\fR is not supplied, then \fBRemind\fR doesn't treat black or white specially and some reminders may be rendered invisible. +.PP +Some terminals (such as "xterm") understand additional escape sequences +that allow for specification of 256 different colors. If you supply +a value of 2, 3 or 4 for \fIn\fR, then \fBRemind\fR uses these enhanced +escape sequences to more closely approximate colors. A value of 2 +tells \fBRemind\fR that the terminal background is dark, 3 that it is +light, and 4 that \fBRemind\fR should not do anything special to +compensate for the background. .RE .TP .B \-w\fR\fIcol\fR[,\fIpad\fR[,\fIspc\fR]]] diff --git a/src/calendar.c b/src/calendar.c index 1073ff35..b3799d6c 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -1331,12 +1331,12 @@ static int DoCalRem(ParsePtr p, int col) } } if (trig.typ == PASSTHRU_TYPE) { - if (!PsCal && strcmp(trig.passthru, "COLOR") && strcmp(trig.passthru, "COLOUR")) { + if (!PsCal && StrCmpi(trig.passthru, "COLOR") && StrCmpi(trig.passthru, "COLOUR")) { FreeTrig(&trig); return OK; } - if (!strcmp(trig.passthru, "COLOR") || - !strcmp(trig.passthru, "COLOUR")) { + if (!StrCmpi(trig.passthru, "COLOR") || + !StrCmpi(trig.passthru, "COLOUR")) { is_color = 1; /* Strip off the three color numbers */ DBufFree(&buf); @@ -1398,8 +1398,8 @@ static int DoCalRem(ParsePtr p, int col) /* Suppress time if it's not today or if it's a non-COLOR special */ if (jul != JulianToday || (trig.typ == PASSTHRU_TYPE && - strcmp(trig.passthru, "COLOUR") && - strcmp(trig.passthru, "COLOR"))) { + StrCmpi(trig.passthru, "COLOUR") && + StrCmpi(trig.passthru, "COLOR"))) { if (DBufPuts(&obuf, SimpleTime(NO_TIME)) != OK) { DBufFree(&obuf); DBufFree(&raw_buf); @@ -1688,7 +1688,7 @@ static void WriteSimpleEntryProtocol2(CalEntry *e, int today) PrintJSONKeyPairInt("r", e->r); PrintJSONKeyPairInt("g", e->g); PrintJSONKeyPairInt("b", e->b); - } else if (!strcmp(e->passthru, "SHADE")) { + } else if (!StrCmpi(e->passthru, "SHADE")) { int r, g, b, n; n = sscanf(e->text, "%d %d %d", &r, &g, &b); if (n < 3) { diff --git a/src/dorem.c b/src/dorem.c index f09ccdcf..dfeda781 100644 --- a/src/dorem.c +++ b/src/dorem.c @@ -770,14 +770,14 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul) DBufInit(&calRow); DBufInit(&pre_buf); if (t->typ == RUN_TYPE && RunDisabled) return E_RUN_DISABLED; - if ((t->typ == PASSTHRU_TYPE && strcmp(t->passthru, "COLOR") && strcmp(t->passthru, "COLOUR")) || + if ((t->typ == PASSTHRU_TYPE && StrCmpi(t->passthru, "COLOR") && StrCmpi(t->passthru, "COLOUR")) || t->typ == CAL_TYPE || t->typ == PS_TYPE || t->typ == PSF_TYPE) return OK; /* Handle COLOR types */ - if (t->typ == PASSTHRU_TYPE && (!strcmp(t->passthru, "COLOR") || !strcmp(t->passthru, "COLOUR"))) { + if (t->typ == PASSTHRU_TYPE && (!StrCmpi(t->passthru, "COLOR") || !StrCmpi(t->passthru, "COLOUR"))) { /* Strip off three tokens */ r = ParseToken(p, &buf); sscanf(DBufValue(&buf), "%d", &red); diff --git a/src/rem2ps.c b/src/rem2ps.c index 7592f932..23bb0a75 100644 --- a/src/rem2ps.c +++ b/src/rem2ps.c @@ -139,6 +139,24 @@ void WriteOneEntry (CalEntry *c); void GetSmallLocations (void); char const *EatToken(char const *in, char *out, int maxlen); +/***************************************************************/ +/* */ +/* StrCmpi */ +/* */ +/* Compare strings, case insensitive. */ +/* */ +/***************************************************************/ +int StrCmpi(char const *s1, char const *s2) +{ + int r; + while (*s1 && *s2) { + r = toupper(*s1) - toupper(*s2); + if (r) return r; + s1++; + s2++; + } + return toupper(*s1) - toupper(*s2); +} /***************************************************************/ /* */ /* Parse the new-style JSON intermediate format */ @@ -196,18 +214,18 @@ JSONToCalEntry(DynamicBuffer *buf) } else if (!strcmp(nm, "passthru")) { if (v->type == json_string) { s = v->u.string.ptr; - if (!strcmp(s, "PostScript")) { + if (!StrCmpi(s, "PostScript")) { c->special = SPECIAL_POSTSCRIPT; - } else if (!strcmp(s, "SHADE")) { + } else if (!StrCmpi(s, "SHADE")) { c->special = SPECIAL_SHADE; - } else if (!strcmp(s, "MOON")) { + } else if (!StrCmpi(s, "MOON")) { c->special = SPECIAL_MOON; - } else if (!strcmp(s, "WEEK")) { + } else if (!StrCmpi(s, "WEEK")) { c->special = SPECIAL_WEEK; - } else if (!strcmp(s, "PSFile")) { + } else if (!StrCmpi(s, "PSFile")) { c->special = SPECIAL_PSFILE; - } else if (!strcmp(s, "COLOUR") || - !strcmp(s, "COLOR")) { + } else if (!StrCmpi(s, "COLOUR") || + !StrCmpi(s, "COLOR")) { c->special = SPECIAL_COLOR; } } @@ -266,18 +284,18 @@ TextToCalEntry(DynamicBuffer *buf) strcpy(c->entry, startOfBody); /* Save the type of SPECIAL */ - if (!strcmp(passthru, "PostScript")) { + if (!StrCmpi(passthru, "PostScript")) { c->special = SPECIAL_POSTSCRIPT; - } else if (!strcmp(passthru, "SHADE")) { + } else if (!StrCmpi(passthru, "SHADE")) { c->special = SPECIAL_SHADE; - } else if (!strcmp(passthru, "MOON")) { + } else if (!StrCmpi(passthru, "MOON")) { c->special = SPECIAL_MOON; - } else if (!strcmp(passthru, "WEEK")) { + } else if (!StrCmpi(passthru, "WEEK")) { c->special = SPECIAL_WEEK; - } else if (!strcmp(passthru, "PSFile")) { + } else if (!StrCmpi(passthru, "PSFile")) { c->special = SPECIAL_PSFILE; - } else if (!strcmp(passthru, "COLOUR") || - !strcmp(passthru, "COLOR")) { + } else if (!StrCmpi(passthru, "COLOUR") || + !StrCmpi(passthru, "COLOR")) { c->special = SPECIAL_COLOR; } return c;