Sent Patches
This commit is contained in:
parent
5141a63d1e
commit
ce7c88f10e
|
@ -0,0 +1,55 @@
|
|||
diff --git a/config.def.h b/config.def.h
|
||||
index 60eb376..b6cf8b6 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -47,6 +47,8 @@ static Shortcut shortcuts[] = {
|
||||
{ XK_n, advance, {.i = +1} },
|
||||
{ XK_p, advance, {.i = -1} },
|
||||
{ XK_r, reload, {0} },
|
||||
+ { XK_bracketleft, beginning, {0} },
|
||||
+ { XK_bracketright,end, {0} },
|
||||
};
|
||||
|
||||
static Filter filters[] = {
|
||||
diff --git a/sent.c b/sent.c
|
||||
index c50a572..84f9b67 100644
|
||||
--- a/sent.c
|
||||
+++ b/sent.c
|
||||
@@ -97,6 +97,8 @@ static void cleanup(int slidesonly);
|
||||
static void reload(const Arg *arg);
|
||||
static void load(FILE *fp);
|
||||
static void advance(const Arg *arg);
|
||||
+static void beginning(const Arg *arg);
|
||||
+static void end(const Arg *arg);
|
||||
static void quit(const Arg *arg);
|
||||
static void resize(int width, int height);
|
||||
static void run();
|
||||
@@ -475,6 +477,28 @@ advance(const Arg *arg)
|
||||
}
|
||||
}
|
||||
|
||||
+void
|
||||
+beginning(const Arg *arg)
|
||||
+{
|
||||
+ if (idx != 0) {
|
||||
+ if (slides[idx].img)
|
||||
+ slides[idx].img->state &= ~SCALED;
|
||||
+ idx = 0;
|
||||
+ xdraw();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+end(const Arg *arg)
|
||||
+{
|
||||
+ if (idx != slidecount-1) {
|
||||
+ if (slides[idx].img)
|
||||
+ slides[idx].img->state &= ~SCALED;
|
||||
+ idx = slidecount-1;
|
||||
+ xdraw();
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void
|
||||
quit(const Arg *arg)
|
||||
{
|
|
@ -0,0 +1,80 @@
|
|||
diff -u sent/config.def.h sent-pdf/config.def.h
|
||||
--- sent/config.def.h 2020-05-12 20:32:04.628425521 +0200
|
||||
+++ sent-pdf/config.def.h 2020-05-23 16:04:44.927236722 +0200
|
||||
@@ -47,6 +47,7 @@
|
||||
{ XK_n, advance, {.i = +1} },
|
||||
{ XK_p, advance, {.i = -1} },
|
||||
{ XK_r, reload, {0} },
|
||||
+ { XK_g, pdf, {0} },
|
||||
};
|
||||
|
||||
static Filter filters[] = {
|
||||
diff -u sent/config.mk sent-pdf/config.mk
|
||||
--- sent/config.mk 2020-05-12 20:32:04.628425521 +0200
|
||||
+++ sent-pdf/config.mk 2020-05-23 16:04:44.927236722 +0200
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
# 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
|
||||
# FreeBSD (uncomment)
|
||||
diff -u sent/sent.c sent-pdf/sent.c
|
||||
--- sent/sent.c 2020-05-23 16:05:29.244073472 +0200
|
||||
+++ sent-pdf/sent.c 2020-05-23 16:04:44.928237147 +0200
|
||||
@@ -19,6 +19,10 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
+#include <cairo/cairo.h>
|
||||
+#include <cairo/cairo-xlib.h>
|
||||
+#include <cairo/cairo-pdf.h>
|
||||
+
|
||||
#include "arg.h"
|
||||
#include "util.h"
|
||||
#include "drw.h"
|
||||
@@ -97,6 +101,7 @@
|
||||
static void reload(const Arg *arg);
|
||||
static void load(FILE *fp);
|
||||
static void advance(const Arg *arg);
|
||||
+static void pdf();
|
||||
static void quit(const Arg *arg);
|
||||
static void resize(int width, int height);
|
||||
static void run();
|
||||
@@ -476,6 +481,34 @@
|
||||
}
|
||||
|
||||
void
|
||||
+pdf()
|
||||
+{
|
||||
+ const Arg next = { .i = 1 };
|
||||
+ const Arg first = { .i = -(slidecount-1) };
|
||||
+ cairo_surface_t *cs;
|
||||
+
|
||||
+ char filename[20];
|
||||
+ sprintf(filename, "%s.pdf", fname);
|
||||
+ cairo_surface_t *pdf = cairo_pdf_surface_create(filename, xw.w, xw.h);
|
||||
+
|
||||
+ cairo_t *cr = cairo_create(pdf);
|
||||
+
|
||||
+ idx = -1;
|
||||
+ for (int i = 0; i < slidecount; ++i) {
|
||||
+ cs = cairo_xlib_surface_create(xw.dpy, xw.win, xw.vis, xw.w, xw.h);
|
||||
+ advance(&next);
|
||||
+ cairo_set_source_surface(cr, cs, 0.0, 0.0);
|
||||
+ cairo_paint(cr);
|
||||
+ cairo_show_page(cr);
|
||||
+ cairo_surface_destroy(cs);
|
||||
+ }
|
||||
+
|
||||
+ cairo_destroy(cr);
|
||||
+ cairo_surface_destroy(pdf);
|
||||
+ advance(&first);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
quit(const Arg *arg)
|
||||
{
|
||||
running = 0;
|
Loading…
Reference in New Issue