From 37eedaef84933b53f26b3d5c416a00aa1bedeec0 Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Sun, 31 Jan 2021 11:03:01 +0100 Subject: [PATCH] Add scroll-half-page-up and scroll-half-page-down actions (#1075) Closes #531 --- doc/manual.adoc | 4 ++-- doc/tigrc.5.adoc | 6 ++++-- include/tig/request.h | 6 ++++-- src/tig.c | 2 ++ src/view.c | 6 ++++-- test/help/all-keybindings-test.expected | 4 ++-- tigrc | 8 +++++--- 7 files changed, 23 insertions(+), 13 deletions(-) diff --git a/doc/manual.adoc b/doc/manual.adoc index c8a832f92..c14c68190 100644 --- a/doc/manual.adoc +++ b/doc/manual.adoc @@ -408,10 +408,10 @@ Cursor Navigation |Key |Action |k |Move cursor one line up. |j |Move cursor one line down. -|PgUp,-,a |Move cursor one page up. +|PgUp, - |Move cursor one page up. |PgDown, Space |Move cursor one page down. -|End |Jump to last line. |Home |Jump to first line. +|End |Jump to last line. |============================================================================= [[view-scrolling]] diff --git a/doc/tigrc.5.adoc b/doc/tigrc.5.adoc index 8f41cef46..5e8b06683 100644 --- a/doc/tigrc.5.adoc +++ b/doc/tigrc.5.adoc @@ -890,10 +890,10 @@ Cursor navigation |============================================================================= |move-up |Move cursor one line up |move-down |Move cursor one line down -|move-page-down |Move cursor one page down |move-page-up |Move cursor one page up -|move-half-page-down |Move cursor half a page down +|move-page-down |Move cursor one page down |move-half-page-up |Move cursor half a page up +|move-half-page-down |Move cursor half a page down |move-first-line |Move cursor to first line |move-last-line |Move cursor to last line |move-next-merge |Move cursor to next merge commit @@ -909,6 +909,8 @@ Scrolling |scroll-line-down |Scroll one line down |scroll-page-up |Scroll one page up |scroll-page-down |Scroll one page down +|scroll-half-page-up |Scroll half a page up +|scroll-half-page-down |Scroll half a page down |scroll-first-col |Scroll to the first line columns |scroll-left |Scroll two columns left |scroll-right |Scroll two columns right diff --git a/include/tig/request.h b/include/tig/request.h index 9f439108f..bad6739c0 100644 --- a/include/tig/request.h +++ b/include/tig/request.h @@ -49,10 +49,10 @@ REQ_GROUP("Cursor navigation") \ REQ_(MOVE_UP, "Move cursor one line up"), \ REQ_(MOVE_DOWN, "Move cursor one line down"), \ - REQ_(MOVE_PAGE_DOWN, "Move cursor one page down"), \ REQ_(MOVE_PAGE_UP, "Move cursor one page up"), \ - REQ_(MOVE_HALF_PAGE_DOWN, "Move cursor half a page down"), \ + REQ_(MOVE_PAGE_DOWN, "Move cursor one page down"), \ REQ_(MOVE_HALF_PAGE_UP, "Move cursor half a page up"), \ + REQ_(MOVE_HALF_PAGE_DOWN, "Move cursor half a page down"), \ REQ_(MOVE_FIRST_LINE, "Move cursor to first line"), \ REQ_(MOVE_LAST_LINE, "Move cursor to last line"), \ REQ_(MOVE_NEXT_MERGE, "Move cursor to next merge commit"), \ @@ -63,6 +63,8 @@ REQ_(SCROLL_LINE_DOWN, "Scroll one line down"), \ REQ_(SCROLL_PAGE_UP, "Scroll one page up"), \ REQ_(SCROLL_PAGE_DOWN, "Scroll one page down"), \ + REQ_(SCROLL_HALF_PAGE_UP, "Scroll half a page up"), \ + REQ_(SCROLL_HALF_PAGE_DOWN, "Scroll half a page down"), \ REQ_(SCROLL_FIRST_COL, "Scroll to the first line columns"), \ REQ_(SCROLL_LEFT, "Scroll two columns left"), \ REQ_(SCROLL_RIGHT, "Scroll two columns right"), \ diff --git a/src/tig.c b/src/tig.c index 87c04cda2..ed4388f46 100644 --- a/src/tig.c +++ b/src/tig.c @@ -188,6 +188,8 @@ view_driver(struct view *view, enum request request) case REQ_SCROLL_LINE_UP: case REQ_SCROLL_PAGE_DOWN: case REQ_SCROLL_PAGE_UP: + case REQ_SCROLL_HALF_PAGE_DOWN: + case REQ_SCROLL_HALF_PAGE_UP: case REQ_SCROLL_WHEEL_DOWN: case REQ_SCROLL_WHEEL_UP: scroll_view(view, request); diff --git a/src/view.c b/src/view.c index ab428b0a9..31af02d98 100644 --- a/src/view.c +++ b/src/view.c @@ -134,7 +134,8 @@ scroll_view(struct view *view, enum request request) report_clear(); return; case REQ_SCROLL_PAGE_DOWN: - lines = view->height; + case REQ_SCROLL_HALF_PAGE_DOWN: + lines = request == REQ_SCROLL_PAGE_DOWN ? view->height : view->height / 2; /* Fall-through */ case REQ_SCROLL_WHEEL_DOWN: case REQ_SCROLL_LINE_DOWN: @@ -154,7 +155,8 @@ scroll_view(struct view *view, enum request request) break; case REQ_SCROLL_PAGE_UP: - lines = view->height; + case REQ_SCROLL_HALF_PAGE_UP: + lines = request == REQ_SCROLL_PAGE_UP ? view->height : view->height / 2; /* Fall-through */ case REQ_SCROLL_LINE_UP: case REQ_SCROLL_WHEEL_UP: diff --git a/test/help/all-keybindings-test.expected b/test/help/all-keybindings-test.expected index 84986272e..7b90b5ad4 100755 --- a/test/help/all-keybindings-test.expected +++ b/test/help/all-keybindings-test.expected @@ -30,10 +30,10 @@ View manipulation Cursor navigation k move-up Move cursor one line up j move-down Move cursor one line down - , move-page-down Move cursor one page down , - move-page-up Move cursor one page up - move-half-page-down Move cursor half a page down + , move-page-down Move cursor one page down move-half-page-up Move cursor half a page up + move-half-page-down Move cursor half a page down move-first-line Move cursor to first line move-last-line Move cursor to last line Scrolling diff --git a/tigrc b/tigrc index 7f7f41394..6777254d8 100644 --- a/tigrc +++ b/tigrc @@ -231,7 +231,7 @@ bind generic quit # Close all views and quit bind status u status-update # Stage/unstage changes in file bind status ! status-revert # Revert changes in file bind status M status-merge # Open git-mergetool(1) -#bind status ??? :toggle status # Show short or long status labels +# bind status ??? :toggle status # Show short or long status labels bind stage u status-update # Stage/unstage current diff (c)hunk bind stage 1 stage-update-line # Stage/unstage current line bind stage ! status-revert # Revert current diff (c)hunk @@ -270,6 +270,8 @@ bind generic scroll-line-down bind generic scroll-line-down bind generic scroll-page-up bind generic scroll-page-down +# bind generic ??? scroll-half-page-up +# bind generic ??? scroll-half-page-down # Searching bind generic / search @@ -295,9 +297,9 @@ bind generic D :toggle date # Toggle date display bind generic A :toggle author # Toggle author display bind generic ~ :toggle line-graphics # Toggle (line) graphics mode bind generic F :toggle file-name # Toggle file name display -# bind generic ??? :toogle show-changes # Toggle local changes display in the main view +# bind generic ??? :toggle show-changes # Toggle local changes display in the main view bind generic W :toggle ignore-space # Toggle ignoring whitespace in diffs -# bind generic ? :toggle commit-order # Toggle commit ordering +# bind generic ??? :toggle commit-order # Toggle commit ordering bind generic X :toggle id # Toggle commit ID display bind generic $ :toggle commit-title-overflow # Toggle highlighting of commit title overflow