From e95599ddf5a2745ddc36f701483f39e0e6aacfbf Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Thu, 29 Oct 2020 15:17:24 -0400 Subject: Initial Commit --- .gitignore | 4 ++ config.def.h | 12 ++++- config.mk | 2 +- example | 4 -- patches/sent-invertedcolors-72d33d4.diff | 73 ++++++++++++++++++++++++++++++ patches/sent-options-20190213-72d33d4.diff | 72 +++++++++++++++++++++++++++++ patches/sent-progress-bar-1.0.diff | 31 +++++++++++++ sent.1 | 14 ++++++ sent.c | 28 +++++++++++- 9 files changed, 231 insertions(+), 9 deletions(-) create mode 100644 patches/sent-invertedcolors-72d33d4.diff create mode 100644 patches/sent-options-20190213-72d33d4.diff create mode 100644 patches/sent-progress-bar-1.0.diff diff --git a/.gitignore b/.gitignore index 4c303b0..e6206b2 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,8 @@ *.swp *~ +# Patch files +*.orig +*.rej + config.h diff --git a/config.def.h b/config.def.h index 60eb376..b09f839 100644 --- a/config.def.h +++ b/config.def.h @@ -9,8 +9,13 @@ static char *fontfallbacks[] = { #define FONTSZ(x) ((int)(10.0 * powf(1.1288, (x)))) /* x in [0, NUMFONTSCALES-1] */ static const char *colors[] = { - "#000000", /* foreground color */ - "#FFFFFF", /* background color */ + "#f2f1f0", /* foreground color */ + "#222d32", /* background color */ +}; + +static const char *inverted_colors[] = { + "#222d32", /* foreground color */ + "#f2f1f0", /* background color */ }; static const float linespacing = 1.4; @@ -19,6 +24,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/config.mk b/config.mk index d61c554..8e05295 100644 --- a/config.mk +++ b/config.mk @@ -27,4 +27,4 @@ LDFLAGS += -g ${LIBS} #LDFLAGS += ${LIBS} # compiler and linker -CC ?= cc +CC ?= tcc diff --git a/example b/example index 300577a..e74b0fc 100644 --- a/example +++ b/example @@ -12,10 +12,6 @@ also: terminal presentations don't support images… -@nyan.png -this text will not be displayed, since the @ at the start of the first line -makes this paragraph an image slide. - easy to use depends on diff --git a/patches/sent-invertedcolors-72d33d4.diff b/patches/sent-invertedcolors-72d33d4.diff new file mode 100644 index 0000000..2da5fc5 --- /dev/null +++ b/patches/sent-invertedcolors-72d33d4.diff @@ -0,0 +1,73 @@ +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 diff --git a/patches/sent-options-20190213-72d33d4.diff b/patches/sent-options-20190213-72d33d4.diff new file mode 100644 index 0000000..d13df48 --- /dev/null +++ b/patches/sent-options-20190213-72d33d4.diff @@ -0,0 +1,72 @@ +From 3a348cc15a97df8e8784b129800293dcfba28f3f Mon Sep 17 00:00:00 2001 +From: Sunur Efe Vural +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 + diff --git a/patches/sent-progress-bar-1.0.diff b/patches/sent-progress-bar-1.0.diff new file mode 100644 index 0000000..9d0e7d2 --- /dev/null +++ b/patches/sent-progress-bar-1.0.diff @@ -0,0 +1,31 @@ +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)) diff --git a/sent.1 b/sent.1 index fabc614..41e9a73 100644 --- a/sent.1 +++ b/sent.1 @@ -5,7 +5,11 @@ .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 @@ -21,6 +25,16 @@ 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. +.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 9534fca..2302127 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) @@ -537,6 +539,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)) @@ -590,7 +598,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); @@ -679,7 +691,7 @@ configure(XEvent *e) void usage() { - die("usage: %s [file]", argv0); + die("usage: %s [-c fgcolor] [-b bgcolor] [-f font] [file]", argv0); } int @@ -691,6 +703,18 @@ 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; + case 'i': + use_inverted_colors = 1; + break; default: usage(); } ARGEND -- cgit v1.2.3