Allow the color special to be spelled COLOR or COLOUR.

This commit is contained in:
David F. Skoll
2011-12-05 16:42:57 -05:00
parent 450e88fad8
commit fcb55001bb
9 changed files with 19 additions and 11 deletions

View File

@@ -112,7 +112,7 @@
"WARN" "UNTIL" "THROUGH" "SCANFROM" "DURATION" "TAG" "MSG" "MSF" "CAL" "SPECIAL" "IFTRIG"
"PS" "PSFILE" "BANNER" "INCLUDE" "PUSH-OMIT-CONTEXT" "DEBUG" "DUMPVARS"
"CLEAR-OMIT-CONTEXT" "POP-OMIT-CONTEXT" "SET" "ERRMSG" "FSET"
"EXIT" "FLUSH" "PRESERVE" "MOON" "COLOR")
"EXIT" "FLUSH" "PRESERVE" "MOON" "COLOR" "COLOUR")
#'(lambda (a b) (> (length a) (length b)))))
(defconst remind-type-keywords

View File

@@ -23,7 +23,7 @@ syn keyword remindExpiry UNTIL FROM SCANFROM SCAN WARN SCHED THROUGH
syn keyword remindTag PRIORITY TAG
syn keyword remindTimed AT DURATION
syn keyword remindMove ONCE SKIP BEFORE AFTER
syn keyword remindSpecial INCLUDE INC BANNER PUSH-OMIT-CONTEXT PUSH CLEAR-OMIT-CONTEXT CLEAR POP-OMIT-CONTEXT POP COLOR
syn keyword remindSpecial INCLUDE INC BANNER PUSH-OMIT-CONTEXT PUSH CLEAR-OMIT-CONTEXT CLEAR POP-OMIT-CONTEXT POP COLOR COLOUR
syn keyword remindRun MSG MSF RUN CAL SATISFY SPECIAL PS PSFILE SHADE MOON
syn keyword remindConditional IF ELSE ENDIF IFTRIG
syn keyword remindDebug DEBUG DUMPVARS DUMP ERRMSG FLUSH PRESERVE

View File

@@ -4167,6 +4167,9 @@ calendar. Use it like this:
REM ... SPECIAL COLOR 0 128 0 This is a dark green reminder
.fi
You can spell COLOR either the American way ("COLOR") or the British
way ("COLOUR"). This manual will use the American way.
Immediately following COLOR should be three decimal numbers ranging
from 0 to 255 specifying red, green and blue intensities, respectively.
The rest of the line is the text to put in the calendar.

View File

@@ -796,6 +796,7 @@ proc FillCalWindow {} {
DoMoonSpecial $n $stuff
continue
}
"COLOUR" -
"COLOR" {
if {[regexp {^ *([0-9]+) +([0-9]+) +([0-9]+) +(.*)$} $stuff all r g b rest]} {
if {$r > 255} {
@@ -822,7 +823,7 @@ proc FillCalWindow {} {
}
}
}
if { $type != "*" && $type != "COLOR"} {
if { $type != "*" && $type != "COLOR" && $type != "COLOUR"} {
continue
}
.cal.t$n configure -state normal

View File

@@ -1016,11 +1016,12 @@ static int DoCalRem(ParsePtr p, int col)
trig.typ = PASSTHRU_TYPE;
}
if (trig.typ == PASSTHRU_TYPE) {
if (!PsCal && strcmp(trig.passthru, "COLOR")) {
if (!PsCal && strcmp(trig.passthru, "COLOR") && strcmp(trig.passthru, "COLOUR")) {
FreeTrig(&trig);
return OK;
}
if (!strcmp(trig.passthru, "COLOR")) {
if (!strcmp(trig.passthru, "COLOR") ||
!strcmp(trig.passthru, "COLOUR")) {
is_color = 1;
/* Strip off the three color numbers */
DBufFree(&buf);
@@ -1073,6 +1074,7 @@ 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"))) {
if (DBufPuts(&obuf, SimpleTime(NO_TIME)) != OK) {
DBufFree(&obuf);

View File

@@ -708,14 +708,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")) ||
if ((t->typ == PASSTHRU_TYPE && strcmp(t->passthru, "COLOR") && strcmp(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")) {
if (t->typ == PASSTHRU_TYPE && (!strcmp(t->passthru, "COLOR") || !strcmp(t->passthru, "COLOUR")) {
/* Strip off three tokens */
r = ParseToken(p, &buf);
if (!NextMode) {

View File

@@ -366,6 +366,7 @@ void DoPsCal(void)
}
}
} else if (!strcmp(passthru, "*") ||
!strcmp(passthru, "COLOUR") ||
!strcmp(passthru, "COLOR")) {
/* Put on linked list */
if (!CurEntries) {
@@ -375,7 +376,8 @@ void DoPsCal(void)
while(d->next) d = d->next;
d->next = c;
}
if (!strcmp(passthru, "COLOR")) {
if (!strcmp(passthru, "COLOR") ||
!strcmp(passthru, "COLOUR")) {
c->special = SPECIAL_COLOR;
}
}

View File

@@ -58,7 +58,7 @@ class Remind
if ($special === null || $special == '*') {
return $this->munge_entry($day, $results, $specials, $options, $body, $e);
}
if ($special == 'COLOR') {
if ($special == 'COLOR' || $special == 'COLOUR') {
if (preg_match('/^(\d+)\s+(\d+)\s+(\d+)\s+(.*)/', $body, $matches)) {
return sprintf('<span style="color: #%02x%02x%02x">%s</span>',
$matches[1] % 255,
@@ -293,7 +293,7 @@ class Remind
$entry['file'] = $lineinfo['file'];
$lineinfo = 0;
}
if ($special != '*' && $special != 'COLOR' && $special != 'HTML') {
if ($special != '*' && $special != 'COLOR' && $special != 'COLOUR' && $special != 'HTML') {
if (!array_key_exists($special, $specials)) {
$specials[$special] = array();
}

View File

@@ -257,7 +257,7 @@ sub parse_input
$shades->[$d] = sprintf("#%02X%02X%02X",
($1 % 256), ($2 % 256), ($3 % 256));
}
} elsif ($special eq 'COLOR') {
} elsif ($special eq 'COLOR' || $special eq 'COLOUR') {
if ($body =~ /(\d+)\s+(\d+)\s+(\d+)\s+(.*)$/) {
my($r, $g, $b, $text) = ($1, $2, $3, $4);
my $color = sprintf("style=\"color: #%02X%02X%02X;\"",