From 6b7a6dce18c88b4b8977679e9179a5d1af525c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 14 Sep 2014 10:34:39 +0200 Subject: 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. --- text.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'text.h') 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); -- cgit v1.2.3