diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-12-05 12:05:32 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-12-16 11:28:44 -0700 |
| commit | 1d1d19ed30309b39fc5e43c830cabb4cdd004d07 (patch) | |
| tree | 56bb7c09d3b07118e39e7fc6174403b0235d56a7 /text-motions.h | |
| parent | 65dd46e0bba74948c824370a06e509cba462cd72 (diff) | |
| download | vis-1d1d19ed30309b39fc5e43c830cabb4cdd004d07.tar.gz vis-1d1d19ed30309b39fc5e43c830cabb4cdd004d07.tar.xz | |
mark all functions in headers with VIS_EXPORT or VIS_INTERNAL
if vis actually wants to be a library exported symbols may need
mark up depending on the platform (eg. __declspec(dllexport)).
This needs to be hidden behind a macro because the way you export
is not the same on every platform.
I did this based on the assumption that vis.h was supposed to be
the only interface to the "vis" library. Since nobody actually
uses vis as a library I have no idea if this is actually correct.
Anyway marking up all prototypes like this allows for one to
convert all functions to static if a single translation unit is
used by inserting at the start:
#define VIS_INTERNAL static
#define VIS_EXPORT static
Diffstat (limited to 'text-motions.h')
| -rw-r--r-- | text-motions.h | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/text-motions.h b/text-motions.h index 1cb21d8..4bfc6c2 100644 --- a/text-motions.h +++ b/text-motions.h @@ -9,24 +9,24 @@ #include "text.h" #include "text-regex.h" -size_t text_begin(Text*, size_t pos); -size_t text_end(Text*, size_t pos); +VIS_INTERNAL size_t text_begin(Text*, size_t pos); +VIS_INTERNAL size_t text_end(Text*, size_t pos); /* char refers to a grapheme (might skip over multiple Unicode codepoints) */ -size_t text_char_next(Text*, size_t pos); -size_t text_char_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_char_next(Text*, size_t pos); +VIS_INTERNAL size_t text_char_prev(Text*, size_t pos); -size_t text_codepoint_next(Text*, size_t pos); -size_t text_codepoint_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_codepoint_next(Text*, size_t pos); +VIS_INTERNAL size_t text_codepoint_prev(Text*, size_t pos); /* find the given substring either in forward or backward direction. * does not wrap around at file start / end. If no match is found return * original position */ -size_t text_find_next(Text*, size_t pos, const char *s); -size_t text_find_prev(Text*, size_t pos, const char *s); +VIS_INTERNAL size_t text_find_next(Text*, size_t pos, const char *s); +VIS_INTERNAL size_t text_find_prev(Text*, size_t pos, const char *s); /* same as above but limit searched range to the line containing pos */ -size_t text_line_find_next(Text*, size_t pos, const char *s); -size_t text_line_find_prev(Text*, size_t pos, const char *s); +VIS_INTERNAL size_t text_line_find_next(Text*, size_t pos, const char *s); +VIS_INTERNAL size_t text_line_find_prev(Text*, size_t pos, const char *s); /* begin finish next * v v v @@ -34,64 +34,64 @@ size_t text_line_find_prev(Text*, size_t pos, const char *s); * ^ ^ ^ * prev start end */ -size_t text_line_prev(Text*, size_t pos); -size_t text_line_begin(Text*, size_t pos); -size_t text_line_start(Text*, size_t pos); -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); -size_t text_line_offset(Text*, size_t pos, size_t off); +VIS_INTERNAL size_t text_line_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_line_begin(Text*, size_t pos); +VIS_INTERNAL size_t text_line_start(Text*, size_t pos); +VIS_INTERNAL size_t text_line_finish(Text*, size_t pos); +VIS_INTERNAL size_t text_line_end(Text*, size_t pos); +VIS_INTERNAL size_t text_line_next(Text*, size_t pos); +VIS_INTERNAL size_t text_line_offset(Text*, size_t pos, size_t off); /* get grapheme count of the line upto `pos' */ -int text_line_char_get(Text*, size_t pos); +VIS_INTERNAL int text_line_char_get(Text*, size_t pos); /* get position of the `count' grapheme in the line containing `pos' */ -size_t text_line_char_set(Text*, size_t pos, int count); +VIS_INTERNAL size_t text_line_char_set(Text*, size_t pos, int count); /* get display width of line upto `pos' */ -int text_line_width_get(Text*, size_t pos); +VIS_INTERNAL int text_line_width_get(Text*, size_t pos); /* get position of character being displayed at `width' in line containing `pos' */ -size_t text_line_width_set(Text*, size_t pos, int width); +VIS_INTERNAL size_t text_line_width_set(Text*, size_t pos, int width); /* move to the next/previous grapheme on the same line */ -size_t text_line_char_next(Text*, size_t pos); -size_t text_line_char_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_line_char_next(Text*, size_t pos); +VIS_INTERNAL size_t text_line_char_prev(Text*, size_t pos); /* move to the next/previous empty line */ -size_t text_line_empty_next(Text*, size_t pos); -size_t text_line_empty_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_line_empty_next(Text*, size_t pos); +VIS_INTERNAL size_t text_line_empty_prev(Text*, size_t pos); /* move to start of next/previous blank line */ -size_t text_line_blank_next(Text*, size_t pos); -size_t text_line_blank_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_line_blank_next(Text*, size_t pos); +VIS_INTERNAL size_t text_line_blank_prev(Text*, size_t pos); /* move to same offset in previous/next line */ -size_t text_line_up(Text*, size_t pos); -size_t text_line_down(Text*, size_t pos); +VIS_INTERNAL size_t text_line_up(Text*, size_t pos); +VIS_INTERNAL size_t text_line_down(Text*, size_t pos); /* functions to iterate over all line beginnings in a given range */ -size_t text_range_line_first(Text*, Filerange*); -size_t text_range_line_last(Text*, Filerange*); -size_t text_range_line_next(Text*, Filerange*, size_t pos); -size_t text_range_line_prev(Text*, Filerange*, size_t pos); +VIS_INTERNAL size_t text_range_line_first(Text*, Filerange*); +VIS_INTERNAL size_t text_range_line_last(Text*, Filerange*); +VIS_INTERNAL size_t text_range_line_next(Text*, Filerange*, size_t pos); +VIS_INTERNAL size_t text_range_line_prev(Text*, Filerange*, size_t pos); /* * A longword 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 equivalent to a WORD in vim terminology. */ -size_t text_longword_end_next(Text*, size_t pos); -size_t text_longword_end_prev(Text*, size_t pos); -size_t text_longword_start_next(Text*, size_t pos); -size_t text_longword_start_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_longword_end_next(Text*, size_t pos); +VIS_INTERNAL size_t text_longword_end_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_longword_start_next(Text*, size_t pos); +VIS_INTERNAL size_t text_longword_start_prev(Text*, size_t pos); /* * A word consists of a sequence of letters, digits and underscores, or a * sequence of other non-blank characters, separated with white space. * TODO?: An empty line is also considered to be a word. * This is equivalent to a word (lowercase) in vim terminology. */ -size_t text_word_end_next(Text*, size_t pos); -size_t text_word_end_prev(Text*, size_t pos); -size_t text_word_start_next(Text*, size_t pos); -size_t text_word_start_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_word_end_next(Text*, size_t pos); +VIS_INTERNAL size_t text_word_end_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_word_start_next(Text*, size_t pos); +VIS_INTERNAL size_t text_word_start_prev(Text*, size_t pos); /* * More general versions of the above, define your own word boundaries. */ -size_t text_customword_start_next(Text*, size_t pos, int (*isboundary)(int)); -size_t text_customword_start_prev(Text*, size_t pos, int (*isboundary)(int)); -size_t text_customword_end_next(Text*, size_t pos, int (*isboundary)(int)); -size_t text_customword_end_prev(Text*, size_t pos, int (*isboundary)(int)); +VIS_INTERNAL size_t text_customword_start_next(Text*, size_t pos, int (*isboundary)(int)); +VIS_INTERNAL size_t text_customword_start_prev(Text*, size_t pos, int (*isboundary)(int)); +VIS_INTERNAL size_t text_customword_end_next(Text*, size_t pos, int (*isboundary)(int)); +VIS_INTERNAL size_t text_customword_end_prev(Text*, size_t pos, int (*isboundary)(int)); /* TODO: implement the following semantics * A sentence is defined as ending at a '.', '!' or '?' followed by either the * end of a line, or by a space or tab. Any number of closing ')', ']', '"' @@ -99,34 +99,34 @@ size_t text_customword_end_prev(Text*, size_t pos, int (*isboundary)(int)); * tabs or end of line. A paragraph and section boundary is also a sentence * boundary. */ -size_t text_sentence_next(Text*, size_t pos); -size_t text_sentence_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_sentence_next(Text*, size_t pos); +VIS_INTERNAL size_t text_sentence_prev(Text*, size_t pos); /* TODO: implement the following semantics * A paragraph begins after each empty line. A section boundary is also a * paragraph boundary. Note that a blank line (only containing white space) * is NOT a paragraph boundary. */ -size_t text_paragraph_next(Text*, size_t pos); -size_t text_paragraph_prev(Text*, size_t pos); +VIS_INTERNAL size_t text_paragraph_next(Text*, size_t pos); +VIS_INTERNAL size_t text_paragraph_prev(Text*, size_t pos); /* A section begins after a form-feed in the first column. size_t text_section_next(Text*, size_t pos); size_t text_section_prev(Text*, size_t pos); */ -size_t text_block_start(Text*, size_t pos); -size_t text_block_end(Text*, size_t pos); -size_t text_parenthesis_start(Text*, size_t pos); -size_t text_parenthesis_end(Text*, size_t pos); +VIS_INTERNAL size_t text_block_start(Text*, size_t pos); +VIS_INTERNAL size_t text_block_end(Text*, size_t pos); +VIS_INTERNAL size_t text_parenthesis_start(Text*, size_t pos); +VIS_INTERNAL size_t text_parenthesis_end(Text*, size_t pos); /* search corresponding '(', ')', '{', '}', '[', ']', '>', '<', '"', ''' */ -size_t text_bracket_match(Text*, size_t pos, const Filerange *limits); +VIS_INTERNAL size_t text_bracket_match(Text*, size_t pos, const Filerange *limits); /* same as above but explicitly specify symbols to match */ -size_t text_bracket_match_symbol(Text*, size_t pos, const char *symbols, const Filerange *limits); +VIS_INTERNAL size_t text_bracket_match_symbol(Text*, size_t pos, const char *symbols, const Filerange *limits); /* 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); +VIS_INTERNAL size_t text_search_forward(Text *txt, size_t pos, Regex *regex); +VIS_INTERNAL size_t text_search_backward(Text *txt, size_t pos, Regex *regex); /* is c a special symbol delimiting a word? */ -int is_word_boundary(int c); +VIS_INTERNAL int is_word_boundary(int c); #endif |
