Skip to content

Commit

Permalink
Expose various text objects with individual functions
Browse files Browse the repository at this point in the history
  • Loading branch information
martanne committed Aug 31, 2014
1 parent 0ce017c commit fbaeffb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
30 changes: 29 additions & 1 deletion text-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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, '`');
}
13 changes: 9 additions & 4 deletions text-objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fbaeffb

Please sign in to comment.