[gnome-builder] libide: add full word movements forwards and backwards



commit b48f75fc84d5d1834fc8a33d728c6eb9a3179e35
Author: Christian Hergert <christian hergert me>
Date:   Wed Mar 4 21:00:01 2015 -0800

    libide: add full word movements forwards and backwards

 libide/ide-source-view-movements.c |   85 +++++++++++++++++++++++++++++++++++-
 libide/ide-source-view.h           |    6 ++-
 2 files changed, 89 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-source-view-movements.c b/libide/ide-source-view-movements.c
index 5e2dec4..d924413 100644
--- a/libide/ide-source-view-movements.c
+++ b/libide/ide-source-view-movements.c
@@ -748,6 +748,20 @@ ide_source_view_movements_next_word_end (IdeSourceView         *self,
 }
 
 static void
+ide_source_view_movements_next_full_word_end (IdeSourceView         *self,
+                                              IdeSourceViewMovement  movement,
+                                              gboolean               extend_selection,
+                                              gint                   param)
+{
+  GtkTextIter insert;
+  GtkTextIter selection;
+
+  ide_source_view_movements_get_selection (self, &insert, &selection);
+  _ide_source_iter_forward_full_word_end (&insert);
+  ide_source_view_movements_select_range (self, &insert, &selection, extend_selection);
+}
+
+static void
 ide_source_view_movements_next_word_start (IdeSourceView         *self,
                                            IdeSourceViewMovement  movement,
                                            gboolean               extend_selection,
@@ -758,7 +772,7 @@ ide_source_view_movements_next_word_start (IdeSourceView         *self,
 
   ide_source_view_movements_get_selection (self, &insert, &selection);
 
-  if (!_ide_source_iter_ends_full_word (&insert))
+  if (!_ide_source_iter_ends_word (&insert))
     _ide_source_iter_forward_visible_word_end (&insert);
 
   _ide_source_iter_forward_visible_word_end (&insert);
@@ -768,6 +782,26 @@ ide_source_view_movements_next_word_start (IdeSourceView         *self,
 }
 
 static void
+ide_source_view_movements_next_full_word_start (IdeSourceView         *self,
+                                                IdeSourceViewMovement  movement,
+                                                gboolean               extend_selection,
+                                                gint                   param)
+{
+  GtkTextIter insert;
+  GtkTextIter selection;
+
+  ide_source_view_movements_get_selection (self, &insert, &selection);
+
+  if (!_ide_source_iter_ends_full_word (&insert))
+    _ide_source_iter_forward_full_word_end (&insert);
+
+  _ide_source_iter_forward_full_word_end (&insert);
+  _ide_source_iter_backward_full_word_start (&insert);
+
+  ide_source_view_movements_select_range (self, &insert, &selection, extend_selection);
+}
+
+static void
 ide_source_view_movements_previous_word_start (IdeSourceView         *self,
                                                IdeSourceViewMovement  movement,
                                                gboolean               extend_selection,
@@ -782,6 +816,20 @@ ide_source_view_movements_previous_word_start (IdeSourceView         *self,
 }
 
 static void
+ide_source_view_movements_previous_full_word_start (IdeSourceView         *self,
+                                                    IdeSourceViewMovement  movement,
+                                                    gboolean               extend_selection,
+                                                    gint                   param)
+{
+  GtkTextIter insert;
+  GtkTextIter selection;
+
+  ide_source_view_movements_get_selection (self, &insert, &selection);
+  _ide_source_iter_backward_full_word_start (&insert);
+  ide_source_view_movements_select_range (self, &insert, &selection, extend_selection);
+}
+
+static void
 ide_source_view_movements_previous_word_end (IdeSourceView         *self,
                                              IdeSourceViewMovement  movement,
                                              gboolean               extend_selection,
@@ -799,6 +847,25 @@ ide_source_view_movements_previous_word_end (IdeSourceView         *self,
 }
 
 static void
+ide_source_view_movements_previous_full_word_end (IdeSourceView         *self,
+                                                  IdeSourceViewMovement  movement,
+                                                  gboolean               extend_selection,
+                                                  gint                   param)
+{
+  GtkTextIter insert;
+  GtkTextIter selection;
+
+  ide_source_view_movements_get_selection (self, &insert, &selection);
+
+  if (!_ide_source_iter_starts_full_word (&insert))
+    _ide_source_iter_backward_full_word_start (&insert);
+  _ide_source_iter_backward_full_word_start (&insert);
+  _ide_source_iter_forward_full_word_end (&insert);
+
+  ide_source_view_movements_select_range (self, &insert, &selection, extend_selection);
+}
+
+static void
 ide_source_view_movements_paragraph_start (IdeSourceView         *self,
                                           IdeSourceViewMovement  movement,
                                           gboolean               extend_selection,
@@ -917,6 +984,22 @@ _ide_source_view_apply_movement (IdeSourceView         *self,
       ide_source_view_movements_last_char (self, movement, extend_selection, param);
       break;
 
+    case IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_FULL_WORD_START:
+      ide_source_view_movements_previous_full_word_start (self, movement, extend_selection, param);
+      break;
+
+    case IDE_SOURCE_VIEW_MOVEMENT_NEXT_FULL_WORD_START:
+      ide_source_view_movements_next_full_word_start (self, movement, extend_selection, param);
+      break;
+
+    case IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_FULL_WORD_END:
+      ide_source_view_movements_previous_full_word_end (self, movement, extend_selection, param);
+      break;
+
+    case IDE_SOURCE_VIEW_MOVEMENT_NEXT_FULL_WORD_END:
+      ide_source_view_movements_next_full_word_end (self, movement, extend_selection, param);
+      break;
+
     case IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_WORD_START:
       ide_source_view_movements_previous_word_start (self, movement, extend_selection, param);
       break;
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index 4e12a16..9ea17cb 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -108,11 +108,15 @@ typedef enum
   IDE_SOURCE_VIEW_MOVEMENT_MIDDLE_CHAR,
   IDE_SOURCE_VIEW_MOVEMENT_LAST_CHAR,
 
-  IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_WORD_START,
   IDE_SOURCE_VIEW_MOVEMENT_NEXT_WORD_START,
+  IDE_SOURCE_VIEW_MOVEMENT_NEXT_FULL_WORD_START,
+  IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_WORD_START,
+  IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_FULL_WORD_START,
 
   IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_WORD_END,
+  IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_FULL_WORD_END,
   IDE_SOURCE_VIEW_MOVEMENT_NEXT_WORD_END,
+  IDE_SOURCE_VIEW_MOVEMENT_NEXT_FULL_WORD_END,
 
   IDE_SOURCE_VIEW_MOVEMENT_SENTANCE_START,
   IDE_SOURCE_VIEW_MOVEMENT_SENTANCE_END,


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