aboutsummaryrefslogtreecommitdiff
path: root/text-objects.c
diff options
context:
space:
mode:
Diffstat (limited to 'text-objects.c')
-rw-r--r--text-objects.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/text-objects.c b/text-objects.c
index 4063992..bce8b5b 100644
--- a/text-objects.c
+++ b/text-objects.c
@@ -41,6 +41,19 @@ Filerange text_object_word(Text *txt, size_t pos) {
return r;
}
+Filerange text_object_line(Text *txt, size_t pos) {
+ char c;
+ Filerange r;
+ r.start = text_line_begin(txt, pos);
+ Iterator it = text_iterator_get(txt, text_line_end(txt, pos));
+ if (text_iterator_byte_get(&it, &c) && c == '\n')
+ text_iterator_byte_next(&it, NULL);
+ if (text_iterator_byte_get(&it, &c) && c == '\r')
+ text_iterator_byte_next(&it, NULL);
+ r.end = it.pos;
+ return r;
+}
+
Filerange text_object_sentence(Text *txt, size_t pos) {
Filerange r;
r.start = text_sentence_prev(txt, pos);