From fbaeffb469d2fd6833a1301255f1ac73c7226a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 31 Aug 2014 11:07:01 +0200 Subject: Expose various text objects with individual functions --- text-objects.c | 30 +++++++++++++++++++++++++++++- text-objects.h | 13 +++++++++---- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/text-objects.c b/text-objects.c index 1ac0395..4063992 100644 --- 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 index de3fdc3..211e4e6 100644 --- 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 -- cgit v1.2.3