diff options
| author | Lukasz Kasprzak <lukasz@arcofasiagroup.com> | 2026-08-21 10:09:04 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukasz@arcofasiagroup.com> | 2026-08-21 10:09:04 +0200 |
| commit | 31db51d7fb782c8e79bf1df067dadc1a8be63255 (patch) | |
| tree | 04c0cc05700c7cc1a898fe724b89acfa5e2aa843 /colitur-x.c | |
| parent | 5312537c9fc12eed4d14d89d9cc1a226f2df94c3 (diff) | |
| download | colitur-x-31db51d7fb782c8e79bf1df067dadc1a8be63255.tar.gz colitur-x-31db51d7fb782c8e79bf1df067dadc1a8be63255.zip | |
config: Terminus by default, and stop hiding knobs in the source
config.h now carries everything a reader would reasonably want to change:
both fonts, the liturgical palette and the fallback for an unlisted
colour, the selection rings, geometry, weekday headings, the detail-pane
labels, the window title, and which rank earns a badge and what it says.
Several of those were literals buried in colitur-x.c.
Default font is Terminus:pixelsize=20:antialias=false, matching st.
Terminus is a bitmap face, so it exists only at fixed pixelsizes -- the
list is in the comment, because asking for one it lacks silently gets a
substitute rather than an error.
Layout metrics now come from the font instead of magic numbers: line
height and the badge from XftFont ascent/descent in colitur-x, column
widths in characters rather than pixels in colitur-mu. Before this,
changing the font size left a 13px line height and a 110px date column
that quietly truncated their contents.
Diffstat (limited to 'colitur-x.c')
| -rw-r--r-- | colitur-x.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/colitur-x.c b/colitur-x.c index 03e2793..5307c24 100644 --- a/colitur-x.c +++ b/colitur-x.c @@ -113,7 +113,7 @@ static void colours_for(const char *name, XftColor *bg, XftColor *fg) alloc(palette[i].fg, fg); return; } - alloc("#808080", bg); alloc("#ffffff", fg); + alloc(col_unknown_bg, bg); alloc(col_unknown_fg, fg); } static void text(XftColor *c, XftFont *f, int x, int y, const char *s, int maxw) @@ -209,9 +209,8 @@ static void redraw(void) rows[cur].f[0], mon, rows[cur].f[3]); text(&head, fnt_big, PAD, 26, title, wa.width - 2*PAD); - static const char *dows[] = {"Dom","Fer II","Fer III","Fer IV","Fer V","Fer VI","Sab"}; for (int c = 0; c < 7; c++) - text(&head, fnt, PAD + c*CELL_W + 4, HEAD_H - 6, dows[c], CELL_W - 8); + text(&head, fnt, PAD + c*CELL_W + 4, HEAD_H - 6, dow_headings[c], CELL_W - 8); /* first row index of this month, and where it starts in the week */ int first = 0; @@ -233,30 +232,32 @@ static void redraw(void) CELL_W - 2 - 2*SEL_RING, CELL_H - 2 - 2*SEL_RING, SEL_RING); } + int lh = fnt->ascent + fnt->descent; /* body line height */ + int bigh = fnt_big->ascent + fnt_big->descent; char d[8]; snprintf(d, sizeof d, "%d", dom_of(i)); - text(&fg, fnt_big, x + 6, y + 20, d, 40); - if (!strcmp(rows[i].f[8], "class-1")) { + text(&fg, fnt_big, x + 6, y + fnt_big->ascent + 4, d, CELL_W / 3); + if (!strcmp(rows[i].f[8], badge_rank)) { /* badge: filled with the cell's FOREGROUND, glyph in its BACKGROUND, so it inverts against any liturgical colour */ - int gw = 0, bw2, bx, by = y + 5, bh2 = 17; + int gw = 0, bw2, bx, by = y + 4, bh2 = lh + 2; XGlyphInfo gi; - XftTextExtentsUtf8(dpy, fnt, (FcChar8 *)rank1_glyph, - strlen(rank1_glyph), &gi); + XftTextExtentsUtf8(dpy, fnt, (FcChar8 *)badge_glyph, + strlen(badge_glyph), &gi); gw = gi.xOff; bw2 = gw + 10; bx = x + CELL_W - 4 - bw2; XftDrawRect(xd, &fg, bx, by, bw2, bh2); - XftDrawStringUtf8(xd, &bg, fnt, bx + 5, by + 13, - (FcChar8 *)rank1_glyph, strlen(rank1_glyph)); + XftDrawStringUtf8(xd, &bg, fnt, bx + 5, by + 1 + fnt->ascent, + (FcChar8 *)badge_glyph, strlen(badge_glyph)); } /* Feast name over up to three lines, breaking on spaces that fit the cell. Measured with XftTextExtents rather than guessed at a character count, so it is right for any font in config.h. */ const char *nm = rows[i].f[6]; - int avail = CELL_W - 12, ty = y + 36; + int avail = CELL_W - 12, ty = y + bigh + 8 + fnt->ascent; const char *p = nm; - for (int ln = 0; ln < 3 && *p; ln++) { + for (int ln = 0; ln < NAME_LINES && *p; ln++) { size_t take = strlen(p), best = 0; XGlyphInfo gi; for (size_t k = 1; k <= take; k++) { @@ -272,7 +273,7 @@ static void redraw(void) } } XftDrawStringUtf8(xd, &fg, fnt, x + 6, ty, (FcChar8 *)p, best); - ty += 13; + ty += lh; p += best; while (*p == ' ') p++; } @@ -285,9 +286,9 @@ static void redraw(void) text(&detail, fnt_big, PAD, dy + 22, line, wa.width - 2*PAD); snprintf(line, sizeof line, "%s ยท %s", rows[cur].f[9], rows[cur].f[11]); text(&head, fnt, PAD, dy + 42, line, wa.width - 2*PAD); - snprintf(line, sizeof line, "Epistola %s", rows[cur].f[13]); + snprintf(line, sizeof line, "%-10s %s", label_epistle, rows[cur].f[13]); text(&detail, fnt, PAD, dy + 62, line, wa.width - 2*PAD); - snprintf(line, sizeof line, "Evangelium %s", rows[cur].f[14]); + snprintf(line, sizeof line, "%-10s %s", label_gospel, rows[cur].f[14]); text(&detail, fnt, PAD, dy + 80, line, wa.width - 2*PAD); XCopyArea(dpy, buf, win, gc, 0, 0, wa.width, wa.height, 0, 0); @@ -311,7 +312,7 @@ int main(void) int w = PAD*2 + 7*CELL_W, h = HEAD_H + 6*CELL_H + DETAIL_H; win = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), 0, 0, w, h, 0, BlackPixel(dpy, scr), BlackPixel(dpy, scr)); - XStoreName(dpy, win, "colitur"); + XStoreName(dpy, win, window_title); { /* Ask the window manager for exactly the grid we drew. Without this a tiling or maximising WM picks its own size and the grid floats in a field of background. */ |
