[gnome-builder] libide: add sub-word movements that match the original gtk word movements



commit ef2885d808430aad50794d23b3e24661c49ec2b2
Author: Christian Hergert <chergert redhat com>
Date:   Sat Oct 10 23:23:26 2015 -0400

    libide: add sub-word movements that match the original gtk word movements
    
    GtkSourceView changes the default word movements, which is rather
    inconvenient for Emacs folks who rely on _ being a word break. This adds
    a new movement which we can use from keybindings to move by word breaks
    which include _ as a break.

 libide/ide-source-view-movements.c |    9 +++++++++
 libide/ide-source-view.h           |    8 ++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view-movements.c b/libide/ide-source-view-movements.c
index 777e2f5..297f14e 100644
--- a/libide/ide-source-view-movements.c
+++ b/libide/ide-source-view-movements.c
@@ -1345,6 +1345,15 @@ _ide_source_view_apply_movement (IdeSourceView         *self,
         ide_source_view_movements_next_full_word_end (&mv);
       break;
 
+    case IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_SUB_WORD_START:
+      gtk_text_iter_backward_visible_word_starts (&mv.insert, MAX (1, mv.count));
+      break;
+
+    case IDE_SOURCE_VIEW_MOVEMENT_NEXT_SUB_WORD_START:
+      if (!gtk_text_iter_forward_visible_word_ends (&mv.insert, MAX (1, mv.count)))
+        gtk_text_iter_forward_to_line_end (&mv.insert);
+      break;
+
     case IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_WORD_START:
       for (i = MAX (1, mv.count); i > 0; i--)
         ide_source_view_movements_previous_word_start (&mv);
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index 4359224..5675cec 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -73,6 +73,12 @@ typedef enum
  * @IDE_SOURCE_VIEW_MOVEMENT_MIDDLE_CHAR: move to the middle character in the line.
  * @IDE_SOURCE_VIEW_MOVEMENT_LAST_CHAR: move to the last character in the line. this can be
  *   inclusve or exclusive. inclusive is equivalent to %IDE_SOURCE_VIEW_MOVEMENT_LINE_END.
+ * @IDE_SOURCE_VIEW_MOVEMENT_NEXT_SUB_WORD_START: move to the next sub-word start, similar
+ *   to the default in GtkTextView. This includes the underline character as a word break,
+ *   as is common in Emacs.
+ * @IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_SUB_WORD_START: move to the previous sub-wird start,
+ *   similar to the default in GtkTextView. This includes the underline character as a
+ *   word break, as is common in Emacs.
  * @IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_WORD_START: move to beginning of previous word.
  * @IDE_SOURCE_VIEW_MOVEMENT_NEXT_WORD_START: move to beginning of next word.
  * @IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_WORD_END: move to end of previous word.
@@ -131,6 +137,8 @@ typedef enum
 
   IDE_SOURCE_VIEW_MOVEMENT_NEXT_WORD_START,
   IDE_SOURCE_VIEW_MOVEMENT_NEXT_FULL_WORD_START,
+  IDE_SOURCE_VIEW_MOVEMENT_NEXT_SUB_WORD_START,
+  IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_SUB_WORD_START,
   IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_WORD_START,
   IDE_SOURCE_VIEW_MOVEMENT_PREVIOUS_FULL_WORD_START,
 


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