aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--text-objects.c30
-rw-r--r--text-objects.h13
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