diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-14 10:34:39 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-14 10:34:39 +0200 |
| commit | 6b7a6dce18c88b4b8977679e9179a5d1af525c60 (patch) | |
| tree | 222aced794311227b576fe84c8a0d576f3bb68e9 /text.h | |
| parent | 7338b80cc8d6eb2e49f6559d1ede9b7f6714808d (diff) | |
| download | vis-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.h | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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); |
