diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2015-07-23 14:36:51 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2015-07-23 14:36:51 +0200 |
| commit | 511337a68cf7329e08397631c48199641441d086 (patch) | |
| tree | 60e37e8c16f2bb67e710bdc63baf6dcebc81d78a | |
| parent | be21d229b92a66c61feebc9a6f12c0957b0ba5c0 (diff) | |
| download | vis-511337a68cf7329e08397631c48199641441d086.tar.gz vis-511337a68cf7329e08397631c48199641441d086.tar.xz | |
text-object: add text_range_linewise
Takes a range and extends both ends to cover the remaining part
of the line.
| -rw-r--r-- | text-objects.c | 8 | ||||
| -rw-r--r-- | text-objects.h | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/text-objects.c b/text-objects.c index 44515e1..815e36a 100644 --- a/text-objects.c +++ b/text-objects.c @@ -264,3 +264,11 @@ Filerange text_object_single_quote(Text *txt, size_t pos) { Filerange text_object_backtick(Text *txt, size_t pos) { return text_object_bracket(txt, pos, '`'); } + +Filerange text_range_linewise(Text *txt, Filerange *rin) { + Filerange rout = *rin; + rout.start = text_line_begin(txt, rin->start); + if (rin->end != text_line_begin(txt, rin->end)) + rout.end = text_line_next(txt, rin->end); + return rout; +} diff --git a/text-objects.h b/text-objects.h index a4babb5..3e08a91 100644 --- a/text-objects.h +++ b/text-objects.h @@ -32,4 +32,7 @@ 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); +/* extend a range to cover whole lines */ +Filerange text_range_linewise(Text*, Filerange*); + #endif |
