vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 9e95d92481bd22dc90e4f8983eb194414d05b95a parent c6d186a60b11c0cf7f6da86fed6f6a293c0d0177 Author: Marc André Tanner <mat@brain-dump.org> Date: Sun, 31 Aug 2014 11:07:01 +0200 Expose various text objects with individual functions Diffstat:
| M | text-objects.c | | | 30 | +++++++++++++++++++++++++++++- |
| M | text-objects.h | | | 13 | +++++++++---- |
2 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/text-objects.c b/text-objects.c @@ -55,7 +55,7 @@ Filerange text_object_paragraph(Text *txt, size_t pos) { return r; } -Filerange text_object_bracket(Text *txt, size_t pos, char type) { +static Filerange text_object_bracket(Text *txt, size_t pos, char type) { char c, open, close; int opened = 1, closed = 1; @@ -105,3 +105,31 @@ Filerange text_object_bracket(Text *txt, size_t pos, char type) { return empty; return r; } + +Filerange text_object_square_bracket(Text *txt, size_t pos) { + return text_object_bracket(txt, pos, ']'); +} + +Filerange text_object_curly_bracket(Text *txt, size_t pos) { + return text_object_bracket(txt, pos, '}'); +} + +Filerange text_object_angle_bracket(Text *txt, size_t pos) { + return text_object_bracket(txt, pos, '>'); +} + +Filerange text_object_paranthese(Text *txt, size_t pos) { + return text_object_bracket(txt, pos, ')'); +} + +Filerange text_object_quote(Text *txt, size_t pos) { + return text_object_bracket(txt, pos, '"'); +} + +Filerange text_object_single_quote(Text *txt, size_t pos) { + return text_object_bracket(txt, pos, '\''); +} + +Filerange text_object_backtick(Text *txt, size_t pos) { + return text_object_bracket(txt, pos, '`'); +} diff --git a/text-objects.h b/text-objects.h @@ -8,11 +8,16 @@ * be a whitespace include all neighbouring leading whitespaces and the following word. */ Filerange text_object_word(Text*, size_t pos); Filerange text_object_word_boundry(Text*, size_t pos, int (*isboundry)(int)); -Filerange text_object_char(Text*, size_t pos, char c); Filerange text_object_sentence(Text*, size_t pos); Filerange text_object_paragraph(Text*, size_t pos); -/* range delimited by either (), {}, [], <>, ", '. the delimiters themself are not - * included in the range */ -Filerange text_object_bracket(Text*, size_t pos, char type); + +/* the delimiters themself are not included in the range */ +Filerange text_object_square_bracket(Text*, size_t pos); +Filerange text_object_curly_bracket(Text*, size_t pos); +Filerange text_object_angle_bracket(Text*, size_t pos); +Filerange text_object_paranthese(Text*, size_t pos); +Filerange text_object_quote(Text*, size_t pos); +Filerange text_object_single_quote(Text*, size_t pos); +Filerange text_object_backtick(Text*, size_t pos); #endif