mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-13 07:33:47 +01:00
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:
parent
012e6de85a
commit
de0d0fb4e0
@ -66,6 +66,7 @@ char* uri_command = "firefox %s"; /* uri */
|
|||||||
|
|
||||||
/* additional settings */
|
/* additional settings */
|
||||||
gboolean show_scrollbars = FALSE;
|
gboolean show_scrollbars = FALSE;
|
||||||
|
gboolean scroll_wrap = FALSE;
|
||||||
int adjust_open = ADJUST_BESTFIT;
|
int adjust_open = ADJUST_BESTFIT;
|
||||||
#define SELECTION_STYLE POPPLER_SELECTION_GLYPH
|
#define SELECTION_STYLE POPPLER_SELECTION_GLYPH
|
||||||
#define GOTO_MODE GOTO_LABELS /* GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET */
|
#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_darkcolor", &(recolor_darkcolor), 's', FALSE, TRUE, "Recoloring (dark color)"},
|
||||||
{"recolor_lightcolor", &(recolor_lightcolor), 's', FALSE, TRUE, "Recoloring (light color)"},
|
{"recolor_lightcolor", &(recolor_lightcolor), 's', FALSE, TRUE, "Recoloring (light color)"},
|
||||||
{"scroll_step", &(scroll_step), 'f', FALSE, FALSE, "Scroll step"},
|
{"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"},
|
{"scrollbars", &(show_scrollbars), 'b', FALSE, TRUE, "Show scrollbars"},
|
||||||
{"show_statusbar", &(Zathura.Global.show_statusbar), 'b', FALSE, TRUE, "Show statusbar"},
|
{"show_statusbar", &(Zathura.Global.show_statusbar), 'b', FALSE, TRUE, "Show statusbar"},
|
||||||
{"show_inputbar", &(Zathura.Global.show_inputbar), 'b', FALSE, TRUE, "Show inputbar"},
|
{"show_inputbar", &(Zathura.Global.show_inputbar), 'b', FALSE, TRUE, "Show inputbar"},
|
||||||
|
17
zathura.c
17
zathura.c
@ -2092,9 +2092,12 @@ sc_navigate(Argument* argument)
|
|||||||
int new_page = Zathura.PDF.page_number;
|
int new_page = Zathura.PDF.page_number;
|
||||||
|
|
||||||
if(argument->n == NEXT)
|
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)
|
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);
|
set_page(new_page);
|
||||||
update_status();
|
update_status();
|
||||||
@ -2172,12 +2175,16 @@ sc_scroll(Argument* argument)
|
|||||||
|
|
||||||
if((argument->n == UP || argument->n == HALF_UP || argument->n == FULL_UP) && value == 0)
|
if((argument->n == UP || argument->n == HALF_UP || argument->n == FULL_UP) && value == 0)
|
||||||
{
|
{
|
||||||
|
int old_page = Zathura.PDF.page_number;
|
||||||
Argument arg;
|
Argument arg;
|
||||||
arg.n = PREVIOUS;
|
arg.n = PREVIOUS;
|
||||||
sc_navigate(&arg);
|
sc_navigate(&arg);
|
||||||
arg.n = BOTTOM;
|
if (!scroll_wrap || (Zathura.PDF.page_number < old_page))
|
||||||
ss = TRUE;
|
{
|
||||||
sc_scroll(&arg);
|
arg.n = BOTTOM;
|
||||||
|
ss = TRUE;
|
||||||
|
sc_scroll(&arg);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if((argument->n == DOWN || argument->n == HALF_DOWN || argument->n == FULL_DOWN) && value == max)
|
else if((argument->n == DOWN || argument->n == HALF_DOWN || argument->n == FULL_DOWN) && value == max)
|
||||||
|
Loading…
Reference in New Issue
Block a user