Commit 87f10baf authored by Moritz Lipp's avatar Moritz Lipp

Allow negative offsets

parent ad9edf5e
...@@ -533,7 +533,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list) ...@@ -533,7 +533,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
} }
/* no argument: take current page as offset */ /* 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 */ /* retrieve offset from argument */
if (girara_list_size(argument_list) == 1) { if (girara_list_size(argument_list) == 1) {
...@@ -547,9 +547,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list) ...@@ -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; return true;
} }
......
...@@ -47,7 +47,7 @@ struct zathura_document_s { ...@@ -47,7 +47,7 @@ struct zathura_document_s {
unsigned int rotate; /**< Rotation */ unsigned int rotate; /**< Rotation */
void* data; /**< Custom data */ void* data; /**< Custom data */
zathura_adjust_mode_t adjust_mode; /**< Adjust mode (best-fit, width) */ zathura_adjust_mode_t adjust_mode; /**< Adjust mode (best-fit, width) */
unsigned int page_offset; /**< Page offset */ int page_offset; /**< Page offset */
/** /**
* Document pages * Document pages
...@@ -365,7 +365,7 @@ zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mo ...@@ -365,7 +365,7 @@ zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mo
document->adjust_mode = mode; document->adjust_mode = mode;
} }
unsigned int int
zathura_document_get_page_offset(zathura_document_t* document) zathura_document_get_page_offset(zathura_document_t* document)
{ {
if (document == NULL) { if (document == NULL) {
...@@ -382,9 +382,7 @@ zathura_document_set_page_offset(zathura_document_t* document, unsigned int page ...@@ -382,9 +382,7 @@ zathura_document_set_page_offset(zathura_document_t* document, unsigned int page
return; return;
} }
if (page_offset < document->number_of_pages) { document->page_offset = page_offset;
document->page_offset = page_offset;
}
} }
void void
......
...@@ -143,7 +143,7 @@ void zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adju ...@@ -143,7 +143,7 @@ void zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adju
* @param document The document * @param document The document
* @return The page offset * @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 * Sets the new page offset of the document
......
...@@ -315,12 +315,9 @@ sc_goto(girara_session_t* session, girara_argument_t* argument, girara_event_t* ...@@ -315,12 +315,9 @@ sc_goto(girara_session_t* session, girara_argument_t* argument, girara_event_t*
zathura_jumplist_save(zathura); zathura_jumplist_save(zathura);
if (t != 0) { if (t != 0) {
/* add offset */ /* add offset */
unsigned int page_offset = zathura_document_get_page_offset(zathura->document); t += zathura_document_get_page_offset(zathura->document);
if (page_offset > 0) {
t += page_offset;
}
page_set(zathura, t-1); page_set(zathura, t - 1);
} else if (argument->n == TOP) { } else if (argument->n == TOP) {
page_set(zathura, 0); page_set(zathura, 0);
} else if (argument->n == BOTTOM) { } else if (argument->n == BOTTOM) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment