Created
March 24, 2018 21:22
-
-
Save capocasa/25dcacb0fbf7e17c4c27951edf7f297b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/platform/x11/x11_main.c b/platform/x11/x11_main.c | |
index 21e3e84..3bce5aa 100644 | |
--- a/platform/x11/x11_main.c | |
+++ b/platform/x11/x11_main.c | |
@@ -96,6 +96,8 @@ static char copyutf8[1024 * 48] = ""; | |
static Time copytime; | |
static char *filename; | |
static char message[1024] = ""; | |
+static char *shadecolor = 0; | |
+static char *papercolor = 0; | |
static pdfapp_t gapp; | |
static int closing = 0; | |
@@ -129,6 +131,14 @@ static void showmessage(pdfapp_t *app, int timeout, char *msg) | |
} | |
} | |
+static int colorasrgb(const char *name, XColor *color) { | |
+ XColor dummy; | |
+ if(XAllocNamedColor(xdpy, DefaultColormap(xdpy, xscr), name, color, &dummy)) | |
+ return 1; | |
+ fprintf(stderr, "mupdf: couldn't allocate color '%s'", name); | |
+ return 0; | |
+} | |
+ | |
void winerror(pdfapp_t *app, char *msg) | |
{ | |
fprintf(stderr, "mupdf: error: %s\n", msg); | |
@@ -224,13 +234,17 @@ static void winopen(void) | |
xcwait = XCreateFontCursor(xdpy, XC_watch); | |
xccaret = XCreateFontCursor(xdpy, XC_xterm); | |
- xbgcolor.red = 0x7000; | |
- xbgcolor.green = 0x7000; | |
- xbgcolor.blue = 0x7000; | |
+ if (!papercolor || !colorasrgb(papercolor, &xbgcolor)) { | |
+ xbgcolor.red = 0x7000; | |
+ xbgcolor.green = 0x7000; | |
+ xbgcolor.blue = 0x7000; | |
+ } | |
- xshcolor.red = 0x4000; | |
- xshcolor.green = 0x4000; | |
- xshcolor.blue = 0x4000; | |
+ if (!shadecolor || !colorasrgb(shadecolor, &xshcolor)) { | |
+ xshcolor.red = 0x4000; | |
+ xshcolor.green = 0x4000; | |
+ xshcolor.blue = 0x4000; | |
+ } | |
XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xbgcolor); | |
XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xshcolor); | |
@@ -806,6 +820,8 @@ static void usage(void) | |
fprintf(stderr, "\t-H -\tpage height for EPUB layout\n"); | |
fprintf(stderr, "\t-S -\tfont size for EPUB layout\n"); | |
fprintf(stderr, "\t-U -\tuser style sheet for EPUB layout\n"); | |
+ fprintf(stderr, "\t-D -\tshade color\n"); | |
+ fprintf(stderr, "\t-P -\tpaper color\n"); | |
exit(1); | |
} | |
@@ -836,7 +852,7 @@ int main(int argc, char **argv) | |
pdfapp_init(ctx, &gapp); | |
- while ((c = fz_getopt(argc, argv, "p:r:A:C:W:H:S:U:")) != -1) | |
+ while ((c = fz_getopt(argc, argv, "p:r:A:C:W:H:S:U:D:P:")) != -1) | |
{ | |
switch (c) | |
{ | |
@@ -854,6 +870,8 @@ int main(int argc, char **argv) | |
case 'H': gapp.layout_h = fz_atof(fz_optarg); break; | |
case 'S': gapp.layout_em = fz_atof(fz_optarg); break; | |
case 'U': gapp.layout_css = fz_optarg; break; | |
+ case 'P': papercolor = fz_optarg; break; | |
+ case 'D': shadecolor = fz_optarg; break; | |
default: usage(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment