aboutsummaryrefslogtreecommitdiff
path: root/text.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-07-27 11:56:20 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-07-28 13:21:49 +0200
commitb1302b29d9158bb62707203ea54fa5b13904ac15 (patch)
tree7816891578b604b66cdf485cf8d88f8f8c015eee /text.c
parent57ffc7e18a1ac0b44d14fd8bc61442b7651dcd02 (diff)
downloadvis-b1302b29d9158bb62707203ea54fa5b13904ac15.tar.gz
vis-b1302b29d9158bb62707203ea54fa5b13904ac15.tar.xz
text: move utility functions to separate file
Diffstat (limited to 'text.c')
-rw-r--r--text.c37
1 files changed, 1 insertions, 36 deletions
diff --git a/text.c b/text.c
index 9a1bd42..26b851d 100644
--- a/text.c
+++ b/text.c
@@ -31,6 +31,7 @@
#endif
#include "text.h"
+#include "text-util.h"
#include "util.h"
/* Allocate buffers holding the actual file content in junks of size: */
@@ -1474,39 +1475,3 @@ size_t text_history_get(Text *txt, size_t index) {
}
return EPOS;
}
-
-bool text_range_valid(Filerange *r) {
- return r->start != EPOS && r->end != EPOS && r->start <= r->end;
-}
-
-size_t text_range_size(Filerange *r) {
- return text_range_valid(r) ? r->end - r->start : 0;
-}
-
-Filerange text_range_empty(void) {
- return (Filerange){ .start = EPOS, .end = EPOS };
-}
-
-Filerange text_range_union(Filerange *r1, Filerange *r2) {
- if (!text_range_valid(r1))
- return *r2;
- if (!text_range_valid(r2))
- return *r1;
- return (Filerange) {
- .start = MIN(r1->start, r2->start),
- .end = MAX(r1->end, r2->end),
- };
-}
-
-Filerange text_range_new(size_t a, size_t b) {
- return (Filerange) {
- .start = MIN(a, b),
- .end = MAX(a, b),
- };
-}
-
-bool text_range_overlap(Filerange *r1, Filerange *r2) {
- if (!text_range_valid(r1) || !text_range_valid(r2))
- return false;
- return r1->start <= r2->end && r2->start <= r1->end;
-}