diff options
author | June McEnroe <june@causal.agency> | 2018-11-21 23:41:15 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-11-21 23:41:15 -0500 |
commit | 49f804e989885f1ad5fc2d2127b285ea34edb3b8 (patch) | |
tree | 28eda7556502c1382d0bf134e5f3c8bcb7a52b62 /bin/edi/edi.h | |
parent | Fix freeing empty buffer block (diff) | |
download | src-49f804e989885f1ad5fc2d2127b285ea34edb3b8.tar.gz src-49f804e989885f1ad5fc2d2127b285ea34edb3b8.zip |
Add Iter for edi
Diffstat (limited to '')
-rw-r--r-- | bin/edi/edi.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/bin/edi/edi.h b/bin/edi/edi.h index d8b1846b..62214e5d 100644 --- a/bin/edi/edi.h +++ b/bin/edi/edi.h @@ -17,11 +17,15 @@ #include <stdlib.h> #include <wchar.h> -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; |