[evince/390-to-move-to-the-next-prev-line-using-the-caret-cursor-loops-on-the-same-page-in-non-continous-mode: 339/340] ev-view.c: fix caret cursor navigation in non-continuous mode



commit 836f787a6bf9d2131d0a9959c6802f4fe0c2b048
Author: Nelson Benítez León <nbenitezl gmail com>
Date:   Mon Sep 3 23:33:16 2018 +0100

    ev-view.c: fix caret cursor navigation in non-continuous mode
    
    Allow to go to next/prev page when reaching end/start of page
    in non-continuous mode.
    
    Fixes issue #390

 libview/ev-view.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 919b4a00..023f779d 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -6502,6 +6502,7 @@ ev_view_move_cursor (EvView         *view,
        gint            prev_offset;
        gint            prev_page;
        cairo_region_t *damage_region;
+       gboolean        changed_page;
        gboolean        clear_selections = FALSE;
        const gboolean  forward = count >= 0;
 
@@ -6578,6 +6579,26 @@ ev_view_move_cursor (EvView         *view,
        if (!get_caret_cursor_area (view, view->cursor_page, view->cursor_offset, &rect))
                return TRUE;
 
+       if (!view->continuous) {
+               changed_page = FALSE;
+               if (prev_page < view->cursor_page) {
+                       ev_view_next_page (view);
+                       cursor_go_to_page_start (view);
+                       changed_page = TRUE;
+               } else if (prev_page > view->cursor_page) {
+                       ev_view_previous_page (view);
+                       cursor_go_to_page_end (view);
+                       ensure_rectangle_is_visible (view, &rect);
+                       changed_page = TRUE;
+               }
+
+               if (changed_page) {
+                       g_signal_emit (view, signals[SIGNAL_CURSOR_MOVED], 0, view->cursor_page, 
view->cursor_offset);
+                       clear_selection (view);
+                       return TRUE;
+               }
+       }
+
        if (step == GTK_MOVEMENT_DISPLAY_LINES) {
                const gint prev_cursor_offset = view->cursor_offset;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]