sites

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

sent-slide-number-1.0.diff (1898B)


      1 From dcd4dc269be453d7b4759d32971986da6040aba4 Mon Sep 17 00:00:00 2001
      2 From: =?UTF-8?q?Antoine=20Lonn=C3=A9?= <antoine@antoinelonne.dev>
      3 Date: Tue, 7 Nov 2023 21:49:25 +0100
      4 Subject: [PATCH] Add slide numbering and size configuration
      5 
      6 ---
      7  config.def.h |  3 +++
      8  sent.c       | 19 +++++++++++++++++++
      9  2 files changed, 22 insertions(+)
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 index 60eb376..5b17cc9 100644
     13 --- a/config.def.h
     14 +++ b/config.def.h
     15 @@ -54,3 +54,6 @@ static Filter filters[] = {
     16  	{ "\\.ff.bz2$", "bunzip2" },
     17  	{ "\\.[a-z0-9]+$", "2ff" },
     18  };
     19 +
     20 +static const unsigned int slide_nb_margin = 10;
     21 +static const char *slide_nb_fnt[] = { "fixed:size=16", NULL };
     22 diff --git a/sent.c b/sent.c
     23 index dfadd3a..31fa3f5 100644
     24 --- a/sent.c
     25 +++ b/sent.c
     26 @@ -524,6 +524,8 @@ xdraw(void)
     27  {
     28  	unsigned int height, width, i;
     29  	Image *im = slides[idx].img;
     30 +    char slide_nb[16];
     31 +    unsigned int slide_nb_w, slide_nb_h;
     32  
     33  	getfontsize(&slides[idx], &width, &height);
     34  	XClearWindow(xw.dpy, xw.win);
     35 @@ -539,6 +541,23 @@ xdraw(void)
     36  			         0,
     37  			         slides[idx].lines[i],
     38  			         0);
     39 +
     40 +        if (idx > 0){
     41 +            snprintf(slide_nb, sizeof(slide_nb), "%d/%d", idx + 1, slidecount);
     42 +            Drw *d_small = malloc(sizeof(Drw));
     43 +            *d_small = *d;
     44 +            d_small->fonts = drw_fontset_create(d_small, slide_nb_fnt, 1);
     45 +            drw_font_getexts(d_small->fonts, slide_nb, strlen(slide_nb),
     46 +                             &slide_nb_w, &slide_nb_h);
     47 +            drw_text(d_small,
     48 +                     xw.w - slide_nb_w - slide_nb_margin,
     49 +                     xw.h - slide_nb_h - slide_nb_margin,
     50 +                     slide_nb_w,
     51 +                     slide_nb_h,
     52 +                     0,
     53 +                     slide_nb,
     54 +                     0);
     55 +        }
     56  		drw_map(d, xw.win, 0, 0, xw.w, xw.h);
     57  	} else {
     58  		if (!(im->state & SCALED))
     59 -- 
     60 2.42.1
     61