From a61192c3149faf2d024e80ee603c6047984d4512 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Mon, 14 Jun 2010 17:13:18 +0200 Subject: [PATCH] Introduced page-wise scrolling It is now possible to scroll one page or an half page up or down. --- config.def.h | 4 ++++ zathura.1 | 12 ++++++++++++ zathura.c | 11 ++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index bd48a9e..d44425f 100644 --- a/config.def.h +++ b/config.def.h @@ -69,6 +69,10 @@ Shortcut shortcuts[] = { {GDK_CONTROL_MASK, GDK_q, sc_quit, -1, {0} }, {GDK_CONTROL_MASK, GDK_c, sc_abort, -1, {0} }, {GDK_CONTROL_MASK, GDK_i, sc_recolor, NORMAL, {0} }, + {GDK_CONTROL_MASK, GDK_d, sc_scroll, NORMAL, { HALF_DOWN } }, + {GDK_CONTROL_MASK, GDK_u, sc_scroll, NORMAL, { HALF_UP } }, + {GDK_CONTROL_MASK, GDK_f, sc_scroll, NORMAL, { FULL_DOWN } }, + {GDK_CONTROL_MASK, GDK_b, sc_scroll, NORMAL, { FULL_UP } }, {0, GDK_slash, sc_focus_inputbar, NORMAL, { .data = "/" } }, {GDK_SHIFT_MASK, GDK_slash, sc_focus_inputbar, NORMAL, { .data = "/" } }, {GDK_SHIFT_MASK, GDK_question, sc_focus_inputbar, NORMAL, { .data = "?" } }, diff --git a/zathura.1 b/zathura.1 index 4646e78..52d690e 100644 --- a/zathura.1 +++ b/zathura.1 @@ -27,6 +27,18 @@ Scroll upwards .B j Scroll downwards .TP +.B ^f +Scroll page down +.TP +.B ^b +Scroll page up +.TP +.B ^d +Scroll half a page down +.TP +.B ^u +Scroll half a page up +.TP .B l Scroll to the right .TP diff --git a/zathura.c b/zathura.c index fde3b0d..4eddd03 100644 --- a/zathura.c +++ b/zathura.c @@ -27,7 +27,8 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, FORWARD, BACKWARD, ADJUST_BESTFIT, ADJUST_WIDTH, ADJUST_NONE, CONTINUOUS, DELETE_LAST, ADD_MARKER, EVAL_MARKER, INDEX, EXPAND, COLLAPSE, SELECT, - GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET, FULLSCREEN }; + GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET, FULLSCREEN, + HALF_UP, HALF_DOWN, FULL_UP, FULL_DOWN }; /* typedefs */ struct CElement @@ -1615,6 +1616,14 @@ sc_scroll(Argument* argument) arg.n = NEXT; sc_navigate(&arg); } + else if(argument->n == FULL_UP) + gtk_adjustment_set_value(adjustment, (value - view_size) < 0 ? 0 : (value - view_size)); + else if(argument->n == FULL_DOWN) + gtk_adjustment_set_value(adjustment, (value + view_size) > max ? max : (value + view_size)); + else if(argument->n == HALF_UP) + gtk_adjustment_set_value(adjustment, (value - (view_size / 2)) < 0 ? 0 : (value - (view_size / 2))); + else if(argument->n == HALF_DOWN) + gtk_adjustment_set_value(adjustment, (value + (view_size / 2)) > max ? max : (value + (view_size / 2))); else if((argument->n == LEFT) || (argument->n == UP)) gtk_adjustment_set_value(adjustment, (value - SCROLL_STEP) < 0 ? 0 : (value - SCROLL_STEP)); else if(argument->n == TOP)