[gtksourceview/wip/chergert/vim: 170/363] add motion for ctrl+f/b




commit cec69dcfa3d3b0a97ccc3ef8fdd180d35d659fa0
Author: Christian Hergert <chergert redhat com>
Date:   Sat Oct 30 14:48:07 2021 -0700

    add motion for ctrl+f/b
    
    this is help from the standpoint of selections, even though it is handled
    differently in normal mode.

 gtksourceview/vim/gtk-source-vim-motion.c | 44 +++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-motion.c b/gtksourceview/vim/gtk-source-vim-motion.c
index c67424fe..56d8f8c3 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.c
+++ b/gtksourceview/vim/gtk-source-vim-motion.c
@@ -1054,6 +1054,34 @@ motion_backward_sentence_start (GtkTextIter        *iter,
        return !gtk_text_iter_equal (&before, iter);
 }
 
+static gboolean
+motion_next_scroll_page (GtkTextIter        *iter,
+                         GtkSourceVimMotion *self)
+{
+       int count = gtk_source_vim_state_get_count (GTK_SOURCE_VIM_STATE (self));
+       GtkTextBuffer *buffer = gtk_text_iter_get_buffer (iter);
+       GtkTextMark *insert = gtk_text_buffer_get_insert (buffer);
+
+       gtk_source_vim_state_scroll_page (GTK_SOURCE_VIM_STATE (self), count);
+       gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), iter, insert);
+
+       return TRUE;
+}
+
+static gboolean
+motion_prev_scroll_page (GtkTextIter        *iter,
+                         GtkSourceVimMotion *self)
+{
+       int count = gtk_source_vim_state_get_count (GTK_SOURCE_VIM_STATE (self));
+       GtkTextBuffer *buffer = gtk_text_iter_get_buffer (iter);
+       GtkTextMark *insert = gtk_text_buffer_get_insert (buffer);
+
+       gtk_source_vim_state_scroll_page (GTK_SOURCE_VIM_STATE (self), -count);
+       gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), iter, insert);
+
+       return TRUE;
+}
+
 GtkSourceVimState *
 gtk_source_vim_motion_new (void)
 {
@@ -1144,6 +1172,22 @@ gtk_source_vim_motion_handle_keypress (GtkSourceVimState *state,
                return TRUE;
        }
 
+       if ((mods & GDK_CONTROL_MASK) != 0)
+       {
+               switch (keyval)
+               {
+
+                       case GDK_KEY_f:
+                               return gtk_source_vim_motion_complete (self, motion_next_scroll_page, 
INCLUSIVE);
+
+                       case GDK_KEY_b:
+                               return gtk_source_vim_motion_complete (self, motion_prev_scroll_page, 
INCLUSIVE);
+
+                       default:
+                               break;
+               }
+       }
+
        switch (keyval)
        {
                case GDK_KEY_0:


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