summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile5
-rw-r--r--README.md71
-rw-r--r--calendar.def.h25
-rw-r--r--clectio.c35
5 files changed, 129 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index bc7b305..afba2cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
/mktext
/bin2h
/config.h
+/calendar.h
/text.lz.h
/gen/verses_of.keys
/gen/verses_ef.keys
diff --git a/Makefile b/Makefile
index ae74a05..c22556a 100644
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,9 @@ all: clectio
config.h:
cp config.def.h config.h
+calendar.h:
+ cp calendar.def.h calendar.h
+
mktext: mktext.c
$(CC) $(CFLAGS) -o $@ mktext.c
@@ -42,7 +45,7 @@ endif
text.lz.h: bin2h text_$(FORM).lz
./bin2h text_$(FORM).lz > $@
-clectio: clectio.c puff.c puff.h config.h text.lz.h gen/liturgy_$(FORM).h
+clectio: clectio.c puff.c puff.h config.h calendar.h text.lz.h gen/liturgy_$(FORM).h
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ clectio.c puff.c
size: clectio
diff --git a/README.md b/README.md
index 0de5efe..162f6c3 100644
--- a/README.md
+++ b/README.md
@@ -104,10 +104,81 @@ restore it:
The compiled calendar runs 2025–2054. Dates outside that range are reported, not
guessed. To extend it, regenerate `gen/` with lectio's `clectio-gen`.
+## Customize the calendar
+
+clectio has **no calendar engine** — it looks the calendar up in a compiled
+table, it doesn't compute one. That sets the limits below. There are two ways to
+change what it shows, sized to how much you need.
+
+### Minor: name + colour of a fixed date — standalone, in `calendar.h`
+
+For a local **name and colour** on a **fixed date** (a diocesan patron, a
+national memorial, a renaming), edit `calendar.h` — same suckless flow as
+`config.h`: it is copied from `calendar.def.h` on first build; edit it and
+`make`. No lectio, no toolchain.
+
+ static const Override overrides[] = {
+ { 5, 16, RED, "Saint Andrew Bobola, priest and martyr" },
+ { 8, 15, WHITE, "Assumption of Our Lady, Patroness" },
+ { 0, 0, 0, 0 } /* keep this row last */
+ };
+
+Fields are `{ month, day, colour, "name" }`; colours are `GREEN WHITE RED VIOLET
+ROSE BLACK`. Overrides apply to both the single-day and `--month` output, every
+year.
+
+**Limits** (all because there is no engine):
+- **fixed dates only** — no movable / computed feasts;
+- changes the **name and colour only**, not a day's **readings** or its
+ **rank / precedence** (the table stores neither). The readings shown stay the
+ underlying day's — which is correct for a memorial, since it uses the weekday
+ readings;
+- an override **wins unconditionally**, so only override a date whose
+ celebration you truly mean to replace.
+
+### Full: readings, ranks, movable feasts — via lectio, then recompile
+
+Anything the engine must compute — **proper readings, a changed rank, a movable
+feast** — is done in **lectio** (its Go engine is where clectio's tables come
+from) and baked back into `gen/`. The *running* clectio stays standalone; only
+*regenerating* needs lectio and a Go toolchain.
+
+1. Describe the change as a lectio **calendar layer** (see lectio's README,
+ "Calendar of saints"). A layer entry can set `rank`, `colour`,
+ `name.<lang>`, and `reading.first|psalm|second|acclamation|gospel`:
+
+ lectio --cal-dump mine # writes ~/.config/lectio/calendars/mine.ini
+ $EDITOR ~/.config/lectio/calendars/mine.ini
+ lectio --cal-check mine
+
+2. Regenerate clectio's tables **with that layer applied** (`old` for the EF):
+
+ cd ~/git/projects/lectio
+ go run ./cmd/clectio-gen -caldir ~/.config/lectio/calendars -use mine \
+ new 2025 2054 ~/git/projects/clectio/gen/
+
+ (`-sanctorale DIR` instead applies a full `of.ini`/`ef.ini` replacement. The
+ book table stays embedded, so a stale `books.ini` can't affect the result.
+ The 30-year range takes roughly a minute.)
+
+3. Rebuild clectio, **repacking the text** so any newly-cited verses are
+ included:
+
+ cd ~/git/projects/clectio
+ make CC=gcc clean
+ make CC=gcc CORPUS=~/git/projects/lectio/internal/bible/corpora/vul.tsv
+
+ (A change that cites only already-embedded verses would build without
+ `CORPUS=`, but repacking is the safe default.)
+
+To undo it and return to the shipped calendar: `git checkout gen/ text_of.lz`
+(or `text_ef.lz`) and rebuild.
+
## Files
clectio.c the program: date -> table lookup -> print
config.def.h compile-time configuration
+ calendar.def.h local calendar overrides (name + colour by fixed date)
puff.c/.h DEFLATE decompressor (Mark Adler's puff, public domain)
mktext.c build tool: resolve verse keys against a corpus, gzip-pack the text
bin2h.c build tool: embed the packed text as C
diff --git a/calendar.def.h b/calendar.def.h
new file mode 100644
index 0000000..3a43f0a
--- /dev/null
+++ b/calendar.def.h
@@ -0,0 +1,25 @@
+/* clectio local calendar overrides -- suckless style: copy to calendar.h,
+ * edit, `make`. Compiled in; there is no config file at run time.
+ *
+ * Each row REPLACES the name and colour of ONE fixed date (month, day), every
+ * year. This is for MINOR local changes only. clectio has no calendar engine,
+ * so it CANNOT, here:
+ * - change a day's READINGS, or its RANK / precedence (it stores neither);
+ * - place MOVABLE feasts (Easter-relative dates);
+ * - arbitrate against the universal day -- an override wins UNCONDITIONALLY,
+ * so only override a date whose celebration you truly mean to replace.
+ * The readings shown on an overridden day stay the underlying day's -- which is
+ * correct for a memorial (it uses the weekday readings). For proper readings,
+ * ranks, or movable feasts, regenerate the calendar from lectio (see README).
+ *
+ * Colours: GREEN WHITE RED VIOLET ROSE BLACK
+ * Fields: { month, day, colour, "Display name" }
+ */
+static const Override overrides[] = {
+ /* Uncomment, edit, or add rows. Examples: */
+ /* { 5, 16, RED, "Saint Andrew Bobola, priest and martyr" }, */
+ /* { 4, 23, RED, "Saint Adalbert, bishop and martyr" }, */
+ /* { 8, 15, WHITE, "The Assumption -- Our Lady of the Herbs" }, */
+
+ { 0, 0, 0, 0 } /* end marker -- keep this row last */
+};
diff --git a/clectio.c b/clectio.c
index 1839ade..469d074 100644
--- a/clectio.c
+++ b/clectio.c
@@ -30,6 +30,21 @@ static int usecolor;
static const char *const colname[] = { "green", "white", "red", "violet", "rose", "black" };
static const char *const colansi[] = { "\033[32m", "\033[37m", "\033[31m", "\033[35m", "\033[95m", "\033[90m" };
+/* Local calendar overrides: replace one fixed date's name + colour. The colour
+ * names below match colname[]/colansi[] above (index order). The user table
+ * lives in calendar.h (copied from calendar.def.h); see it for the limits. */
+enum { GREEN, WHITE, RED, VIOLET, ROSE, BLACK };
+typedef struct { int mon, day, colour; const char *name; } Override;
+#include "calendar.h" /* static const Override overrides[]; ends with a {0,...} row */
+
+static const Override *find_override(int mon, int day) {
+ const Override *o;
+ for (o = overrides; o->mon; o++)
+ if (o->mon == mon && o->day == day)
+ return o;
+ return NULL;
+}
+
/* Days since the civil epoch 1970-01-01 (Howard Hinnant's algorithm). */
static long days_from_civil(long y, unsigned m, unsigned d) {
y -= m <= 2;
@@ -131,12 +146,15 @@ static int print_month(int y, int mon) {
for (day = 1; day <= dim; day++) {
long civ = civ1 + (day - 1);
const Day *d = &days[cal[off1 + (day - 1)]];
+ const Override *ov = find_override(mon, day);
+ const char *dname = ov ? ov->name : names[d->name];
+ int dcol = ov ? ov->colour : d->colour;
int w = (int)((civ + 4) % 7); /* 1970-01-01 was Thursday; 0 = Sunday */
- printf("%s %02d %-6s ", wd[w], day, colname[d->colour]);
+ printf("%s %02d %-6s ", wd[w], day, colname[dcol]);
if (usecolor)
- printf("%s%s\033[0m\n", colansi[d->colour], names[d->name]);
+ printf("%s%s\033[0m\n", colansi[dcol], dname);
else
- printf("%s\n", names[d->name]);
+ printf("%s\n", dname);
}
return 0;
}
@@ -165,14 +183,17 @@ static int run_month(const char *spec) {
return print_month(y, mon);
}
-static void print_day(long off, const char *datestr, int gospel, int wrap) {
+static void print_day(long off, const char *datestr, int mon, int day, int gospel, int wrap) {
const Day *d = &days[cal[off]];
+ const Override *ov = find_override(mon, day);
+ const char *dname = ov ? ov->name : names[d->name];
+ int dcol = ov ? ov->colour : d->colour;
unsigned ri;
int n;
if (usecolor)
- printf("%s%s\033[0m\n", colansi[d->colour], names[d->name]);
+ printf("%s%s\033[0m\n", colansi[dcol], dname);
else
- printf("%s \xc2\xb7 %s\n", names[d->name], colname[d->colour]);
+ printf("%s \xc2\xb7 %s\n", dname, colname[dcol]);
n = printf("%s for %s\n", FORMNAME, datestr) - 1; /* underline that line */
while (n-- > 0)
putchar('=');
@@ -263,6 +284,6 @@ int main(int argc, char **argv) {
wrap = istty ? termwidth() : 0;
load_text();
- print_day(off, datestr, gospel, wrap);
+ print_day(off, datestr, m, dd, gospel, wrap);
return 0;
}