4 /* these function all take a position in bytes from the start of the file,
5 * perform a certain movement and return the new postion. if the movement
6 * is not possible the original position is returned unchanged. */
11 size_t text_begin(Text
*, size_t pos
);
12 size_t text_end(Text
*, size_t pos
);
14 /* move to start of next / previous UTF-8 character */
15 size_t text_char_next(Text
*, size_t pos
);
16 size_t text_char_prev(Text
*, size_t pos
);
18 /* find the given substring either in forward or backward direction.
19 * does not wrap around at file start / end. if no match is found return
20 * original position */
21 size_t text_find_next(Text
*, size_t pos
, const char *s
);
22 size_t text_find_prev(Text
*, size_t pos
, const char *s
);
24 /* begin finish end next
26 * [\r]\n I am a line! [\r]\n
30 size_t text_line_prev(Text
*, size_t pos
);
31 size_t text_line_begin(Text
*, size_t pos
);
32 size_t text_line_start(Text
*, size_t pos
);
33 size_t text_line_finish(Text
*, size_t pos
);
34 size_t text_line_lastchar(Text
*, size_t pos
);
35 size_t text_line_end(Text
*, size_t pos
);
36 size_t text_line_next(Text
*, size_t pos
);
37 size_t text_line_offset(Text
*, size_t pos
, size_t off
);
39 * A longword consists of a sequence of non-blank characters, separated with
40 * white space. TODO?: An empty line is also considered to be a word.
41 * This is equivalant to a WORD in vim terminology.
43 size_t text_longword_end_next(Text
*, size_t pos
);
44 size_t text_longword_end_prev(Text
*, size_t pos
);
45 size_t text_longword_start_next(Text
*, size_t pos
);
46 size_t text_longword_start_prev(Text
*, size_t pos
);
48 * A word consists of a sequence of letters, digits and underscores, or a
49 * sequence of other non-blank characters, separated with white space.
50 * TODO?: An empty line is also considered to be a word.
51 * This is equivalant to a word (lowercase) in vim terminology.
53 size_t text_word_end_next(Text
*, size_t pos
);
54 size_t text_word_end_prev(Text
*, size_t pos
);
55 size_t text_word_start_next(Text
*, size_t pos
);
56 size_t text_word_start_prev(Text
*, size_t pos
);
57 /* TODO: implement the following semantics
58 * A sentence is defined as ending at a '.', '!' or '?' followed by either the
59 * end of a line, or by a space or tab. Any number of closing ')', ']', '"'
60 * and ''' characters may appear after the '.', '!' or '?' before the spaces,
61 * tabs or end of line. A paragraph and section boundary is also a sentence
64 size_t text_sentence_next(Text
*, size_t pos
);
65 size_t text_sentence_prev(Text
*, size_t pos
);
66 /* TODO: implement the following semantics
67 * A paragraph begins after each empty line. A section boundary is also a
68 * paragraph boundary. Note that a blank line (only containing white space)
69 * is NOT a paragraph boundary.
71 size_t text_paragraph_next(Text
*, size_t pos
);
72 size_t text_paragraph_prev(Text
*, size_t pos
);
73 /* A section begins after a form-feed in the first column.
74 size_t text_section_next(Text*, size_t pos);
75 size_t text_section_prev(Text*, size_t pos);
77 /* search coresponding '(', ')', '{', '}', '[', ']', '>', '<', '"', ''' */
78 size_t text_bracket_match(Text
*, size_t pos
);
79 /* same as above but ignore symbols contained in last argument */
80 size_t text_bracket_match_except(Text
*, size_t pos
, const char *except
);
82 /* search the given regex pattern in either forward or backward direction,
83 * starting from pos. does wrap around if no match was found. */
84 size_t text_search_forward(Text
*txt
, size_t pos
, Regex
*regex
);
85 size_t text_search_backward(Text
*txt
, size_t pos
, Regex
*regex
);
87 /* is c a special symbol delimiting a word? */
88 int is_word_boundry(int c
);