diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-08-06 11:08:04 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-08-06 13:45:08 +0200 |
| commit | bb1ca1631def9be20da34af66b11c48daab09313 (patch) | |
| tree | a2bbbd8975640073f9c95f8dc222fca97b78ab09 /text-objects.c | |
| parent | 2084b81c593cd5ebefe0d6b19dfad2c85811d0a6 (diff) | |
| download | vis-bb1ca1631def9be20da34af66b11c48daab09313.tar.gz vis-bb1ca1631def9be20da34af66b11c48daab09313.tar.xz | |
vis: implement al and il text objects
Diffstat (limited to 'text-objects.c')
| -rw-r--r-- | text-objects.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/text-objects.c b/text-objects.c index 9f646dc..a65d46c 100644 --- a/text-objects.c +++ b/text-objects.c @@ -221,6 +221,11 @@ Filerange text_object_line(Text *txt, size_t pos) { return r; } +Filerange text_object_line_inner(Text *txt, size_t pos) { + Filerange r = text_object_line(txt, pos); + return text_range_inner(txt, &r); +} + Filerange text_object_sentence(Text *txt, size_t pos) { Filerange r; r.start = text_sentence_prev(txt, pos); @@ -346,3 +351,15 @@ bool text_range_is_linewise(Text *txt, Filerange *r) { r->start == text_line_begin(txt, r->start) && r->end == text_line_begin(txt, r->end); } + +Filerange text_range_inner(Text *txt, Filerange *rin) { + char c; + Filerange r = *rin; + Iterator it = text_iterator_get(txt, rin->start); + while (text_iterator_byte_get(&it, &c) && isspace((unsigned char)c)) + text_iterator_byte_next(&it, NULL); + r.start = it.pos; + it = text_iterator_get(txt, rin->end); + do r.end = it.pos; while (text_iterator_byte_prev(&it, &c) && isspace((unsigned char)c)); + return r; +} |
