Signed-off-by: Fabienne Ducroquet <fabi...@gmail.com>
---
 src/config/actions-main.inc |    2 +
 src/viewer/action.c         |    8 ++++++
 src/viewer/text/view.c      |   51 ++++++++++++++++++++++++++++++++-----------
 src/viewer/text/view.h      |    2 +
 4 files changed, 50 insertions(+), 13 deletions(-)

diff --git a/src/config/actions-main.inc b/src/config/actions-main.inc
index 6620d3f..cb6c6bb 100644
--- a/src/config/actions-main.inc
+++ b/src/config/actions-main.inc
@@ -71,7 +71,9 @@ ACTION_(MAIN, "move-link-right-line", MOVE_LINK_RIGHT_LINE, 
N__("Move one link r
 ACTION_(MAIN, "move-link-up", MOVE_LINK_UP, N__("Move one link up"), 
ACTION_REQUIRE_VIEW_STATE),
 ACTION_(MAIN, "move-link-up-line", MOVE_LINK_UP_LINE, N__("Move to the 
previous line with a link"), ACTION_REQUIRE_VIEW_STATE),
 ACTION_(MAIN, "move-page-down", MOVE_PAGE_DOWN, N__("Move downwards by a 
page"), ACTION_REQUIRE_VIEW_STATE),
+ACTION_(MAIN, "move-half-page-down", MOVE_HALF_PAGE_DOWN, N__("Move downwards 
by half a page"), ACTION_REQUIRE_VIEW_STATE),
 ACTION_(MAIN, "move-page-up", MOVE_PAGE_UP, N__("Move upwards by a page"), 
ACTION_REQUIRE_VIEW_STATE),
+ACTION_(MAIN, "move-half-page-up", MOVE_HALF_PAGE_UP, N__("Move upwards by 
half a page"), ACTION_REQUIRE_VIEW_STATE),
 ACTION_(MAIN, "open-link-in-new-tab", OPEN_LINK_IN_NEW_TAB, N__("Open the 
current link in a new tab"), ACTION_REQUIRE_VIEW_STATE | ACTION_JUMP_TO_LINK | 
ACTION_REQUIRE_LINK),
 ACTION_(MAIN, "open-link-in-new-tab-in-background", 
OPEN_LINK_IN_NEW_TAB_IN_BACKGROUND, N__("Open the current link in a new tab in 
the background"), ACTION_REQUIRE_VIEW_STATE | ACTION_JUMP_TO_LINK | 
ACTION_REQUIRE_LINK),
 ACTION_(MAIN, "open-link-in-new-window", OPEN_LINK_IN_NEW_WINDOW, N__("Open 
the current link in a new window"), ACTION_RESTRICT_ANONYMOUS | 
ACTION_REQUIRE_VIEW_STATE | ACTION_JUMP_TO_LINK | ACTION_REQUIRE_LINK),
diff --git a/src/viewer/action.c b/src/viewer/action.c
index 66e20bb..d22db6d 100644
--- a/src/viewer/action.c
+++ b/src/viewer/action.c
@@ -408,10 +408,18 @@ do_action(struct session *ses, enum main_action 
action_id, int verbose)
                        status = move_page_down(ses, doc_view);
                        break;
 
+               case ACT_MAIN_MOVE_HALF_PAGE_DOWN:
+                       status = move_half_page_down(ses, doc_view);
+                       break;
+
                case ACT_MAIN_MOVE_PAGE_UP:
                        status = move_page_up(ses, doc_view);
                        break;
 
+               case ACT_MAIN_MOVE_HALF_PAGE_UP:
+                       status = move_half_page_up(ses, doc_view);
+                       break;
+
                case ACT_MAIN_MOVE_DOCUMENT_START:
                        status = move_document_start(ses, doc_view);
                        break;
diff --git a/src/viewer/text/view.c b/src/viewer/text/view.c
index 3a031b3..e4a9648 100644
--- a/src/viewer/text/view.c
+++ b/src/viewer/text/view.c
@@ -85,7 +85,7 @@ detach_formatted(struct document_view *doc_view)
 /*! @a type == 0 -> PAGE_DOWN;
  * @a type == 1 -> DOWN */
 static void
-move_down(struct session *ses, struct document_view *doc_view, int type)
+move_down(struct session *ses, struct document_view *doc_view, int type, int 
overlap)
 {
        int newpos;
 
@@ -94,7 +94,8 @@ move_down(struct session *ses, struct document_view 
*doc_view, int type)
 
        assert(ses->navigate_mode == NAVIGATE_LINKWISE);        /* XXX: drop it 
at some time. --Zas */
 
-       newpos = doc_view->vs->y + doc_view->box.height;
+       newpos = doc_view->vs->y + doc_view->box.height - overlap;
+
        if (newpos < doc_view->document->height)
                doc_view->vs->y = newpos;
 
@@ -109,23 +110,35 @@ move_down(struct session *ses, struct document_view 
*doc_view, int type)
        return;
 }
 
-enum frame_event_status
-move_page_down(struct session *ses, struct document_view *doc_view)
+static enum frame_event_status
+move_part_page_down(struct session *ses, struct document_view *doc_view, int 
overlap)
 {
        int oldy = doc_view->vs->y;
        int count = eat_kbd_repeat_count(ses);
 
        ses->navigate_mode = NAVIGATE_LINKWISE;
 
-       do move_down(ses, doc_view, 0); while (--count > 0);
+       do move_down(ses, doc_view, 0, overlap); while (--count > 0);
 
        return doc_view->vs->y == oldy ? FRAME_EVENT_OK : FRAME_EVENT_REFRESH;
 }
 
+enum frame_event_status
+move_page_down(struct session *ses, struct document_view *doc_view)
+{
+       return move_part_page_down(ses, doc_view, 0);
+}
+
+enum frame_event_status
+move_half_page_down(struct session *ses, struct document_view *doc_view)
+{
+       return move_part_page_down(ses, doc_view, doc_view->box.height / 2);
+}
+
 /*! @a type == 0 -> PAGE_UP;
  * @a type == 1 -> UP */
 static void
-move_up(struct session *ses, struct document_view *doc_view, int type)
+move_up(struct session *ses, struct document_view *doc_view, int type, int 
overlap)
 {
        assert(ses && doc_view && doc_view->vs);
        if_assert_failed return;
@@ -134,7 +147,8 @@ move_up(struct session *ses, struct document_view 
*doc_view, int type)
 
        if (doc_view->vs->y == 0) return;
 
-       doc_view->vs->y -= doc_view->box.height;
+       doc_view->vs->y -= (doc_view->box.height - overlap);
+
        int_lower_bound(&doc_view->vs->y, 0);
 
        if (current_link_is_visible(doc_view))
@@ -149,18 +163,29 @@ move_up(struct session *ses, struct document_view 
*doc_view, int type)
 }
 
 enum frame_event_status
-move_page_up(struct session *ses, struct document_view *doc_view)
+move_part_page_up(struct session *ses, struct document_view *doc_view, int 
overlap)
 {
        int oldy = doc_view->vs->y;
        int count = eat_kbd_repeat_count(ses);
 
        ses->navigate_mode = NAVIGATE_LINKWISE;
 
-       do move_up(ses, doc_view, 0); while (--count > 0);
+       do move_up(ses, doc_view, 0, overlap); while (--count > 0);
 
        return doc_view->vs->y == oldy ? FRAME_EVENT_OK : FRAME_EVENT_REFRESH;
 }
 
+enum frame_event_status
+move_page_up(struct session *ses, struct document_view *doc_view)
+{
+       return move_part_page_up(ses, doc_view, 0);
+}
+
+enum frame_event_status
+move_half_page_up(struct session *ses, struct document_view *doc_view)
+{
+       return move_part_page_up(ses, doc_view, doc_view->box.height / 2);
+}
 
 enum frame_event_status
 move_link(struct session *ses, struct document_view *doc_view, int direction,
@@ -216,9 +241,9 @@ move_link(struct session *ses, struct document_view 
*doc_view, int direction,
                doc_view->vs->current_link = current_link;
 
                if (direction > 0) {
-                       move_down(ses, doc_view, 1);
+                       move_down(ses, doc_view, 1, 0);
                } else {
-                       move_up(ses, doc_view, 1);
+                       move_up(ses, doc_view, 1, 0);
                }
 
                if (current_link != wraparound_bound
@@ -250,9 +275,9 @@ move_link_dir(struct session *ses, struct document_view 
*doc_view, int dir_x, in
 
                /* FIXME: This won't preserve the column! */
                if (dir_y > 0)
-                       move_down(ses, doc_view, 1);
+                       move_down(ses, doc_view, 1, 0);
                else if (dir_y < 0)
-                       move_up(ses, doc_view, 1);
+                       move_up(ses, doc_view, 1, 0);
 
                if (dir_y && current_link != doc_view->vs->current_link) {
                        set_textarea(doc_view, -dir_y);
diff --git a/src/viewer/text/view.h b/src/viewer/text/view.h
index 6bbfdc7..f7032f2 100644
--- a/src/viewer/text/view.h
+++ b/src/viewer/text/view.h
@@ -15,7 +15,9 @@ struct terminal;
 void detach_formatted(struct document_view *doc_view);
 
 enum frame_event_status move_page_down(struct session *ses, struct 
document_view *doc_view);
+enum frame_event_status move_half_page_down(struct session *ses, struct 
document_view *doc_view);
 enum frame_event_status move_page_up(struct session *ses, struct document_view 
*doc_view);
+enum frame_event_status move_half_page_up(struct session *ses, struct 
document_view *doc_view);
 enum frame_event_status move_link(struct session *ses, struct document_view 
*doc_view,
                                  int direction, int wraparound_bound, int 
wraparound_link);
 
-- 
1.7.1

_______________________________________________
elinks-dev mailing list
elinks-dev@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-dev

Reply via email to