[wiki] [sites] Add a sent patch that adds numbering on slides || Antoine Lonné

From: <git_AT_suckless.org>
Date: Sun, 12 Nov 2023 15:58:44 +0100

commit 8d4981a15e802534c358fca5d1893773ba615256
Author: Antoine Lonné <antoine_AT_antoinelonne.dev>
Date: Sun Nov 12 15:48:26 2023 +0100

    Add a sent patch that adds numbering on slides
    
    This patch adds a numbering in the bottom left corner of the slide.

diff --git a/tools.suckless.org/sent/patches/slide-number/index.md b/tools.suckless.org/sent/patches/slide-number/index.md
new file mode 100644
index 00000000..a2d54be2
--- /dev/null
+++ b/tools.suckless.org/sent/patches/slide-number/index.md
_AT_@ -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_AT_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
new file mode 100644
index 00000000..1dc69177
--- /dev/null
+++ b/tools.suckless.org/sent/patches/slide-number/sent-slide-number-1.0.diff
_AT_@ -0,0 +1,61 @@
+From dcd4dc269be453d7b4759d32971986da6040aba4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Antoine=20Lonn=C3=A9?= <antoine_AT_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
+_AT_@ -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
+_AT_@ -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);
+_AT_@ -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
+
Received on Sun Nov 12 2023 - 15:58:44 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 12 2023 - 16:00:48 CET