diff options
Diffstat (limited to 'txt.h')
| -rw-r--r-- | txt.h | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -33,6 +33,12 @@ typedef struct { } TxtLoc; typedef struct { + struct Txt *t; + u32 p0, i0; + u32 p1, i1; +} TxtRange; + +typedef struct { TxtPieceTbl v[TXT_HIST_MAX]; TxtLoc cur[TXT_HIST_MAX]; u32 i, n; @@ -146,4 +152,22 @@ static inline TxtLoc cprev(TxtLoc l) { return l; } +static inline TxtRange txt_range(TxtLoc a, TxtLoc b) { + ASSERT(a.t == b.t); + if (txt_before(b, a)) + return (TxtRange) { a.t, b.p, b.i, a.p, a.i }; + else + return (TxtRange) { a.t, a.p, a.i, b.p, b.i }; +} + +static inline TxtRange txt_range_incl(TxtLoc a, TxtLoc b) { + if (txt_before(b, a)) { + TxtLoc t = a; + a = b; + b = t; + } + b = cnext(b); + return (TxtRange) { a.t, a.p, a.i, b.p, b.i }; +} + #endif |
