From 87f10baffc61ef2eed68cbd437997b11d18b92b5 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Wed, 8 May 2013 18:28:32 +0200 Subject: [PATCH] Allow negative offsets --- commands.c | 6 ++---- document.c | 8 +++----- document.h | 2 +- shortcuts.c | 7 ++----- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/commands.c b/commands.c index 9551b51..38f7470 100644 --- a/commands.c +++ b/commands.c @@ -533,7 +533,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list) } /* no argument: take current page as offset */ - unsigned int page_offset = zathura_document_get_current_page_number(zathura->document); + int page_offset = zathura_document_get_current_page_number(zathura->document); /* retrieve offset from argument */ if (girara_list_size(argument_list) == 1) { @@ -547,9 +547,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list) } } - if (page_offset < zathura_document_get_number_of_pages(zathura->document)) { - zathura_document_set_page_offset(zathura->document, page_offset); - } + zathura_document_set_page_offset(zathura->document, page_offset); return true; } diff --git a/document.c b/document.c index dc69540..2e6e557 100644 --- a/document.c +++ b/document.c @@ -47,7 +47,7 @@ struct zathura_document_s { unsigned int rotate; /**< Rotation */ void* data; /**< Custom data */ zathura_adjust_mode_t adjust_mode; /**< Adjust mode (best-fit, width) */ - unsigned int page_offset; /**< Page offset */ + int page_offset; /**< Page offset */ /** * Document pages @@ -365,7 +365,7 @@ zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mo document->adjust_mode = mode; } -unsigned int +int zathura_document_get_page_offset(zathura_document_t* document) { if (document == NULL) { @@ -382,9 +382,7 @@ zathura_document_set_page_offset(zathura_document_t* document, unsigned int page return; } - if (page_offset < document->number_of_pages) { - document->page_offset = page_offset; - } + document->page_offset = page_offset; } void diff --git a/document.h b/document.h index 113344e..5f18047 100644 --- a/document.h +++ b/document.h @@ -143,7 +143,7 @@ void zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adju * @param document The document * @return The page offset */ -unsigned int zathura_document_get_page_offset(zathura_document_t* document); +int zathura_document_get_page_offset(zathura_document_t* document); /** * Sets the new page offset of the document diff --git a/shortcuts.c b/shortcuts.c index 583867f..3af1531 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -315,12 +315,9 @@ sc_goto(girara_session_t* session, girara_argument_t* argument, girara_event_t* zathura_jumplist_save(zathura); if (t != 0) { /* add offset */ - unsigned int page_offset = zathura_document_get_page_offset(zathura->document); - if (page_offset > 0) { - t += page_offset; - } + t += zathura_document_get_page_offset(zathura->document); - page_set(zathura, t-1); + page_set(zathura, t - 1); } else if (argument->n == TOP) { page_set(zathura, 0); } else if (argument->n == BOTTOM) {