sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 8d4981a15e802534c358fca5d1893773ba615256
parent a540477f182ef370a7e2aa6ef850889b6b92bbfa
Author: Antoine Lonné <antoine@antoinelonne.dev>
Date:   Sun, 12 Nov 2023 15:48:26 +0100

Add a sent patch that adds numbering on slides

This patch adds a numbering in the bottom left corner of the slide.

Diffstat:
Atools.suckless.org/sent/patches/slide-number/index.md | 19+++++++++++++++++++
Atools.suckless.org/sent/patches/slide-number/sent-slide-number-1.0.diff | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/tools.suckless.org/sent/patches/slide-number/index.md b/tools.suckless.org/sent/patches/slide-number/index.md @@ -0,0 +1,19 @@ +Slide number +============ + +Description +----------- +This patch introduces slide number in the bottom right corner of non-image +slides. The number isn't displayed on the first slide + +Notes +----- +You can change the font size and margin of the nubering (`config.h`) + +Download +-------- +* [sent-slide-number-1.0.diff](sent-slide-number-1.0.diff) + +Author +------ +* Antoine Lonné <antoine@antoinelonne.dev> diff --git a/tools.suckless.org/sent/patches/slide-number/sent-slide-number-1.0.diff b/tools.suckless.org/sent/patches/slide-number/sent-slide-number-1.0.diff @@ -0,0 +1,61 @@ +From dcd4dc269be453d7b4759d32971986da6040aba4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Antoine=20Lonn=C3=A9?= <antoine@antoinelonne.dev> +Date: Tue, 7 Nov 2023 21:49:25 +0100 +Subject: [PATCH] Add slide numbering and size configuration + +--- + config.def.h | 3 +++ + sent.c | 19 +++++++++++++++++++ + 2 files changed, 22 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 60eb376..5b17cc9 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -54,3 +54,6 @@ static Filter filters[] = { + { "\\.ff.bz2$", "bunzip2" }, + { "\\.[a-z0-9]+$", "2ff" }, + }; ++ ++static const unsigned int slide_nb_margin = 10; ++static const char *slide_nb_fnt[] = { "fixed:size=16", NULL }; +diff --git a/sent.c b/sent.c +index dfadd3a..31fa3f5 100644 +--- a/sent.c ++++ b/sent.c +@@ -524,6 +524,8 @@ xdraw(void) + { + unsigned int height, width, i; + Image *im = slides[idx].img; ++ char slide_nb[16]; ++ unsigned int slide_nb_w, slide_nb_h; + + getfontsize(&slides[idx], &width, &height); + XClearWindow(xw.dpy, xw.win); +@@ -539,6 +541,23 @@ xdraw(void) + 0, + slides[idx].lines[i], + 0); ++ ++ if (idx > 0){ ++ snprintf(slide_nb, sizeof(slide_nb), "%d/%d", idx + 1, slidecount); ++ Drw *d_small = malloc(sizeof(Drw)); ++ *d_small = *d; ++ d_small->fonts = drw_fontset_create(d_small, slide_nb_fnt, 1); ++ drw_font_getexts(d_small->fonts, slide_nb, strlen(slide_nb), ++ &slide_nb_w, &slide_nb_h); ++ drw_text(d_small, ++ xw.w - slide_nb_w - slide_nb_margin, ++ xw.h - slide_nb_h - slide_nb_margin, ++ slide_nb_w, ++ slide_nb_h, ++ 0, ++ slide_nb, ++ 0); ++ } + drw_map(d, xw.win, 0, 0, xw.w, xw.h); + } else { + if (!(im->state & SCALED)) +-- +2.42.1 +