mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Add patch for $DefaultColor, courtesy of Tim Chase.
This commit is contained in:
@@ -1070,7 +1070,15 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
|
||||
int is_color, col_r, col_g, col_b;
|
||||
|
||||
is_color = 0;
|
||||
is_color = (
|
||||
DefaultColorR != -1
|
||||
&& DefaultColorG != -1
|
||||
&& DefaultColorB != -1);
|
||||
if (is_color) {
|
||||
col_r = DefaultColorR;
|
||||
col_g = DefaultColorG;
|
||||
col_b = DefaultColorB;
|
||||
}
|
||||
DBufInit(&buf);
|
||||
DBufInit(&pre_buf);
|
||||
DBufInit(&raw_buf);
|
||||
@@ -1152,6 +1160,19 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
strcpy(trig.passthru, "PSFile");
|
||||
trig.typ = PASSTHRU_TYPE;
|
||||
}
|
||||
|
||||
/* If it's a plain reminder but we have a default color, add the
|
||||
three colors to the prebuf and change passthru to "COLOR" */
|
||||
if (trig.typ == MSG_TYPE ||
|
||||
trig.typ == CAL_TYPE) {
|
||||
if (PsCal && is_color) {
|
||||
char cbuf[24];
|
||||
sprintf(cbuf, "%d %d %d ", col_r, col_g, col_b);
|
||||
DBufPuts(&pre_buf, cbuf);
|
||||
strcpy(trig.passthru, "COLOR");
|
||||
/* Don't change trig.typ or next if() will trigger! */
|
||||
}
|
||||
}
|
||||
if (trig.typ == PASSTHRU_TYPE) {
|
||||
if (!PsCal && strcmp(trig.passthru, "COLOR") && strcmp(trig.passthru, "COLOUR")) {
|
||||
FreeTrig(&trig);
|
||||
@@ -1358,7 +1379,7 @@ static int DoCalRem(ParsePtr p, int col)
|
||||
}
|
||||
e->lineno = LineNo;
|
||||
|
||||
if (trig.typ == PASSTHRU_TYPE) {
|
||||
if (trig.typ == PASSTHRU_TYPE || is_color) {
|
||||
StrnCpy(e->passthru, trig.passthru, PASSTHRU_LEN);
|
||||
} else {
|
||||
e->passthru[0] = 0;
|
||||
|
||||
@@ -73,6 +73,9 @@ EXTERN INIT( int Daemon, 0);
|
||||
EXTERN INIT( char DateSep, DATESEP);
|
||||
EXTERN INIT( char TimeSep, TIMESEP);
|
||||
EXTERN INIT( char DateTimeSep, DATETIMESEP);
|
||||
EXTERN INIT( int DefaultColorR, -1);
|
||||
EXTERN INIT( int DefaultColorB, -1);
|
||||
EXTERN INIT( int DefaultColorG, -1);
|
||||
EXTERN INIT( int SynthesizeTags, 0);
|
||||
EXTERN INIT( int ScFormat, SC_AMPM);
|
||||
EXTERN INIT( int MaxSatIter, 150);
|
||||
|
||||
35
src/var.c
35
src/var.c
@@ -168,6 +168,40 @@ static int datetime_sep_func(int do_set, Value *val)
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int default_color_func(int do_set, Value *val)
|
||||
{
|
||||
int col_r, col_g, col_b;
|
||||
if (!do_set) {
|
||||
/* 12 = strlen("255 255 255\0") */
|
||||
val->v.str = malloc(12);
|
||||
if (!val->v.str) return E_NO_MEM;
|
||||
snprintf(val->v.str, 12, "%d %d %d",
|
||||
DefaultColorR,
|
||||
DefaultColorB,
|
||||
DefaultColorG
|
||||
);
|
||||
val->type = STR_TYPE;
|
||||
return OK;
|
||||
}
|
||||
if (val->type != STR_TYPE) return E_BAD_TYPE;
|
||||
if (sscanf(val->v.str, "%d %d %d", &col_r, &col_g, &col_b) != 3) {
|
||||
return E_BAD_TYPE;
|
||||
}
|
||||
if (col_r != -1 || col_g != -1 || col_b != -1) {
|
||||
/* if any of them aren't -1, clamp them all as set */
|
||||
if (col_r < 0) col_r = 0;
|
||||
else if (col_r > 255) col_r = 255;
|
||||
if (col_g < 0) col_g = 0;
|
||||
else if (col_g > 255) col_g = 255;
|
||||
if (col_b < 0) col_b = 0;
|
||||
else if (col_b > 255) col_b = 255;
|
||||
}
|
||||
DefaultColorR = col_r;
|
||||
DefaultColorB = col_b;
|
||||
DefaultColorG = col_g;
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int date_sep_func(int do_set, Value *val)
|
||||
{
|
||||
if (!do_set) {
|
||||
@@ -608,6 +642,7 @@ static SysVar SysVarArr[] = {
|
||||
{"Daemon", 0, INT_TYPE, &Daemon, 0, 0 },
|
||||
{"DateSep", 1, SPECIAL_TYPE, date_sep_func, 0, 0 },
|
||||
{"DateTimeSep", 1, SPECIAL_TYPE, datetime_sep_func, 0, 0 },
|
||||
{"DefaultColor", 1, SPECIAL_TYPE, default_color_func, 0, 0 },
|
||||
{"DefaultPrio", 1, INT_TYPE, &DefaultPrio, 0, 9999},
|
||||
{"DeltaOffset", 0, INT_TYPE, &DeltaOffset, 0, 0 },
|
||||
{"DontFork", 0, INT_TYPE, &DontFork, 0, 0 },
|
||||
|
||||
Reference in New Issue
Block a user