"#FFFFFF", /* background color */
};
+static const char *inverted_colors[] = {
+ "#FFFFFF", /* foreground color */
+ "#000000", /* background color */
+};
+
static const float linespacing = 1.4;
/* 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;
+/* height of the presentation progress bar */
+static const int progressheight = 5;
+
static Mousekey mshortcuts[] = {
/* button function argument */
{ Button1, advance, {.i = +1} },
{ XK_n, advance, {.i = +1} },
{ XK_p, advance, {.i = -1} },
{ XK_r, reload, {0} },
+ { XK_i, togglescm, {0} },
};
static Filter filters[] = {
--- /dev/null
+diff --git a/config.def.h b/config.def.h
+index 60eb376..ccea9a6 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -13,6 +13,11 @@ static const char *colors[] = {
+ "#FFFFFF", /* background color */
+ };
+
++static const char *inverted_colors[] = {
++ "#FFFFFF", /* foreground color */
++ "#000000", /* background color */
++};
++
+ static const float linespacing = 1.4;
+
+ /* how much screen estate is to be used at max for the content */
+diff --git a/sent.1 b/sent.1
+index fabc614..f74d583 100644
+--- a/sent.1
++++ b/sent.1
+@@ -6,6 +6,7 @@
+ .Sh SYNOPSIS
+ .Nm
+ .Op Fl v
++.Op Fl i
+ .Op Ar file
+ .Sh DESCRIPTION
+ .Nm
+@@ -21,6 +22,8 @@ few minutes.
+ .Bl -tag -width Ds
+ .It Fl v
+ Print version information to stdout and exit.
++.It Fl i
++Use the colors from the inverted color array.
+ .El
+ .Sh USAGE
+ .Bl -tag -width Ds
+diff --git a/sent.c b/sent.c
+index c50a572..c31f772 100644
+--- a/sent.c
++++ b/sent.c
+@@ -25,6 +25,8 @@
+
+ char *argv0;
+
++int use_inverted_colors = 0;
++
+ /* macros */
+ #define LEN(a) (sizeof(a) / sizeof(a)[0])
+ #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
+@@ -586,7 +588,11 @@ xinit()
+
+ if (!(d = drw_create(xw.dpy, xw.scr, xw.win, xw.w, xw.h)))
+ die("sent: Unable to create drawing context");
+- sc = drw_scm_create(d, colors, 2);
++ if (use_inverted_colors) {
++ sc = drw_scm_create(d, inverted_colors, 2);
++ } else {
++ sc = drw_scm_create(d, colors, 2);
++ }
+ drw_setscheme(d, sc);
+ XSetWindowBackground(xw.dpy, xw.win, sc[ColBg].pixel);
+
+@@ -687,6 +693,9 @@ main(int argc, char *argv[])
+ case 'v':
+ fprintf(stderr, "sent-"VERSION"\n");
+ return 0;
++ case 'i':
++ use_inverted_colors = 1;
++ break;
+ default:
+ usage();
+ } ARGEND
--- /dev/null
+From 3a348cc15a97df8e8784b129800293dcfba28f3f Mon Sep 17 00:00:00 2001
+From: Sunur Efe Vural <efe@efe.kim>
+Date: Wed, 13 Feb 2019 14:28:17 -0500
+Subject: [PATCH] Commandline Options
+
+A simple patch that adds extra commandline options to sent.
+---
+ sent.1 | 11 +++++++++++
+ sent.c | 11 ++++++++++-
+ 2 files changed, 21 insertions(+), 1 deletion(-)
+
+diff --git a/sent.1 b/sent.1
+index fabc614..5d55bf4 100644
+--- a/sent.1
++++ b/sent.1
+@@ -5,6 +5,9 @@
+ .Nd simple plaintext presentation tool
+ .Sh SYNOPSIS
+ .Nm
++.Op Fl f Ar font
++.Op Fl c Ar fgcolor
++.Op Fl b Ar bgcolor
+ .Op Fl v
+ .Op Ar file
+ .Sh DESCRIPTION
+@@ -21,6 +24,14 @@ few minutes.
+ .Bl -tag -width Ds
+ .It Fl v
+ Print version information to stdout and exit.
++.It Fl f Ar font
++Defines the
++.Ar font
++when sent is run.
++.It Fl c Ar fgcolor
++Defines the foreground color when sent is run.
++.It Fl b Ar bgcolor
++Defines the background color when sent is run.
+ .El
+ .Sh USAGE
+ .Bl -tag -width Ds
+diff --git a/sent.c b/sent.c
+index c50a572..0b36e32 100644
+--- a/sent.c
++++ b/sent.c
+@@ -675,7 +675,7 @@ configure(XEvent *e)
+ void
+ usage()
+ {
+- die("usage: %s [file]", argv0);
++ die("usage: %s [-c fgcolor] [-b bgcolor] [-f font] [file]", argv0);
+ }
+
+ int
+@@ -687,6 +687,15 @@ main(int argc, char *argv[])
+ case 'v':
+ fprintf(stderr, "sent-"VERSION"\n");
+ return 0;
++ case 'f':
++ fontfallbacks[0] = EARGF(usage());
++ break;
++ case 'c':
++ colors[0] = EARGF(usage());
++ break;
++ case 'b':
++ colors[1] = EARGF(usage());
++ break;
+ default:
+ usage();
+ } ARGEND
+--
+2.20.1
+
--- /dev/null
+diff --git a/config.def.h b/config.def.h
+index 60eb376..25d89e0 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -19,6 +19,9 @@ static const float linespacing = 1.4;
+ static const float usablewidth = 0.75;
+ static const float usableheight = 0.75;
+
++/* height of the presentation progress bar */
++static const int progressheight = 5;
++
+ static Mousekey mshortcuts[] = {
+ /* button function argument */
+ { Button1, advance, {.i = +1} },
+diff --git a/sent.c b/sent.c
+index c50a572..046466e 100644
+--- a/sent.c
++++ b/sent.c
+@@ -533,6 +533,12 @@ xdraw()
+ 0,
+ slides[idx].lines[i],
+ 0);
++ if (idx != 0 && progressheight != 0) {
++ drw_rect(d,
++ 0, xw.h - progressheight,
++ (xw.w * idx)/(slidecount - 1), progressheight,
++ 1, 0);
++ }
+ drw_map(d, xw.win, 0, 0, xw.w, xw.h);
+ } else {
+ if (!(im->state & SCALED))
--- /dev/null
+From 2be4210944d97ddb158feee601ec85c016de0872 Mon Sep 17 00:00:00 2001
+From: Randoragon <randoragongamedev@gmail.com>
+Date: Tue, 19 Jan 2021 10:17:47 +0100
+Subject: [PATCH] Add toggle colorscheme functionality
+
+This patch is meant to be applied on top of the "inverted colors" patch
+(https://tools.suckless.org/sent/patches/inverted-colors/). It creates a
+new binding, "i", that lets you toggle between two colorschemes during
+presentation.
+---
+ config.def.h | 1 +
+ sent.1 | 2 ++
+ sent.c | 18 ++++++++++++++++++
+ 3 files changed, 21 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index ccea9a6..c72afc5 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -52,6 +52,7 @@ static Shortcut shortcuts[] = {
+ { XK_n, advance, {.i = +1} },
+ { XK_p, advance, {.i = -1} },
+ { XK_r, reload, {0} },
++ { XK_i, togglescm, {0} },
+ };
+
+ static Filter filters[] = {
+diff --git a/sent.1 b/sent.1
+index f74d583..a7564a8 100644
+--- a/sent.1
++++ b/sent.1
+@@ -44,6 +44,8 @@ Reload the slides. Only works on file input.
+ Go to next slide, if existent.
+ .It Sy Left | Backspace | h | k | Up | Prior | p
+ Go to previous slide, if existent.
++.It Sy i
++Toggle colorschemes.
+ .El
+ .El
+ .Sh FORMAT
+diff --git a/sent.c b/sent.c
+index 7053ab3..d29fc35 100644
+--- a/sent.c
++++ b/sent.c
+@@ -107,6 +107,7 @@ static void xdraw();
+ static void xhints();
+ static void xinit();
+ static void xloadfonts();
++static void togglescm();
+
+ static void bpress(XEvent *);
+ static void cmessage(XEvent *);
+@@ -613,6 +614,23 @@ xinit()
+ XSync(xw.dpy, False);
+ }
+
++void
++togglescm()
++{
++ if (use_inverted_colors) {
++ free(sc);
++ sc = drw_scm_create(d, colors, 2);
++ use_inverted_colors = 0;
++ } else {
++ sc = drw_scm_create(d, inverted_colors, 2);
++ use_inverted_colors = 1;
++ }
++ drw_setscheme(d, sc);
++ XSetWindowBackground(xw.dpy, xw.win, sc[ColBg].pixel);
++ xdraw();
++}
++
++
+ void
+ xloadfonts()
+ {
+--
+2.30.0
+
.Nd simple plaintext presentation tool
.Sh SYNOPSIS
.Nm
+.Op Fl f Ar font
+.Op Fl c Ar fgcolor
+.Op Fl b Ar bgcolor
.Op Fl v
+.Op Fl i
.Op Ar file
.Sh DESCRIPTION
.Nm
.Bl -tag -width Ds
.It Fl v
Print version information to stdout and exit.
+.It Fl i
+Use the colors from the inverted color array.
.El
.Sh USAGE
.Bl -tag -width Ds
Go to next slide, if existent.
.It Sy Left | Backspace | h | k | Up | Prior | p
Go to previous slide, if existent.
+.It Sy i
+Toggle colorschemes.
.El
.El
.Sh FORMAT
char *argv0;
+int use_inverted_colors = 0;
+
/* macros */
#define LEN(a) (sizeof(a) / sizeof(a)[0])
#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
typedef struct {
unsigned int linecount;
char **lines;
+ int *invert;
Image *img;
char *embed;
} Slide;
static void xhints();
static void xinit();
static void xloadfonts();
+static void togglescm();
static void bpress(XEvent *);
static void cmessage(XEvent *);
static size_t size = 0;
size_t blen, maxlines;
char buf[BUFSIZ], *p;
+ int inverted = 0;
Slide *s;
/* read each line from fp and add it to the item list */
if (buf[0] == '#')
continue;
+ inverted = 0;
+ if (buf[0] == '$') {
+ buf[0] = ' ';
+ inverted = 1;
+ }
+
/* grow lines array */
if (s->linecount >= maxlines) {
maxlines = 2 * s->linecount + 1;
if (!(s->lines = realloc(s->lines, maxlines * sizeof(s->lines[0]))))
die("sent: Unable to reallocate %u bytes:", maxlines * sizeof(s->lines[0]));
+ if (!(s->invert = realloc(s->invert, maxlines * sizeof(s->invert[0]))))
+ die("sent: Unable to reallocate %u bytes:", maxlines * sizeof(s->invert[0]));
}
+ s->invert[s->linecount] = inverted;
+
blen = strlen(buf);
if (!(s->lines[s->linecount] = strdup(buf)))
die("sent: Unable to strdup:");
if (!im) {
drw_rect(d, 0, 0, xw.w, xw.h, 1, 1);
- for (i = 0; i < slides[idx].linecount; i++)
- drw_text(d,
- (xw.w - width) / 2,
- (xw.h - height) / 2 + i * linespacing * d->fonts->h,
- width,
- d->fonts->h,
- 0,
- slides[idx].lines[i],
- 0);
+ for (i = 0; i < slides[idx].linecount; i++) {
+ if (slides[idx].invert[i]) {
+ drw_rect(d,
+ 0,
+ (xw.h - height) / 2 + i * linespacing * d->fonts->h,
+ xw.w,
+ d->fonts->h, 1, 0);
+ }
+
+ drw_text(d,
+ (xw.w - width) / 2,
+ (xw.h - height) / 2 + i * linespacing * d->fonts->h,
+ width,
+ d->fonts->h,
+ 0,
+ slides[idx].lines[i],
+ slides[idx].invert[i]);
+ }
+ if (idx != 0 && progressheight != 0) {
+ drw_rect(d,
+ 0, xw.h - progressheight,
+ (xw.w * idx)/(slidecount - 1), progressheight,
+ 1, 0);
+ }
drw_map(d, xw.win, 0, 0, xw.w, xw.h);
} else {
if (!(im->state & SCALED))
if (!(d = drw_create(xw.dpy, xw.scr, xw.win, xw.w, xw.h)))
die("sent: Unable to create drawing context");
- sc = drw_scm_create(d, colors, 2);
+ if (use_inverted_colors) {
+ sc = drw_scm_create(d, inverted_colors, 2);
+ } else {
+ sc = drw_scm_create(d, colors, 2);
+ }
drw_setscheme(d, sc);
XSetWindowBackground(xw.dpy, xw.win, sc[ColBg].pixel);
XSync(xw.dpy, False);
}
+void
+togglescm()
+{
+ if (use_inverted_colors) {
+ free(sc);
+ sc = drw_scm_create(d, colors, 2);
+ use_inverted_colors = 0;
+ } else {
+ sc = drw_scm_create(d, inverted_colors, 2);
+ use_inverted_colors = 1;
+ }
+ drw_setscheme(d, sc);
+ XSetWindowBackground(xw.dpy, xw.win, sc[ColBg].pixel);
+ xdraw();
+}
+
+
void
xloadfonts()
{
void
usage()
{
- die("usage: %s [file]", argv0);
+ die("usage: %s [-c fgcolor] [-b bgcolor] [-f font] [file]", argv0);
}
int
case 'v':
fprintf(stderr, "sent-"VERSION"\n");
return 0;
+ case 'i':
+ use_inverted_colors = 1;
+ break;
+ case 'f':
+ fontfallbacks[0] = EARGF(usage());
+ break;
+ case 'c':
+ colors[0] = EARGF(usage());
+ break;
+ case 'b':
+ colors[1] = EARGF(usage());
+ break;
default:
usage();
} ARGEND