vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit cdb22d691a38a47e5b2d612e672f46370e6b759e parent dfa87d8aedfc6ff857d31c1b1ab0ed95df30f71a Author: Marc André Tanner <mat@brain-dump.org> Date: Thu, 23 Jul 2015 14:36:51 +0200 text-object: add text_range_linewise Takes a range and extends both ends to cover the remaining part of the line. Diffstat:
| M | text-objects.c | | | 8 | ++++++++ |
| M | text-objects.h | | | 3 | +++ |
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git 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 @@ -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