sent-toggle-scm-20210119-2be4210.diff (2013B)
1 From 2be4210944d97ddb158feee601ec85c016de0872 Mon Sep 17 00:00:00 2001 2 From: Randoragon <randoragongamedev@gmail.com> 3 Date: Tue, 19 Jan 2021 10:17:47 +0100 4 Subject: [PATCH] Add toggle colorscheme functionality 5 6 This patch is meant to be applied on top of the "inverted colors" patch 7 (https://tools.suckless.org/sent/patches/inverted-colors/). It creates a 8 new binding, "i", that lets you toggle between two colorschemes during 9 presentation. 10 --- 11 config.def.h | 1 + 12 sent.1 | 2 ++ 13 sent.c | 18 ++++++++++++++++++ 14 3 files changed, 21 insertions(+) 15 16 diff --git a/config.def.h b/config.def.h 17 index ccea9a6..c72afc5 100644 18 --- a/config.def.h 19 +++ b/config.def.h 20 @@ -52,6 +52,7 @@ static Shortcut shortcuts[] = { 21 { XK_n, advance, {.i = +1} }, 22 { XK_p, advance, {.i = -1} }, 23 { XK_r, reload, {0} }, 24 + { XK_i, togglescm, {0} }, 25 }; 26 27 static Filter filters[] = { 28 diff --git a/sent.1 b/sent.1 29 index f74d583..a7564a8 100644 30 --- a/sent.1 31 +++ b/sent.1 32 @@ -44,6 +44,8 @@ Reload the slides. Only works on file input. 33 Go to next slide, if existent. 34 .It Sy Left | Backspace | h | k | Up | Prior | p 35 Go to previous slide, if existent. 36 +.It Sy i 37 +Toggle colorschemes. 38 .El 39 .El 40 .Sh FORMAT 41 diff --git a/sent.c b/sent.c 42 index 7053ab3..d29fc35 100644 43 --- a/sent.c 44 +++ b/sent.c 45 @@ -107,6 +107,7 @@ static void xdraw(); 46 static void xhints(); 47 static void xinit(); 48 static void xloadfonts(); 49 +static void togglescm(); 50 51 static void bpress(XEvent *); 52 static void cmessage(XEvent *); 53 @@ -613,6 +614,23 @@ xinit() 54 XSync(xw.dpy, False); 55 } 56 57 +void 58 +togglescm() 59 +{ 60 + if (use_inverted_colors) { 61 + free(sc); 62 + sc = drw_scm_create(d, colors, 2); 63 + use_inverted_colors = 0; 64 + } else { 65 + sc = drw_scm_create(d, inverted_colors, 2); 66 + use_inverted_colors = 1; 67 + } 68 + drw_setscheme(d, sc); 69 + XSetWindowBackground(xw.dpy, xw.win, sc[ColBg].pixel); 70 + xdraw(); 71 +} 72 + 73 + 74 void 75 xloadfonts() 76 { 77 -- 78 2.30.0 79