[gnome-builder] libide: implement forward to sentence end
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: implement forward to sentence end
- Date: Mon, 23 Mar 2015 23:58:30 +0000 (UTC)
commit 0fdcd37a2a3ecae8524ad4de6e0cf82e89853c31
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 4 23:39:13 2015 -0800
libide: implement forward to sentence end
libide/ide-vim-iter.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 52 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-vim-iter.c b/libide/ide-vim-iter.c
index 81f55af..0089f4f 100644
--- a/libide/ide-vim-iter.c
+++ b/libide/ide-vim-iter.c
@@ -163,9 +163,60 @@ _ide_vim_iter_backward_sentence_end (GtkTextIter *iter)
gboolean
_ide_vim_iter_forward_sentence_end (GtkTextIter *iter)
{
+ GtkTextIter end_bounds;
+ gboolean found_para;
+
g_return_val_if_fail (iter, FALSE);
- return FALSE;
+ end_bounds = *iter;
+ found_para = _ide_vim_iter_forward_paragraph_end (&end_bounds);
+
+ if (!found_para)
+ gtk_text_buffer_get_end_iter (gtk_text_iter_get_buffer (iter), &end_bounds);
+
+ while ((gtk_text_iter_compare (iter, &end_bounds) < 0) && gtk_text_iter_forward_char (iter))
+ {
+ if (gtk_text_iter_forward_find_char (iter, sentence_end_chars, NULL, &end_bounds))
+ {
+ GtkTextIter copy = *iter;
+
+ while (gtk_text_iter_forward_char (©) && (gtk_text_iter_compare (©, &end_bounds) < 0))
+ {
+ gunichar ch;
+ gboolean invalid = FALSE;
+
+ ch = gtk_text_iter_get_char (©);
+
+ switch (ch)
+ {
+ case ']':
+ case ')':
+ case '"':
+ case '\'':
+ continue;
+
+ case ' ':
+ case '\n':
+ *iter = copy;
+ return SENTENCE_OK;
+
+ default:
+ invalid = TRUE;
+ break;
+ }
+
+ if (invalid)
+ break;
+ }
+ }
+ }
+
+ *iter = end_bounds;
+
+ if (found_para)
+ return SENTENCE_PARA;
+
+ return SENTENCE_FAILED;
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]