diff options
| -rw-r--r-- | text-objects.c | 13 | ||||
| -rw-r--r-- | text-objects.h | 1 |
2 files changed, 14 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); diff --git a/text-objects.h b/text-objects.h index 211e4e6..5b3895d 100644 --- a/text-objects.h +++ b/text-objects.h @@ -8,6 +8,7 @@ * 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_line(Text*, size_t pos); Filerange text_object_sentence(Text*, size_t pos); Filerange text_object_paragraph(Text*, size_t pos); |
