Allow negative offsets

This commit is contained in:
Moritz Lipp 2013-05-08 18:28:32 +02:00
parent ad9edf5ea2
commit 87f10baffc
4 changed files with 8 additions and 15 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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) {