Commit 04742354 authored by Moritz Lipp's avatar Moritz Lipp

Added 'scroll-wrap' for sc_navigate

parent 81b86d8b
......@@ -89,6 +89,8 @@ config_load_default(zathura_t* zathura)
bool_value = false;
girara_setting_add(gsession, "recolor", &bool_value, BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL);
bool_value = false;
girara_setting_add(gsession, "scroll-wrap", &bool_value, BOOLEAN, false, _("Wrap scrolling"), NULL, NULL);
float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL);
bool_value = true;
......
......@@ -342,11 +342,26 @@ sc_navigate(girara_session_t* session, girara_argument_t* argument,
unsigned int number_of_pages = zathura->document->number_of_pages;
unsigned int new_page = zathura->document->current_page_number;
bool scroll_wrap = false;
girara_setting_get(session, "scroll-wrap", &scroll_wrap);
t = (t == 0) ? 1 : t;
if (argument->n == NEXT) {
new_page = (new_page + t) % number_of_pages;
if (scroll_wrap == true) {
new_page = new_page + t;
} else {
new_page = (new_page + t) % number_of_pages;
}
} else if (argument->n == PREVIOUS) {
new_page = (new_page + number_of_pages - t) % number_of_pages;
if (scroll_wrap == true) {
new_page = new_page - t;
} else {
new_page = (new_page + number_of_pages - t) % number_of_pages;
}
}
if (scroll_wrap == true && (new_page < 0 || new_page >= number_of_pages)) {
return false;
}
page_set(zathura, new_page);
......@@ -431,10 +446,11 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
}
gdouble view_size = gtk_adjustment_get_page_size(adjustment);
gdouble value = gtk_adjustment_get_value(adjustment);
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
unsigned int padding = zathura->global.page_padding;
gdouble view_size = gtk_adjustment_get_page_size(adjustment);
gdouble value = gtk_adjustment_get_value(adjustment);
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
unsigned int padding = zathura->global.page_padding;
zathura->global.update_page_number = true;
float scroll_step = 40;
......
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