From f8da655d5b8154940540a1de62122b7639cf235e Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 21 Nov 2018 23:41:15 -0500 Subject: Add Iter for edi --- bin/edi/edi.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'bin/edi/edi.h') diff --git a/bin/edi/edi.h b/bin/edi/edi.h index 3425b235..6891b866 100644 --- a/bin/edi/edi.h +++ b/bin/edi/edi.h @@ -17,11 +17,15 @@ #include #include -static inline struct Span { +struct Span { size_t at, to; -} spanNext(struct Span span, size_t len) { +}; +static inline struct Span spanNext(struct Span span, size_t len) { return (struct Span) { span.to, span.to + len }; } +static inline struct Span spanPrev(struct Span span, size_t len) { + return (struct Span) { span.at - len, span.at }; +} struct Slice { const wchar_t *ptr; @@ -55,6 +59,17 @@ struct Table tableInsert(const struct Table *prev, size_t at, struct Slice ins); struct Table tableDelete(const struct Table *prev, struct Span del); void tableUpdate(struct Table *table, struct Slice ins); +struct Iter { + const struct Table *table; + struct Span span; + size_t slice; + size_t at; + wint_t ch; +}; +struct Iter iter(const struct Table *table, size_t at); +struct Iter iterNext(struct Iter it); +struct Iter iterPrev(struct Iter it); + struct Log { size_t cap, len; size_t state; -- cgit 1.4.1