Implement wrap-around scrolling (closes #44)

Applied a modified version of raylu's patch. One can enable/disable wrap-around
scrolling with `set scroll_wrap 1/0". It's disabled per default.
This commit is contained in:
Sebastian Ramacher 2010-10-31 10:11:25 +01:00
parent 06c9f742a9
commit 454b356f37
2 changed files with 14 additions and 5 deletions

View File

@ -66,6 +66,7 @@ char* uri_command = "firefox %s"; /* uri */
/* additional settings */
gboolean show_scrollbars = FALSE;
gboolean scroll_wrap = FALSE;
int adjust_open = ADJUST_BESTFIT;
#define SELECTION_STYLE POPPLER_SELECTION_GLYPH
#define GOTO_MODE GOTO_LABELS /* GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET */
@ -245,6 +246,7 @@ Setting settings[] = {
{"recolor_darkcolor", &(recolor_darkcolor), 's', FALSE, TRUE, "Recoloring (dark color)"},
{"recolor_lightcolor", &(recolor_lightcolor), 's', FALSE, TRUE, "Recoloring (light color)"},
{"scroll_step", &(scroll_step), 'f', FALSE, FALSE, "Scroll step"},
{"scroll_wrap", &(scroll_wrap), 'b', FALSE, FALSE, "Wrap scolling at last page"},
{"scrollbars", &(show_scrollbars), 'b', FALSE, TRUE, "Show scrollbars"},
{"show_statusbar", &(Zathura.Global.show_statusbar), 'b', FALSE, TRUE, "Show statusbar"},
{"show_inputbar", &(Zathura.Global.show_inputbar), 'b', FALSE, TRUE, "Show inputbar"},

View File

@ -2092,9 +2092,12 @@ sc_navigate(Argument* argument)
int new_page = Zathura.PDF.page_number;
if(argument->n == NEXT)
new_page = (new_page + number_of_pages + 1) % number_of_pages;
new_page = scroll_wrap ? (new_page + 1) : ((new_page + 1) % number_of_pages);
else if(argument->n == PREVIOUS)
new_page = (new_page + number_of_pages - 1) % number_of_pages;
new_page = scroll_wrap ? (new_page - 1) : ((new_page + number_of_pages - 1) % number_of_pages);
if (scroll_wrap && (new_page < 0 || new_page >= number_of_pages))
return;
set_page(new_page);
update_status();
@ -2172,12 +2175,16 @@ sc_scroll(Argument* argument)
if((argument->n == UP || argument->n == HALF_UP || argument->n == FULL_UP) && value == 0)
{
int old_page = Zathura.PDF.page_number;
Argument arg;
arg.n = PREVIOUS;
sc_navigate(&arg);
arg.n = BOTTOM;
ss = TRUE;
sc_scroll(&arg);
if (!scroll_wrap || (Zathura.PDF.page_number < old_page))
{
arg.n = BOTTOM;
ss = TRUE;
sc_scroll(&arg);
}
return;
}
else if((argument->n == DOWN || argument->n == HALF_DOWN || argument->n == FULL_DOWN) && value == max)