vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 75d88a4aba08d2d1cb8df97512b319050376e628 parent 51749f4f4c0a1d39bc79abe3ef1f6255bfbeee7e Author: Marc André Tanner <mat@brain-dump.org> Date: Mon, 27 Jul 2015 15:08:41 +0200 text-util: add text_range_contains Diffstat:
| M | text-util.c | | | 4 | ++++ |
| M | text-util.h | | | 5 | +++-- |
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/text-util.c b/text-util.c @@ -36,3 +36,7 @@ bool text_range_overlap(Filerange *r1, Filerange *r2) { return false; return r1->start <= r2->end && r2->start <= r1->end; } + +bool text_range_contains(Filerange *r, size_t pos) { + return text_range_valid(r) && r->start <= pos && pos <= r->end; +} diff --git a/text-util.h b/text-util.h @@ -17,5 +17,7 @@ Filerange text_range_union(Filerange*, Filerange*); Filerange text_range_new(size_t a, size_t b); /* test whether two ranges overlap */ bool text_range_overlap(Filerange*, Filerange*); +/* test whether a given position is within a certain range */ +bool text_range_contains(Filerange*, size_t pos); -#endif -\ No newline at end of file +#endif