aboutsummaryrefslogtreecommitdiff
path: root/text.h
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-14 10:34:39 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-14 10:34:39 +0200
commit6b7a6dce18c88b4b8977679e9179a5d1af525c60 (patch)
tree222aced794311227b576fe84c8a0d576f3bb68e9 /text.h
parent7338b80cc8d6eb2e49f6559d1ede9b7f6714808d (diff)
downloadvis-6b7a6dce18c88b4b8977679e9179a5d1af525c60.tar.gz
vis-6b7a6dce18c88b4b8977679e9179a5d1af525c60.tar.xz
Make byte based iterator API handle the whole range [0, size]
Before this commit the valid range was [0, size) which represents the file content. For the position at EOF (=size) a NUL byte is returned which is not actually part of the underlying file. This should fix various movements / editing operations at the end of the file. For example Ctrl+w at the end of the command prompt.
Diffstat (limited to 'text.h')
-rw-r--r--text.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/text.h b/text.h
index 4f7c4dc..15d0ad1 100644
--- a/text.h
+++ b/text.h
@@ -56,9 +56,14 @@ bool text_iterator_valid(const Iterator*);
bool text_iterator_next(Iterator*);
bool text_iterator_prev(Iterator*);
+/* get byte at current iterator position, if this is at EOF a NUL
+ * byte (which is not actually part of the file) is read. */
bool text_iterator_byte_get(Iterator*, char *b);
-bool text_iterator_byte_next(Iterator*, char *b);
+/* advance iterator by one byte and get byte at new position. */
bool text_iterator_byte_prev(Iterator*, char *b);
+/* if the new position is at EOF a NUL byte (which is not actually
+ * part of the file) is read. */
+bool text_iterator_byte_next(Iterator*, char *b);
bool text_iterator_char_next(Iterator*, char *c);
bool text_iterator_char_prev(Iterator*, char *c);