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



commit f44a2bd53f2d0f49c3377e91146d0e251c741e7e
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 a8afc789..7a071075 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -6361,6 +6361,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;
 
        if (!view->caret_enabled || view->rotation != 0)
@@ -6436,6 +6437,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) {
                position_caret_cursor_at_location (view,
                                                   MAX (rect.x, view->cursor_line_offset),


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