diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-10 11:46:59 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-10 11:46:59 +0200 |
| commit | 18aa993466ab857b2a56612dabd243992e987998 (patch) | |
| tree | 4e7d4ca1df42eb25ed65bea36894595766e7b22f /text-motions.h | |
| parent | deca6f4d03d36e4980715ae6709f244f381b1175 (diff) | |
| download | vis-18aa993466ab857b2a56612dabd243992e987998.tar.gz vis-18aa993466ab857b2a56612dabd243992e987998.tar.xz | |
Add comments where appropriate
Diffstat (limited to 'text-motions.h')
| -rw-r--r-- | text-motions.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/text-motions.h b/text-motions.h index 81b5b61..84f6ecc 100644 --- a/text-motions.h +++ b/text-motions.h @@ -1,15 +1,22 @@ #ifndef TEXT_MOTIONS_H #define TEXT_MOTIONS_H +/* these function all take a position in bytes from the start of the file, + * perform a certain movement and return the new postion. if the movement + * is not possible the original position is returned unchanged. */ + #include <stddef.h> #include "text.h" size_t text_begin(Text*, size_t pos); size_t text_end(Text*, size_t pos); +/* move to start of next / previous UTF-8 character */ size_t text_char_next(Text*, size_t pos); size_t text_char_prev(Text*, size_t pos); +/* find the given substring either in forward or backward direction. + * does not wrap around at file start / end. */ size_t text_find_char_next(Text*, size_t pos, const char *s, size_t len); size_t text_find_char_prev(Text*, size_t pos, const char *s, size_t len); @@ -25,9 +32,9 @@ size_t text_line_finish(Text*, size_t pos); size_t text_line_end(Text*, size_t pos); size_t text_line_next(Text*, size_t pos); /* - * A word consists of a sequence of non-blank characters, separated with white space. - * TODO?: An empty line is also considered to be a word. This is equivalant to a WORD - * in vim terminology. + * A word consists of a sequence of non-blank characters, separated with white + * space. TODO?: An empty line is also considered to be a word. + * This is equivalant to a WORD in vim terminology. */ size_t text_word_end_next(Text*, size_t pos); size_t text_word_end_prev(Text*, size_t pos); @@ -35,8 +42,8 @@ size_t text_word_start_next(Text*, size_t pos); size_t text_word_start_prev(Text*, size_t pos); /* * These are variants of the above with the additional possibility to implement - * a custom word detection logic. Can be used to implment the equivalent of a what - * vim reconizes as a word (lowercase). + * a custom word detection logic. Can be used to implment the equivalent of a + * what vim reconizes as a word (lowercase). */ size_t text_word_boundry_end_next(Text*, size_t pos, int (*isboundry)(int)); size_t text_word_boundry_end_prev(Text*, size_t pos, int (*isboundry)(int)); @@ -65,6 +72,8 @@ size_t text_section_prev(Text*, size_t pos); /* search coresponding '(', ')', '{', '}', '[', ']', '>', '<', '"', ''' */ size_t text_bracket_match(Text*, size_t pos); +/* search the given regex pattern in either forward or backward direction, + * starting from pos. does wrap around if no match was found. */ size_t text_search_forward(Text *txt, size_t pos, Regex *regex); size_t text_search_backward(Text *txt, size_t pos, Regex *regex); |
