Add the $AddBlankLines system variable.

This commit is contained in:
Dianne Skoll
2022-10-10 22:49:28 -04:00
parent f9d968cf68
commit 07fd975935
8 changed files with 64 additions and 9 deletions

View File

@@ -1526,7 +1526,8 @@ Notes:
o
.B Remind
normally prints a blank line after each reminder; if the last character
of the body is "%", the blank line will not be printed.
of the body is "%", the blank line will not be printed. You can globally
suppress the extra blank lines by setting \fB$AddBlankLines\fR to 0.
.TP
o
Substitutions a, b, c, e, f, g, h, i, j, k, l, u and v all are replaced
@@ -2275,6 +2276,13 @@ The following system variables are defined. Those marked
All system variables hold values of type \fBINT\fR, unless otherwise
specified.
.TP
.B $AddBlankLines
If set to 1 (the default), then \fBRemind\fR normally prints a blank
line after the banner and each reminder. (This can be suppressed by
ending the reminder or banner with a single percent sign.) If
$AddBlankLines is set to 0, then Remind does not print the blank line.
In this case, ending a reminder with % has no effect.
.TP
.B $CalcUTC
If 1 (the default), then \fBRemind\fR uses C library functions
to calculate the number of minutes between local and Universal Time
@@ -3753,7 +3761,7 @@ defined, and the value of XY if it is defined.
.TP
.B version()
Returns a string specifying the version of \fBRemind\fR. For version
03.00.04, returns "03.00.04". It is guaranteed that as new versions of
@VERSION@, returns "@VERSION@". It is guaranteed that as new versions of
\fBRemind\fR are released, the value returned by \fBversion()\fR will
strictly increase, according to the rules for string ordering.
.TP
@@ -4086,13 +4094,13 @@ Notes:
.TP
o
If you access a variable in \fIexpr\fR that is not in the list of arguments,
the "global" value (if any) is used.
the global value (if any) is used.
.TP
o
Function and parameter names are significant only to 12 characters.
Function and parameter names are significant to 64 characters.
.TP
o
The \fBvalue()\fR function \fIalways\fR accesses the "global" value of a
The \fBvalue()\fR function \fIalways\fR accesses the global value of a
variable, even if it has the same name as an argument. For example:
.RS
.PP

View File

@@ -945,8 +945,8 @@ int TriggerReminder(ParsePtr p, Trigger *t, TimeTrig *tim, int jul)
if (!DoSubstFromString(DBufValue(&Banner), &buf,
JulianToday, NO_TIME) &&
DBufLen(&buf)) {
printf("%s\n", DBufValue(&buf));
}
printf("%s\n", DBufValue(&buf));
}
DBufFree(&buf);
}

View File

@@ -190,8 +190,11 @@ int DoSubst(ParsePtr p, DynamicBuffer *dbuf, Trigger *t, TimeTrig *tt, int jul,
}
if (c == '\n') continue;
if (!c) {
if (mode != CAL_MODE && mode != ADVANCE_MODE &&
t->typ != RUN_TYPE && !MsgCommand) {
if (AddBlankLines &&
mode != CAL_MODE &&
mode != ADVANCE_MODE &&
t->typ != RUN_TYPE &&
!MsgCommand) {
if (DBufPutc(dbuf, '\n') != OK) return E_NO_MEM;
}
break;

View File

@@ -58,6 +58,7 @@ EXTERN INIT( int DoSimpleCalendar, 0);
EXTERN INIT( int DoSimpleCalDelta, 0);
EXTERN INIT( int DoPrefixLineNo, 0);
EXTERN INIT( int MondayFirst, 0);
EXTERN INIT( int AddBlankLines, 1);
EXTERN INIT( int Iterations, 1);
EXTERN INIT( int PsCal, 0);
EXTERN INIT( int CalWidth, 80);

View File

@@ -776,6 +776,7 @@ typedef struct {
/* All of the system variables sorted alphabetically */
static SysVar SysVarArr[] = {
/* name mod type value min/mal max validate*/
{"AddBlankLines", 1, INT_TYPE, &AddBlankLines, 0, 1, NULL },
{"Ago", 1, STR_TYPE, &DynamicAgo, 0, 0, NULL },
{"Am", 1, STR_TYPE, &DynamicAm, 0, 0, NULL },
{"And", 1, STR_TYPE, &DynamicAnd, 0, 0, NULL },

5
tests/blanks.rem Normal file
View File

@@ -0,0 +1,5 @@
MSG $AddBlankLines=[$AddBlankLines]
MSG Hello
MSG Hi
MSF How are you?
MSG OK

View File

@@ -116,6 +116,11 @@ echo "ANSI Color Test" >> ../tests/test.out
../src/remind -@1,1,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind -@2,1,1 ../tests/ansicolors.rem 1 Jan 2022 >> ../tests/test.out 2>&1
echo '$AddBlankLines test' >> ../tests/test.out
../src/remind ../tests/blanks.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind '-i$AddBlankLines=1' ../tests/blanks.rem 1 Jan 2022 >> ../tests/test.out 2>&1
../src/remind '-i$AddBlankLines=0' ../tests/blanks.rem 1 Jan 2022 >> ../tests/test.out 2>&1
echo "MON WKDAY DAY across year test" >> ../tests/test.out
echo 'REM Mon 29 Dec MSG x' | ../src/remind -dt - 1 Jan 2000 >> ../tests/test.out 2>&1

View File

@@ -2723,6 +2723,7 @@ a125 -1
dump $
Variable Value
$AddBlankLines 1 [0, 1]
$Ago "ago"
$Am "am"
$And "and"
@@ -6618,6 +6619,37 @@ keyword will[38;2;0
../tests/ansicolors.rem(41): ansicolor(): Number too low
../tests/ansicolors.rem(42): ansicolor(): Number too high
../tests/ansicolors.rem(43): ansicolor(): Number too low
$AddBlankLines test
Reminders for Saturday, 1st January, 2022:
$AddBlankLines=1
Hello
Hi
How are you?
OK
Reminders for Saturday, 1st January, 2022:
$AddBlankLines=1
Hello
Hi
How are you?
OK
Reminders for Saturday, 1st January, 2022:
$AddBlankLines=0
Hello
Hi
How are you?
OK
MON WKDAY DAY across year test
-(1): Trig = Monday, 3 January, 2000
No reminders.