aboutsummaryrefslogtreecommitdiff
path: root/colitur-x.c
diff options
context:
space:
mode:
Diffstat (limited to 'colitur-x.c')
-rw-r--r--colitur-x.c33
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. */