diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-05-27 16:51:15 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-05-27 16:51:15 +0200 |
commit | 11a208aa2e60954aef668c03d199808347d38c26 (patch) | |
tree | 574cb750dd2d8d9212d405f0c415ea2f3025fa3e | |
parent | 9b79a247b765d4d3344c9c34fb49d47dee2d3ae5 (diff) | |
download | mupdf-11a208aa2e60954aef668c03d199808347d38c26.tar.xz |
Change command line options to x11 viewer.
-rw-r--r-- | apps/pdfapp.c | 47 | ||||
-rw-r--r-- | apps/pdfapp.h | 5 | ||||
-rw-r--r-- | apps/x11_main.c | 24 | ||||
-rw-r--r-- | debian/mupdf.1 | 14 |
4 files changed, 48 insertions, 42 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 73589e7f..a271f25f 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -2,6 +2,8 @@ #include <mupdf.h> #include "pdfapp.h" +#define ZOOMSTEP 1.142857 + enum panning { DONT_PAN = 0, @@ -56,7 +58,7 @@ void pdfapp_init(pdfapp_t *app) memset(app, 0, sizeof(pdfapp_t)); app->scrw = 640; app->scrh = 480; - app->zoom = 1.0; + app->resolution = 72; } void pdfapp_open(pdfapp_t *app, char *filename, int fd) @@ -126,10 +128,10 @@ void pdfapp_open(pdfapp_t *app, char *filename, int fd) app->pageno = 1; if (app->pageno > app->pagecount) app->pageno = app->pagecount; - if (app->zoom < 0.1) - app->zoom = 0.1; - if (app->zoom > 3.0) - app->zoom = 3.0; + if (app->resolution < MINRES) + app->resolution = MINRES; + if (app->resolution > MAXRES) + app->resolution = MAXRES; app->rotate = 0; app->panx = 0; app->pany = 0; @@ -172,7 +174,7 @@ static fz_matrix pdfapp_viewctm(pdfapp_t *app) fz_matrix ctm; ctm = fz_identity(); ctm = fz_concat(ctm, fz_translate(0, -app->page->mediabox.y1)); - ctm = fz_concat(ctm, fz_scale(app->zoom, -app->zoom)); + ctm = fz_concat(ctm, fz_scale(app->resolution/72.0, -app->resolution/72.0)); ctm = fz_concat(ctm, fz_rotate(app->rotate + app->page->rotate)); return ctm; } @@ -211,6 +213,10 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage) fz_bbox bbox; fz_obj *obj; + sprintf(buf, "%s - %d/%d (%d dpi)", app->doctitle, + app->pageno, app->pagecount, app->resolution); + wintitle(app, buf); + if (loadpage) { wincursor(app, WAIT); @@ -225,10 +231,6 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage) error = pdf_loadpage(&app->page, app->xref, obj); if (error) pdfapp_error(app, error); - - sprintf(buf, "%s - %d/%d", app->doctitle, - app->pageno, app->pagecount); - wintitle(app, buf); } if (drawpage) @@ -350,15 +352,15 @@ void pdfapp_onkey(pdfapp_t *app, int c) case '+': case '=': - app->zoom += 0.1; - if (app->zoom > 3.0) - app->zoom = 3.0; + app->resolution *= ZOOMSTEP; + if (app->resolution > MAXRES) + app->resolution = MAXRES; pdfapp_showpage(app, 0, 1); break; case '-': - app->zoom -= 0.1; - if (app->zoom < 0.1) - app->zoom = 0.1; + app->resolution /= ZOOMSTEP; + if (app->resolution < MINRES) + app->resolution = MINRES; pdfapp_showpage(app, 0, 1); break; case '<': @@ -574,11 +576,14 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta if (modifiers & (1<<2)) { /* zoom in/out if ctrl is pressed */ - app->zoom += 0.1 * dir; - if (app->zoom > 3.0) - app->zoom = 3.0; - if (app->zoom < 0.1) - app->zoom = 0.1; + if (dir > 0) + app->resolution *= ZOOMSTEP; + else + app->resolution /= ZOOMSTEP; + if (app->resolution > MAXRES) + app->resolution = MAXRES; + if (app->resolution < MINRES) + app->resolution = MINRES; pdfapp_showpage(app, 0, 1); } else diff --git a/apps/pdfapp.h b/apps/pdfapp.h index 37f11895..db355fe3 100644 --- a/apps/pdfapp.h +++ b/apps/pdfapp.h @@ -4,6 +4,9 @@ * uses a number of callbacks to the GUI app. */ +#define MINRES 54 +#define MAXRES 300 + typedef struct pdfapp_s pdfapp_t; enum { ARROW, HAND, WAIT }; @@ -30,7 +33,7 @@ struct pdfapp_s fz_glyphcache *cache; /* current view params */ - float zoom; + int resolution; int rotate; fz_pixmap *image; fz_textspan *text; diff --git a/apps/x11_main.c b/apps/x11_main.c index 7478d4d9..1a8304dc 100644 --- a/apps/x11_main.c +++ b/apps/x11_main.c @@ -500,7 +500,7 @@ static void onmouse(int x, int y, int btn, int modifiers, int state) static void usage(void) { - fprintf(stderr, "usage: mupdf [-d password] [-z zoom%%] [-p pagenumber] file.pdf\n"); + fprintf(stderr, "usage: mupdf [-p password] [-r resolution] file.pdf [page]\n"); exit(1); } @@ -554,34 +554,36 @@ int main(int argc, char **argv) KeySym keysym; int oldx = 0; int oldy = 0; - int zoom = 100; + int resolution = 72; int pageno = 1; int wasshowingpage; struct timeval tmo, tmo_at; int closing; int fd; - while ((c = fz_getopt(argc, argv, "d:z:p:")) != -1) + while ((c = fz_getopt(argc, argv, "p:r:")) != -1) { switch (c) { - case 'd': password = fz_optarg; break; - case 'z': zoom = atoi(fz_optarg); break; - case 'p': pageno = atoi(fz_optarg); break; + case 'p': password = fz_optarg; break; + case 'r': resolution = atoi(fz_optarg); break; default: usage(); } } - if (zoom < 100) - zoom = 100; - if (zoom > 300) - zoom = 300; + if (resolution < MINRES) + resolution = MINRES; + if (resolution > MAXRES) + resolution = MAXRES; if (argc - fz_optind == 0) usage(); filename = argv[fz_optind++]; + if (argc - fz_optind == 1) + pageno = atoi(argv[fz_optind++]); + fz_cpudetect(); fz_accelerate(); @@ -590,7 +592,7 @@ int main(int argc, char **argv) pdfapp_init(&gapp); gapp.scrw = DisplayWidth(xdpy, xscr); gapp.scrh = DisplayHeight(xdpy, xscr); - gapp.zoom = zoom / 100.0; + gapp.resolution = resolution; gapp.pageno = pageno; fd = open(filename, O_BINARY | O_RDONLY, 0666); diff --git a/debian/mupdf.1 b/debian/mupdf.1 index 118804d3..13ba77fe 100644 --- a/debian/mupdf.1 +++ b/debian/mupdf.1 @@ -13,17 +13,13 @@ command. .SH OPTIONS A description of each of the supported options is included below. .TP -.B \-z percentage -Changes the initial zoom percentage from the default 100%. The allowed -range is 10%-300%. -.TP -.B \-d password -Uses the given password during decryption of an encrypted PDF file. +.B \-p password +Uses the given password to open an encrypted PDF file. The password is tried both as user and owner password. .TP -.B \-p page -Show the given page number instead of the first page of the PDF file when -opening the MuPDF window. +.B \-r resolution +Changes the initial zoom level, specified as the resolution in dpi. +The default value is 72. .SH MOUSE AND KEY BINDINGS In addition to the key bindings described below, the mouse can also be used. Clicking the left mouse button follows links within the PDF while |