From a33a0b64b84eabb2335e667972143c32901cbf26 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Tue, 9 Apr 2013 22:32:14 +0430 Subject: [PATCH] fbpdf: o command now sets current page number The behavior of o command has been changed: instead of setting the first page, it overrides current page number. Also I have removed -o for now. --- README | 12 ++++++------ fbpdf.c | 13 +++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/README b/README index 332b124..5050186 100644 --- a/README +++ b/README @@ -10,15 +10,15 @@ can compile it using "make fbpdf". See the Makefile for other targets. The following options can be specified when starting fbpdf (or fbdjvu and fbpdf2): - fbpdf [-r rotation] [-z zoom x10] [-p page] [-o first page] filename + fbpdf [-r rotation] [-z zoom x10] [-p page] filename KEYS ==== -The following table describes fbpdf keybinding. Most of these -commands accept a numerical prefix. For instance, '^F' tells -fbpdf to go to the next page while '5^F' tells it to move to -the fifth next page. +The following table describes the commands available in fbpdf. +Most of these commands accept a numerical prefix. For instance, +'^F' tells fbpdf to go to the next page while '5^F' tells it to +move to the fifth next page. ============== ================================================ KEY ACTION @@ -26,7 +26,7 @@ KEY ACTION ^F/J next page ^B/K previous page G goto page (goto the last page if no prefix) -o set first page ('5G' after '3o' goes to page 8) +o set current page number (for 'G' command only) z set zoom multiplied by 10 (i.e. '15z' = 150%) r set rotation in degrees i print info diff --git a/fbpdf.c b/fbpdf.c index 3adf31e..8ea7a8e 100644 --- a/fbpdf.c +++ b/fbpdf.c @@ -31,17 +31,17 @@ static struct doc *doc; static fbval_t pbuf[PDFROWS * PDFCOLS]; /* current page */ static int prows, pcols; /* the dimensions of current page */ -static int num = 1; static struct termios termios; static char filename[256]; static int mark[128]; /* mark page number */ static int mark_head[128]; /* mark head position */ +static int num = 1; /* page number */ +static int numdiff; /* G command page number difference */ static int zoom = 15; static int rotate; static int head; static int left; static int count; -static int first; /* first_page - 1 */ static void draw(void) { @@ -195,7 +195,7 @@ static void mainloop(void) break; case 'G': setmark('\''); - showpage(getcount(doc_pages(doc) - first) + first, 0); + showpage(getcount(doc_pages(doc) - numdiff) + numdiff, 0); break; case 'z': zoom_page(getcount(15)); @@ -235,7 +235,7 @@ static void mainloop(void) jmpmark(readkey(), c == '`'); break; case 'o': - first = getcount(1) - 1; + numdiff = num - getcount(num); break; default: if (isdigit(c)) @@ -296,7 +296,7 @@ static void mainloop(void) } static char *usage = - "usage: fbpdf [-r rotation] [-z zoom x10] [-p page] [-o first page] filename\n"; + "usage: fbpdf [-r rotation] [-z zoom x10] [-p page] filename\n"; int main(int argc, char *argv[]) { @@ -322,9 +322,6 @@ int main(int argc, char *argv[]) case 'p': num = atoi(argv[i][2] ? argv[i] + 2 : argv[++i]); break; - case 'o': - first = atoi(argv[i][2] ? argv[i] + 2 : argv[++i]) - 1; - break; } } printf("\x1b[?25l"); /* hide the cursor */ -- 2.11.4.GIT