From f67c1db3c59121e55bd6e2fddc08f350c2633ca6 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 12 Jun 2012 23:07:32 +0200 Subject: Make backspace go to the previous page in x11 viewer. --- apps/man/mupdf.1 | 4 ++-- apps/pdfapp.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/man/mupdf.1 b/apps/man/mupdf.1 index dc2dfca1..99179d69 100644 --- a/apps/man/mupdf.1 +++ b/apps/man/mupdf.1 @@ -1,4 +1,4 @@ -.TH MUPDF 1 "March 19, 2012" +.TH MUPDF 1 "June 12, 2012" .\" Please adjust this date whenever revising the manpage. .SH NAME mupdf \- MuPDF is a lightweight PDF viewer written in portable C @@ -49,7 +49,7 @@ Reload file. .B . pgdn right space Go to the next page .TP -.B , pgup left b +.B , pgup left b backspace Go to the previous page .TP .B <, > diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 2a8ae3b5..d2c28927 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -56,7 +56,7 @@ char *pdfapp_usage(pdfapp_t *app) "f\t\t-- fullscreen\n" "r\t\t-- reload file\n" ". pgdn right spc\t-- next page\n" - ", pgup left b\t-- previous page\n" + ", pgup left b bkspc\t-- previous page\n" ">\t\t-- next 10 pages\n" "<\t\t-- back 10 pages\n" "m\t\t-- mark page for snap back\n" @@ -892,6 +892,7 @@ void pdfapp_onkey(pdfapp_t *app, int c) app->pageno++; break; + case '\b': case 'b': panto = DONT_PAN; if (app->numberlen > 0) -- cgit v1.2.3 From a606f714258677688c67e9561b87cc70f9e9b6b0 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 15 Jun 2012 10:45:55 +0200 Subject: Scale page size by UserUnit in pdfinfo. --- apps/mupdfinfo.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'apps') diff --git a/apps/mupdfinfo.c b/apps/mupdfinfo.c index 6e4db812..3a1c9c39 100644 --- a/apps/mupdfinfo.c +++ b/apps/mupdfinfo.c @@ -202,6 +202,16 @@ gatherdimensions(int page, pdf_obj *pageref, pdf_obj *pageobj) bbox = pdf_to_rect(ctx, obj); + obj = pdf_dict_gets(pageobj, "UserUnit"); + if (pdf_is_real(obj)) + { + float unit = pdf_to_real(obj); + bbox.x0 *= unit; + bbox.y0 *= unit; + bbox.x1 *= unit; + bbox.y1 *= unit; + } + for (j = 0; j < dims; j++) if (!memcmp(dim[j].u.dim.bbox, &bbox, sizeof (fz_rect))) break; -- cgit v1.2.3 From b002d99ce2d6eec36e886067e87f983d7f2e0c54 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 3 Jul 2012 15:12:35 +0100 Subject: Tweak mubusy so it responds to 'pdfclean' as well as 'mupdfclean' etc. --- apps/mubusy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/mubusy.c b/apps/mubusy.c index b520d0ec..e11d488c 100644 --- a/apps/mubusy.c +++ b/apps/mubusy.c @@ -58,7 +58,7 @@ int main(int argc, char **argv) { strcpy(buf, "mupdf"); strcat(buf, tools[i].name); - if (namematch(end, start, buf)) + if (namematch(end, start, buf) || namematch(end, start, buf+2)) return tools[i].func(argc, argv); } } -- cgit v1.2.3 From f23e5052e23a42057ef2c4025a38b9fc29ccd00c Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 4 Jul 2012 16:50:36 +0100 Subject: Avoid calling pdf_array_len (and friends) in a loop. for(i = 0; i < pdf_array_len(x); i++) ... results in lots of calls to pdf_array_len. This is not what we want. --- apps/mupdfclean.c | 3 ++- apps/mupdfextract.c | 3 ++- apps/mupdfshow.c | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/mupdfclean.c b/apps/mupdfclean.c index 8eb30efe..264d8edc 100644 --- a/apps/mupdfclean.c +++ b/apps/mupdfclean.c @@ -123,8 +123,9 @@ static void retainpages(int argc, char **argv) pdf_obj *names = pdf_new_dict(ctx, 1); pdf_obj *dests = pdf_new_dict(ctx, 1); pdf_obj *names_list = pdf_new_array(ctx, 32); + int len = pdf_dict_len(olddests); - for (i = 0; i < pdf_dict_len(olddests); i++) + for (i = 0; i < len; i++) { pdf_obj *key = pdf_dict_get_key(olddests, i); pdf_obj *val = pdf_dict_get_val(olddests, i); diff --git a/apps/mupdfextract.c b/apps/mupdfextract.c index 8db6ceaf..95f27be9 100644 --- a/apps/mupdfextract.c +++ b/apps/mupdfextract.c @@ -178,7 +178,8 @@ int pdfextract_main(int argc, char **argv) if (fz_optind == argc) { - for (o = 0; o < pdf_count_objects(doc); o++) + int len = pdf_count_objects(doc); + for (o = 0; o < len; o++) showobject(o); } else diff --git a/apps/mupdfshow.c b/apps/mupdfshow.c index 252e7dc2..8e8425b0 100644 --- a/apps/mupdfshow.c +++ b/apps/mupdfshow.c @@ -142,9 +142,10 @@ static void showobject(int num, int gen) static void showgrep(char *filename) { pdf_obj *obj; - int i; + int i, len; - for (i = 0; i < pdf_count_objects(doc); i++) + len = pdf_count_objects(doc); + for (i = 0; i < len; i++) { if (doc->table[i].type == 'n' || doc->table[i].type == 'o') { -- cgit v1.2.3 From ee382eb9e03bd609bc0da95a77e7b7232d7e56d5 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 5 Jul 2012 16:56:32 +0100 Subject: Move to static inline functions from macros. Instead of using macros for min/max/abs/clamp, we move to using inline functions. These are more typesafe, and should produce equivalent code on compilers that support inline (i.e. pretty much everything we care about these days). People can always do their own macro versions if they prefer. --- apps/mudraw.c | 4 ++-- apps/mupdfclean.c | 4 ++-- apps/mupdfinfo.c | 4 ++-- apps/pdfapp.c | 16 ++++++++-------- apps/x11_image.c | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) (limited to 'apps') diff --git a/apps/mudraw.c b/apps/mudraw.c index 359b102f..4fce251d 100644 --- a/apps/mudraw.c +++ b/apps/mudraw.c @@ -406,8 +406,8 @@ static void drawrange(fz_context *ctx, fz_document *doc, char *range) epage = pagecount; } - spage = CLAMP(spage, 1, pagecount); - epage = CLAMP(epage, 1, pagecount); + spage = fz_clampi(spage, 1, pagecount); + epage = fz_clampi(epage, 1, pagecount); if (spage < epage) for (page = spage; page <= epage; page++) diff --git a/apps/mupdfclean.c b/apps/mupdfclean.c index 264d8edc..6b185668 100644 --- a/apps/mupdfclean.c +++ b/apps/mupdfclean.c @@ -87,8 +87,8 @@ static void retainpages(int argc, char **argv) if (spage > epage) page = spage, spage = epage, epage = page; - spage = CLAMP(spage, 1, pagecount); - epage = CLAMP(epage, 1, pagecount); + spage = fz_clampi(spage, 1, pagecount); + epage = fz_clampi(epage, 1, pagecount); for (page = spage; page <= epage; page++) { diff --git a/apps/mupdfinfo.c b/apps/mupdfinfo.c index 3a1c9c39..5bdf760e 100644 --- a/apps/mupdfinfo.c +++ b/apps/mupdfinfo.c @@ -921,8 +921,8 @@ showinfo(char *filename, int show, char *pagelist) if (spage > epage) page = spage, spage = epage, epage = page; - spage = CLAMP(spage, 1, pagecount); - epage = CLAMP(epage, 1, pagecount); + spage = fz_clampi(spage, 1, pagecount); + epage = fz_clampi(epage, 1, pagecount); if (allpages) printf("Retrieving info from pages %d-%d...\n", spage, epage); diff --git a/apps/pdfapp.c b/apps/pdfapp.c index d2c28927..50a89610 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -1085,10 +1085,10 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta if (app->iscopying) { app->iscopying = 0; - app->selr.x0 = MIN(app->selx, x) - app->panx + rect.x0; - app->selr.x1 = MAX(app->selx, x) - app->panx + rect.x0; - app->selr.y0 = MIN(app->sely, y) - app->pany + rect.y0; - app->selr.y1 = MAX(app->sely, y) - app->pany + rect.y0; + app->selr.x0 = fz_mini(app->selx, x) - app->panx + rect.x0; + app->selr.x1 = fz_maxi(app->selx, x) - app->panx + rect.x0; + app->selr.y0 = fz_mini(app->sely, y) - app->pany + rect.y0; + app->selr.y1 = fz_maxi(app->sely, y) - app->pany + rect.y0; winrepaint(app); if (app->selr.x0 < app->selr.x1 && app->selr.y0 < app->selr.y1) windocopy(app); @@ -1156,10 +1156,10 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta else if (app->iscopying) { - app->selr.x0 = MIN(app->selx, x) - app->panx + rect.x0; - app->selr.x1 = MAX(app->selx, x) - app->panx + rect.x0; - app->selr.y0 = MIN(app->sely, y) - app->pany + rect.y0; - app->selr.y1 = MAX(app->sely, y) - app->pany + rect.y0; + app->selr.x0 = fz_mini(app->selx, x) - app->panx + rect.x0; + app->selr.x1 = fz_maxi(app->selx, x) - app->panx + rect.x0; + app->selr.y0 = fz_mini(app->sely, y) - app->pany + rect.y0; + app->selr.y1 = fz_maxi(app->sely, y) - app->pany + rect.y0; winrepaint(app); } diff --git a/apps/x11_image.c b/apps/x11_image.c index 06764313..6392d868 100644 --- a/apps/x11_image.c +++ b/apps/x11_image.c @@ -432,10 +432,10 @@ ximage_blit(Drawable d, GC gc, for (ay = 0; ay < srch; ay += HEIGHT) { - h = MIN(srch - ay, HEIGHT); + h = fz_mini(srch - ay, HEIGHT); for (ax = 0; ax < srcw; ax += WIDTH) { - w = MIN(srcw - ax, WIDTH); + w = fz_mini(srcw - ax, WIDTH); image = next_pool_image(); -- cgit v1.2.3