From 48d12f49be55847fd03bbeebf3a6a98c71d8f331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Knecht?= Date: Thu, 6 Dec 2012 10:57:05 +0100 Subject: [PATCH] Also wrap when scrolling with 'j' and 'k' The scroll-wrap option used to only change the behavior of 'J' and 'K' (i.e. moving one page forward/backward). Now, if scroll-wrap is true and the top of the first page is shown, pressing 'k' will show the bottom of the last page; conversely, when at the bottom of the last page, pressing 'j' will show the top of the first page. Signed-off-by: Sebastian Ramacher --- shortcuts.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/shortcuts.c b/shortcuts.c index 130f18f..59370e2 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -567,6 +567,9 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, bool scroll_page_aware = false; girara_setting_get(session, "scroll-page-aware", &scroll_page_aware); + bool scroll_wrap = false; + girara_setting_get(session, "scroll-wrap", &scroll_wrap); + int padding = 1; girara_setting_get(session, "page-padding", &padding); @@ -611,6 +614,13 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument, new_value = value; } + if (scroll_wrap == true) { + if (new_value < 0) + new_value = max; + else if (new_value > max) + new_value = 0; + } + if (scroll_page_aware == true) { int page_offset; double page_size;