summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 23:33:23 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 23:33:23 +0200
commit46e482552c35456ddc836720df0a44ba25f60544 (patch)
tree241d18be89022e7e0951b80752f7b2c3815de0e1
parent4a0ab3d2f390a68b18c40b04269c46a6373c08f9 (diff)
downloadclectio-46e482552c35456ddc836720df0a44ba25f60544.tar.gz
clectio-46e482552c35456ddc836720df0a44ba25f60544.zip
feat: config.h GOSPEL_ONLY -- print all readings (default) or just the Gospel
Add a compile-time toggle in config.h: GOSPEL_ONLY=0 (default) prints every reading; GOSPEL_ONLY=1 prints only the Gospel. The Gospel is matched by its part label, so it works for both forms. Help and the compiled-settings line report the mode. Also tidy print_day's header underline to match the width of the "<form> for <date>" line instead of the reading count. No data change; strict -Wsign-conversion clean in both modes. Claude-Session: https://claude.ai/code/session_01S1CD1u3tgSS4xNu6WHfp5a
-rw-r--r--README.md1
-rw-r--r--clectio.c17
-rw-r--r--config.def.h8
3 files changed, 20 insertions, 6 deletions
diff --git a/README.md b/README.md
index e6b494c..2852836 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,7 @@ Edit `config.h` (copied from `config.def.h` on first build), then `make`:
* `FORM_OF` / `FORM_EF` — Ordinary Form (1969) or Extraordinary Form (1962)
* `SIGLA_ENGLISH` / `SIGLA_LATIN` — citation dialect (`Jer 14` vs `Ier 14`)
* `COLOR` — colour the day name with its liturgical colour
+ * `GOSPEL_ONLY` — print every reading (0, default) or just the Gospel (1)
One form per binary; for both, build twice. The interface is English only.
diff --git a/clectio.c b/clectio.c
index 6461e51..24cb4b6 100644
--- a/clectio.c
+++ b/clectio.c
@@ -67,18 +67,23 @@ static const char *citation(int r) {
static void print_day(long off, const char *datestr) {
const Day *d = &days[cal[off]];
- unsigned k, ri;
+ unsigned ri;
+ int n;
if (usecolor)
- printf("%s%s\033[0m", colansi[d->colour], names[d->name]);
+ printf("%s%s\033[0m\n", colansi[d->colour], names[d->name]);
else
- printf("%s \xc2\xb7 %s", names[d->name], colname[d->colour]);
- printf("\n%s for %s\n", FORMNAME, datestr);
- for (k = 0; k < d->rlen; k++)
+ printf("%s \xc2\xb7 %s\n", names[d->name], colname[d->colour]);
+ n = printf("%s for %s\n", FORMNAME, datestr) - 1; /* underline that line */
+ while (n-- > 0)
putchar('=');
putchar('\n');
for (ri = 0; ri < d->rlen; ri++) {
const Reading *r = &readings[rpool[d->roff + ri]];
unsigned v;
+#if GOSPEL_ONLY
+ if (strcmp(parts[r->part], "Gospel") != 0)
+ continue;
+#endif
printf("\n%s (%s)\n\n", parts[r->part], citation(rpool[d->roff + ri]));
for (v = 0; v < r->vlen; v++)
printf("%s\n", verse[vpool[r->voff + v]]);
@@ -95,7 +100,7 @@ int main(int argc, char **argv) {
if (argc > 1 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) {
fprintf(stderr, "usage: clectio [YYYY-MM-DD] (default: today)\n"
- " compiled: %s, %s, %d-%d\n", FORMNAME, SIGLANAME, EPOCH_Y, EPOCH_Y + (NDAYS / 366));
+ " compiled: %s, %s, %s, %d-%d\n", FORMNAME, SIGLANAME, READMODE, EPOCH_Y, EPOCH_Y + (NDAYS / 366));
return 0;
}
if (argc > 1) {
diff --git a/config.def.h b/config.def.h
index 0447669..e22075f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -12,7 +12,15 @@
/* --- Colourize the day name with its liturgical colour on a terminal. ---- */
#define COLOR 1
+/* --- Which readings to print. -------------------------------------------- */
+#define GOSPEL_ONLY 0 /* 0 = all readings; 1 = the Gospel only */
+
/* ------------------------- derived (do not edit) ------------------------- */
+#if GOSPEL_ONLY
+# define READMODE "Gospel only"
+#else
+# define READMODE "all readings"
+#endif
#ifdef FORM_EF
# define LITURGY "gen/liturgy_ef.h"
# define FORMNAME "Extraordinary Form (1962)"