[gtksourceview/wip/chergert/vim: 296/363] add some checks for blocks




commit f6c6f494df8c1a5cb5991ebad10d6f1a76685184
Author: Christian Hergert <chergert redhat com>
Date:   Thu Nov 4 22:53:42 2021 -0700

    add some checks for blocks

 gtksourceview/vim/gtk-source-vim-text-object.c | 32 +++++++++++++++++++-------
 1 file changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-text-object.c b/gtksourceview/vim/gtk-source-vim-text-object.c
index 29ea3f97..312a3267 100644
--- a/gtksourceview/vim/gtk-source-vim-text-object.c
+++ b/gtksourceview/vim/gtk-source-vim-text-object.c
@@ -56,6 +56,22 @@ gtk_source_vim_iter_always_false (const GtkTextIter *iter)
        return FALSE;
 }
 
+#define DEFINE_ITER_CHECK(name, char)                 \
+static gboolean                                       \
+gtk_source_vim_iter_##name (const GtkTextIter *iter)  \
+{                                                     \
+       return gtk_text_iter_get_char (iter) == char; \
+}
+DEFINE_ITER_CHECK (starts_paren, '(')
+DEFINE_ITER_CHECK (ends_paren, ')')
+DEFINE_ITER_CHECK (starts_brace, '{')
+DEFINE_ITER_CHECK (ends_brace, '}')
+DEFINE_ITER_CHECK (starts_bracket, '[')
+DEFINE_ITER_CHECK (ends_bracket, ']')
+DEFINE_ITER_CHECK (starts_lt_gt, '<')
+DEFINE_ITER_CHECK (ends_lt_gt, '>')
+#undef DEFINE_ITER_CHECK
+
 static inline gboolean
 iter_isspace (const GtkTextIter *iter)
 {
@@ -187,10 +203,10 @@ TEXT_OBJECT_CTOR (inner_word, ends_word, starts_word, forward_word_end, backward
 TEXT_OBJECT_CTOR (inner_WORD, always_false, starts_WORD, forward_WORD_end, backward_WORD_start, word, INNER);
 TEXT_OBJECT_CTOR (inner_sentence, always_false, always_false, forward_sentence_end, backward_sentence_start, 
sentence, INNER);
 TEXT_OBJECT_CTOR (inner_paragraph, always_false, always_false, forward_paragraph_end, 
backward_paragraph_start, paragraph, INNER);
-TEXT_OBJECT_CTOR (inner_block_paren, always_false, always_false, forward_block_paren_end, 
backward_block_paren_start, one, INNER);
-TEXT_OBJECT_CTOR (inner_block_brace, always_false, always_false, forward_block_brace_end, 
backward_block_brace_start, one, INNER);
-TEXT_OBJECT_CTOR (inner_block_bracket, always_false, always_false, forward_block_bracket_end, 
backward_block_bracket_start, one, INNER);
-TEXT_OBJECT_CTOR (inner_block_lt_gt, always_false, always_false, forward_block_lt_gt_end, 
backward_block_lt_gt_start, one, INNER);
+TEXT_OBJECT_CTOR (inner_block_paren, ends_paren, starts_paren, forward_block_paren_end, 
backward_block_paren_start, one, INNER);
+TEXT_OBJECT_CTOR (inner_block_brace, ends_brace, starts_brace, forward_block_brace_end, 
backward_block_brace_start, one, INNER);
+TEXT_OBJECT_CTOR (inner_block_bracket, ends_bracket, starts_bracket, forward_block_bracket_end, 
backward_block_bracket_start, one, INNER);
+TEXT_OBJECT_CTOR (inner_block_lt_gt, ends_lt_gt, starts_lt_gt, forward_block_lt_gt_end, 
backward_block_lt_gt_start, one, INNER);
 TEXT_OBJECT_CTOR (inner_quote_double, ends_quote_double, always_false, forward_quote_double, 
backward_quote_double, one, INNER);
 TEXT_OBJECT_CTOR (inner_quote_single, ends_quote_single, always_false, forward_quote_single, 
backward_quote_single, one, INNER);
 TEXT_OBJECT_CTOR (inner_quote_grave, ends_quote_grave, always_false, forward_quote_grave, 
backward_quote_grave, one, INNER);
@@ -199,10 +215,10 @@ TEXT_OBJECT_CTOR (a_word, ends_word, starts_word, forward_word_end, backward_wor
 TEXT_OBJECT_CTOR (a_WORD, ends_WORD, starts_WORD, forward_WORD_end, backward_WORD_start, word, A);
 TEXT_OBJECT_CTOR (a_sentence, always_false, always_false, forward_sentence_end, backward_sentence_start, 
sentence, A);
 TEXT_OBJECT_CTOR (a_paragraph, always_false, always_false, forward_paragraph_end, backward_paragraph_start, 
paragraph, A);
-TEXT_OBJECT_CTOR (a_block_paren, always_false, always_false, forward_block_paren_end, 
backward_block_paren_start, one, A);
-TEXT_OBJECT_CTOR (a_block_brace, always_false, always_false, forward_block_brace_end, 
backward_block_brace_start, one, A);
-TEXT_OBJECT_CTOR (a_block_bracket, always_false, always_false, forward_block_bracket_end, 
backward_block_bracket_start, one, A);
-TEXT_OBJECT_CTOR (a_block_lt_gt, always_false, always_false, forward_block_lt_gt_end, 
backward_block_lt_gt_start, one, A);
+TEXT_OBJECT_CTOR (a_block_paren, ends_paren, starts_paren, forward_block_paren_end, 
backward_block_paren_start, one, A);
+TEXT_OBJECT_CTOR (a_block_brace, ends_brace, starts_brace, forward_block_brace_end, 
backward_block_brace_start, one, A);
+TEXT_OBJECT_CTOR (a_block_bracket, ends_bracket, starts_bracket, forward_block_bracket_end, 
backward_block_bracket_start, one, A);
+TEXT_OBJECT_CTOR (a_block_lt_gt, ends_lt_gt, starts_lt_gt, forward_block_lt_gt_end, 
backward_block_lt_gt_start, one, A);
 TEXT_OBJECT_CTOR (a_quote_double, ends_quote_double, always_false, forward_quote_double, 
backward_quote_double, one, A);
 TEXT_OBJECT_CTOR (a_quote_single, ends_quote_single, always_false, forward_quote_single, 
backward_quote_single, one, A);
 TEXT_OBJECT_CTOR (a_quote_grave, ends_quote_grave, always_false, forward_quote_grave, backward_quote_grave, 
one, A);


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