aboutsummaryrefslogtreecommitdiff
path: root/editor.h
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-07-21 13:23:41 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-07-21 13:23:41 +0200
commit39f545e518d22b8f9e792902675e69e7592b806a (patch)
tree5541511d3463ae2b85e8dcedc653391a7d93778f /editor.h
parent67d8948f37e59b9206e27070d91c7e368c099aae (diff)
downloadvis-39f545e518d22b8f9e792902675e69e7592b806a.tar.gz
vis-39f545e518d22b8f9e792902675e69e7592b806a.tar.xz
Add iterator functions to walk through text
Diffstat (limited to 'editor.h')
-rw-r--r--editor.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/editor.h b/editor.h
index 1273d6f..bde4da9 100644
--- a/editor.h
+++ b/editor.h
@@ -1,6 +1,13 @@
#include <stdbool.h>
typedef struct Editor Editor;
+typedef struct Piece Piece;
+
+typedef struct {
+ const char const *text;
+ /* const */ size_t len;
+ const Piece const *piece;
+} Iterator;
typedef bool (*iterator_callback_t)(void *, size_t pos, const char *content, size_t len);
@@ -11,7 +18,10 @@ bool editor_replace(Editor*, size_t pos, char *c);
void editor_snapshot(Editor*);
bool editor_undo(Editor*);
bool editor_redo(Editor*);
-//char *editor_get(Editor*, size_t pos, size_t len);
+Iterator editor_iterator_get(Editor*, size_t pos);
+bool editor_iterator_valid(const Iterator*);
+void editor_iterator_next(Iterator*);
+void editor_iterator_prev(Iterator*);
void editor_iterate(Editor*, void *, size_t pos, iterator_callback_t);
bool editor_modified(Editor*);
int editor_save(Editor*, const char *file);