diff options
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | config.def.h | 1 | ||||
-rw-r--r-- | config.mk | 7 | ||||
-rw-r--r-- | sent.c | 41 |
4 files changed, 50 insertions, 4 deletions
@@ -11,8 +11,8 @@ worry about alignment. Instead you can really concentrate on the content. Dependencies -You need Xlib and Xft to build sent and the farbfeld[0] tools installed to use -images in your presentations. +You need Xlib and Xft to build sent, the farbfeld[0] tools installed to use +images in your presentations and cairo to compile pdf's. Demo @@ -40,6 +40,7 @@ with `#` will be ignored. A `\` at the beginning of the line escapes `@` and - Xlib - Xft - farbfeld + - cairo sent FILENAME one slide per paragraph diff --git a/config.def.h b/config.def.h index 60eb376..26c01b4 100644 --- a/config.def.h +++ b/config.def.h @@ -47,6 +47,7 @@ static Shortcut shortcuts[] = { { XK_n, advance, {.i = +1} }, { XK_p, advance, {.i = -1} }, { XK_r, reload, {0} }, + { XK_g, pdf, {0} }, }; static Filter filters[] = { @@ -7,14 +7,17 @@ VERSION = 1 PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man +PKG_CONFIG = pkg-config + X11INC = /usr/X11R6/include X11LIB = /usr/X11R6/lib # includes and libs INCS = -I. -I/usr/include -I/usr/include/freetype2 -I${X11INC} -LIBS = -L/usr/lib -lc -lm -L${X11LIB} -lXft -lfontconfig -lX11 +LIBS = -L/usr/lib -lc -lm -L${X11LIB} -lXft -lfontconfig -lX11 -lcairo # OpenBSD (uncomment) -#INCS = -I. -I${X11INC} -I${X11INC}/freetype2 +INCS = -I. -I${X11INC} -I${X11INC}/freetype2 `${PKG_CONFIG} --cflags cairo` +LIBS += -L/usr/local/lib # FreeBSD (uncomment) #INCS = -I. -I/usr/local/include -I/usr/local/include/freetype2 -I${X11INC} #LIBS = -L/usr/local/lib -lc -lm -L${X11LIB} -lXft -lfontconfig -lX11 @@ -20,6 +20,10 @@ #include <X11/Xft/Xft.h> #include <X11/cursorfont.h> +#include <cairo/cairo.h> +#include <cairo/cairo-xlib.h> +#include <cairo/cairo-pdf.h> + #include "arg.h" #include "util.h" #include "drw.h" @@ -98,6 +102,7 @@ static void cleanup(int slidesonly); static void reload(const Arg *arg); static void load(FILE *fp); static void advance(const Arg *arg); +static void pdf(); static void toggle_cursor(const Arg *arg); static void quit(const Arg *arg); static void resize(int width, int height); @@ -541,6 +546,42 @@ void toggle_cursor(const Arg *arg) } void +pdf() +{ + const Arg next = { .i = 1 }; + Arg first; + cairo_surface_t *cs; + + if (!fname) + fname = "slides"; + + char filename[strlen(fname) + 5]; + sprintf(filename, "%s.pdf", fname); + cairo_surface_t *pdf = cairo_pdf_surface_create(filename, xw.w, xw.h); + + cairo_t *cr = cairo_create(pdf); + + first.i = -idx; + advance(&first); + + cs = cairo_xlib_surface_create(xw.dpy, xw.win, xw.vis, xw.w, xw.h); + cairo_set_source_surface(cr, cs, 0.0, 0.0); + for (int i = 0; i < slidecount; ++i) { + cairo_paint(cr); + cairo_show_page(cr); + cairo_surface_flush(cs); + advance(&next); + cairo_surface_mark_dirty(cs); + } + cairo_surface_destroy(cs); + + cairo_destroy(cr); + cairo_surface_destroy(pdf); + first.i = -(slidecount-1); + advance(&first); +} + +void quit(const Arg *arg) { running = 0; |