On Sat, Sep 02, 2017 at 11:01:03AM +0200, [email protected] wrote: > > This adds a slide number to the bottom (left, right or middle) of the > slide. It uses the index in the fontlist to specify the font size for > the slide number. > > known issue: number is not shown on image slides. future work. > > cheers > --s
Nice, it can be useful perhaps. > From 7faec195d93d0dce7f494c24ebb4a7b563df4729 Mon Sep 17 00:00:00 2001 > From: ssd <[email protected]> > Date: Sat, 2 Sep 2017 02:55:55 +0200 > Subject: [sent] add slide numbers (configure position + font size) > To: [email protected] > > --- > config.def.h | 4 ++++ > sent.c | 12 ++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/config.def.h b/config.def.h > index f66d121..d82fb27 100644 > --- a/config.def.h > +++ b/config.def.h > @@ -15,6 +15,10 @@ static const char *colors[] = { > > static const float linespacing = 1.4; > > +/* slide numbers: fonts[numfontidx] will be used to display them */ > +static const int numfontidx = 1; > +static const int numpos = 1; /* -1: left, 0: middle, 1: right, any: none*/ > + > /* how much screen estate is to be used at max for the content */ > static const float usablewidth = 0.75; > static const float usableheight = 0.75; > diff --git a/sent.c b/sent.c > index 6cf53ff..1f84f83 100644 > --- a/sent.c > +++ b/sent.c > @@ -483,10 +483,13 @@ xdraw() > { > unsigned int height, width, i; > Image *im = slides[idx].img; > + char idxstr[16]; > > getfontsize(&slides[idx], &width, &height); > XClearWindow(xw.dpy, xw.win); > > + snprintf(idxstr, 16, "%d", idx); > + I think its better to do: > + snprintf(idxstr, sizeof(idxstr), "%d", idx); > if (!im) { > drw_rect(d, 0, 0, xw.w, xw.h, 1, 1); > for (i = 0; i < slides[idx].linecount; i++) > @@ -498,6 +501,15 @@ xdraw() > 0, > slides[idx].lines[i], > 0); > + drw_setfontset(d, fonts[numfontidx]); > + drw_text(d, > + xw.w / 2 + numpos * (xw.w / 2 - 3 * > fonts[numfontidx]->h), > + xw.h - 3 * fonts[numfontidx]->h, > + 4 * d->fonts->h, > + d->fonts->h, > + 1, > + idxstr, > + 0); > drw_map(d, xw.win, 0, 0, xw.w, xw.h); > } else { > if (!(im->state & SCALED)) > -- > 2.13.2 > -- Kind regards, Hiltjo
