[gnome-builder] libide: improve word boundaries with empty lines
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: improve word boundaries with empty lines
- Date: Mon, 23 Mar 2015 23:58:25 +0000 (UTC)
commit 462f688776023a0c31ce9d6bca9188d7ab3d023a
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 4 23:36:07 2015 -0800
libide: improve word boundaries with empty lines
libide/ide-source-view-movements.c | 60 ++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view-movements.c b/libide/ide-source-view-movements.c
index 39c8fe5..5b8547f 100644
--- a/libide/ide-source-view-movements.c
+++ b/libide/ide-source-view-movements.c
@@ -767,17 +767,27 @@ ide_source_view_movements_next_word_start (IdeSourceView *self,
gboolean extend_selection,
gint param)
{
+ GtkTextIter copy;
GtkTextIter insert;
GtkTextIter selection;
ide_source_view_movements_get_selection (self, &insert, &selection);
+ copy = insert;
+
if (_ide_source_iter_starts_word (&insert))
_ide_source_iter_forward_visible_word_end (&insert);
if (_ide_source_iter_forward_visible_word_end (&insert))
_ide_source_iter_backward_visible_word_start (&insert);
+ /*
+ * Vim treats an empty line as a word.
+ */
+ if (gtk_text_iter_forward_char (©))
+ if (gtk_text_iter_get_char (©) == '\n')
+ insert = copy;
+
ide_source_view_movements_select_range (self, &insert, &selection, extend_selection);
}
@@ -787,17 +797,27 @@ ide_source_view_movements_next_full_word_start (IdeSourceView *self,
gboolean extend_selection,
gint param)
{
+ GtkTextIter copy;
GtkTextIter insert;
GtkTextIter selection;
ide_source_view_movements_get_selection (self, &insert, &selection);
+ copy = insert;
+
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);
+ /*
+ * Vim treats an empty line as a word.
+ */
+ if (gtk_text_iter_forward_char (©))
+ if (gtk_text_iter_get_char (©) == '\n')
+ insert = copy;
+
ide_source_view_movements_select_range (self, &insert, &selection, extend_selection);
}
@@ -807,11 +827,23 @@ ide_source_view_movements_previous_word_start (IdeSourceView *self,
gboolean extend_selection,
gint param)
{
+ GtkTextIter copy;
GtkTextIter insert;
GtkTextIter selection;
ide_source_view_movements_get_selection (self, &insert, &selection);
+
+ copy = insert;
+
_ide_source_iter_backward_visible_word_start (&insert);
+
+ /*
+ * Vim treats an empty line as a word.
+ */
+ if (gtk_text_iter_backward_char (©))
+ if (gtk_text_iter_get_char (©) == '\n')
+ insert = copy;
+
ide_source_view_movements_select_range (self, &insert, &selection, extend_selection);
}
@@ -821,11 +853,23 @@ ide_source_view_movements_previous_full_word_start (IdeSourceView *self,
gboolean extend_selection,
gint param)
{
+ GtkTextIter copy;
GtkTextIter insert;
GtkTextIter selection;
ide_source_view_movements_get_selection (self, &insert, &selection);
+
+ copy = insert;
+
_ide_source_iter_backward_full_word_start (&insert);
+
+ /*
+ * Vim treats an empty line as a word.
+ */
+ if (gtk_text_iter_backward_char (©))
+ if (gtk_text_iter_get_char (©) == '\n')
+ insert = copy;
+
ide_source_view_movements_select_range (self, &insert, &selection, extend_selection);
}
@@ -835,14 +879,30 @@ ide_source_view_movements_previous_word_end (IdeSourceView *self,
gboolean extend_selection,
gint param)
{
+ GtkTextIter copy;
GtkTextIter insert;
GtkTextIter selection;
ide_source_view_movements_get_selection (self, &insert, &selection);
+ copy = insert;
+
_ide_source_iter_backward_visible_word_starts (&insert, 2);
_ide_source_iter_forward_visible_word_end (&insert);
+ /*
+ * Vim treats an empty line as a word.
+ */
+ if (gtk_text_iter_backward_char (©))
+ if (gtk_text_iter_get_char (©) == '\n')
+ insert = copy;
+
+ /*
+ * Ensure we are strictly before our previous position.
+ */
+ if (gtk_text_iter_compare (&insert, ©) > 0)
+ gtk_text_buffer_get_start_iter (gtk_text_iter_get_buffer (&insert), &insert);
+
ide_source_view_movements_select_range (self, &insert, &selection, extend_selection);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]