On Sat, Sep 02, 2017 at 11:01:03AM +0200, ssd_AT_mailless.org 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 <ssd_AT_mailless.org>
> Date: Sat, 2 Sep 2017 02:55:55 +0200
> Subject: [sent] add slide numbers (configure position + font size)
> To: hackers_AT_suckless.org
>
> ---
> 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
> _AT_@ -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
> _AT_@ -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++)
> _AT_@ -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
Received on Sat Sep 02 2017 - 12:08:02 CEST