[gtksourceview/wip/chergert/vim] track some motions that are jumps



commit f93261669b6c0c0647f6603dd4db465bc94d24a5
Author: Christian Hergert <chergert redhat com>
Date:   Thu Nov 11 14:26:39 2021 -0800

    track some motions that are jumps

 gtksourceview/vim/gtk-source-vim-motion.c | 26 +++++++++++++++++++++++++-
 gtksourceview/vim/gtk-source-vim-motion.h |  1 +
 2 files changed, 26 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-motion.c b/gtksourceview/vim/gtk-source-vim-motion.c
index 2e1bf6d0..2849809e 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.c
+++ b/gtksourceview/vim/gtk-source-vim-motion.c
@@ -112,9 +112,12 @@ struct _GtkSourceVimMotion
         */
        MotionWise wise : 1;
 
-       /* Jumping to marks */
+       /* Moving to marks */
        guint mark_charwise : 1;
        guint mark_linewise : 1;
+
+       /* If this motion is a "jump" (:help jumplist) */
+       guint is_jump : 1;
 };
 
 G_DEFINE_TYPE (GtkSourceVimMotion, gtk_source_vim_motion, GTK_SOURCE_TYPE_VIM_STATE)
@@ -1640,18 +1643,22 @@ gtk_source_vim_motion_handle_keypress (GtkSourceVimState *state,
                {
                        case GDK_KEY_parenleft:
                                self->f_char = '(';
+                               self->is_jump = TRUE;
                                return gtk_source_vim_motion_complete (self, motion_bracket, INCLUSIVE, 
CHARWISE);
 
                        case GDK_KEY_parenright:
                                self->f_char = ')';
+                               self->is_jump = TRUE;
                                return gtk_source_vim_motion_complete (self, motion_bracket, INCLUSIVE, 
CHARWISE);
 
                        case GDK_KEY_braceleft:
                                self->f_char = '{';
+                               self->is_jump = TRUE;
                                return gtk_source_vim_motion_complete (self, motion_bracket, INCLUSIVE, 
CHARWISE);
 
                        case GDK_KEY_braceright:
                                self->f_char = '}';
+                               self->is_jump = TRUE;
                                return gtk_source_vim_motion_complete (self, motion_bracket, INCLUSIVE, 
CHARWISE);
 
                        case GDK_KEY_M:
@@ -1784,6 +1791,7 @@ gtk_source_vim_motion_handle_keypress (GtkSourceVimState *state,
                        return gtk_source_vim_motion_complete (self, motion_prev_line_visual_column, 
INCLUSIVE, LINEWISE);
 
                case GDK_KEY_G:
+                       self->is_jump = TRUE;
                        if (gtk_source_vim_state_get_count_set (state))
                                return gtk_source_vim_motion_complete (self, motion_line_number, INCLUSIVE, 
LINEWISE);
                        return gtk_source_vim_motion_complete (self, motion_last_line_first_char, INCLUSIVE, 
LINEWISE);
@@ -1793,12 +1801,15 @@ gtk_source_vim_motion_handle_keypress (GtkSourceVimState *state,
                        return TRUE;
 
                case GDK_KEY_H:
+                       self->is_jump = TRUE;
                        return gtk_source_vim_motion_complete (self, motion_screen_top, INCLUSIVE, LINEWISE);
 
                case GDK_KEY_M:
+                       self->is_jump = TRUE;
                        return gtk_source_vim_motion_complete (self, motion_screen_middle, INCLUSIVE, 
LINEWISE);
 
                case GDK_KEY_L:
+                       self->is_jump = TRUE;
                        return gtk_source_vim_motion_complete (self, motion_screen_bottom, INCLUSIVE, 
LINEWISE);
 
                case GDK_KEY_w:
@@ -1850,12 +1861,14 @@ gtk_source_vim_motion_handle_keypress (GtkSourceVimState *state,
                        return gtk_source_vim_motion_complete (self, motion_backward_search_word, INCLUSIVE, 
CHARWISE);
 
                case GDK_KEY_n:
+                       self->is_jump = TRUE;
                        if (gtk_source_vim_state_get_reverse_search (GTK_SOURCE_VIM_STATE (self)))
                                return gtk_source_vim_motion_complete (self, motion_prev_search, INCLUSIVE, 
CHARWISE);
                        else
                                return gtk_source_vim_motion_complete (self, motion_next_search, INCLUSIVE, 
CHARWISE);
 
                case GDK_KEY_N:
+                       self->is_jump = TRUE;
                        if (gtk_source_vim_state_get_reverse_search (GTK_SOURCE_VIM_STATE (self)))
                                return gtk_source_vim_motion_complete (self, motion_next_search, INCLUSIVE, 
CHARWISE);
                        else
@@ -1870,13 +1883,16 @@ gtk_source_vim_motion_handle_keypress (GtkSourceVimState *state,
                        return TRUE;
 
                case GDK_KEY_percent:
+                       self->is_jump = TRUE;
                        return gtk_source_vim_motion_complete (self, motion_matching_char, EXCLUSIVE, 
CHARWISE);
 
                case GDK_KEY_grave:
+                       self->is_jump = TRUE;
                        self->mark_charwise = TRUE;
                        return TRUE;
 
                case GDK_KEY_apostrophe:
+                       self->is_jump = TRUE;
                        self->mark_linewise = TRUE;
                        return TRUE;
 
@@ -2347,6 +2363,14 @@ gtk_source_vim_motion_is_linewise (GtkSourceVimMotion *self)
        return self->wise == LINEWISE;
 }
 
+gboolean
+gtk_source_vim_motion_is_jump (GtkSourceVimMotion *self)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_VIM_MOTION (self), FALSE);
+
+       return self->is_jump;
+}
+
 GtkSourceVimState *
 gtk_source_vim_motion_new_down (int alter_count)
 {
diff --git a/gtksourceview/vim/gtk-source-vim-motion.h b/gtksourceview/vim/gtk-source-vim-motion.h
index 1eb8eb11..fd199c3c 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.h
+++ b/gtksourceview/vim/gtk-source-vim-motion.h
@@ -54,6 +54,7 @@ gboolean           gtk_source_vim_motion_apply                     (GtkSourceVim
                                                                     gboolean            apply_inclusive);
 gboolean           gtk_source_vim_motion_invalidates_visual_column (GtkSourceVimMotion *self);
 gboolean           gtk_source_vim_motion_is_linewise               (GtkSourceVimMotion *self);
+gboolean           gtk_source_vim_motion_is_jump                   (GtkSourceVimMotion *self);
 
 gboolean gtk_source_vim_iter_backward_block_brace_start   (GtkTextIter       *iter);
 gboolean gtk_source_vim_iter_backward_block_bracket_start (GtkTextIter       *iter);


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