diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2011-09-04 04:01:58 +0200 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2011-09-17 15:08:05 +0200 |
commit | d08f215e7d44fc521ae514316a429b755f864003 (patch) | |
tree | 19417279fe2648bc3b66e42d87936d61c14e978e /apps | |
parent | c6959b1074f7a80a2c0d16697a3544c627d9b978 (diff) | |
download | mupdf-d08f215e7d44fc521ae514316a429b755f864003.tar.xz |
Implement backwards search in viewer.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/pdfapp.c | 34 | ||||
-rw-r--r-- | apps/pdfapp.h | 1 |
2 files changed, 29 insertions, 6 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 6292b039..6e0b465b 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -700,6 +700,16 @@ void pdfapp_onkey(pdfapp_t *app, int c) if (n > 0) { winrepaintsearch(app); + + if (app->searchdir < 0) + { + if (app->pageno == 1) + app->pageno = app->pagecount; + else + app->pageno--; + pdfapp_showpage(app, 1, 1, 0); + } + pdfapp_onkey(app, 'n'); } else @@ -736,10 +746,6 @@ void pdfapp_onkey(pdfapp_t *app, int c) switch (c) { - case '?': - winhelp(app); - break; - case 'q': winclose(app); break; @@ -925,8 +931,18 @@ void pdfapp_onkey(pdfapp_t *app, int c) * Searching */ + case '?': + app->isediting = 1; + app->searchdir = -1; + app->search[0] = 0; + app->hit = -1; + app->hitlen = 0; + winrepaintsearch(app); + break; + case '/': app->isediting = 1; + app->searchdir = 1; app->search[0] = 0; app->hit = -1; app->hitlen = 0; @@ -934,12 +950,18 @@ void pdfapp_onkey(pdfapp_t *app, int c) break; case 'n': - pdfapp_searchforward(app, &panto); + if (app->searchdir > 0) + pdfapp_searchforward(app, &panto); + else + pdfapp_searchbackward(app, &panto); loadpage = 0; break; case 'N': - pdfapp_searchbackward(app, &panto); + if (app->searchdir > 0) + pdfapp_searchbackward(app, &panto); + else + pdfapp_searchforward(app, &panto); loadpage = 0; break; diff --git a/apps/pdfapp.h b/apps/pdfapp.h index 732d637c..a3829b3e 100644 --- a/apps/pdfapp.h +++ b/apps/pdfapp.h @@ -81,6 +81,7 @@ struct pdfapp_s /* search state */ int isediting; + int searchdir; char search[512]; int hit; int hitlen; |