seek.h (2756B)
1 #ifndef SEEK_H_ 2 #define SEEK_H_ 3 4 // TODO: check that all functions are in the right place 5 // complete rework / file renaming first 6 7 #include "buffer.h" 8 #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) 9 10 struct delimiter { 11 char* start; 12 char* end; 13 }; 14 15 int str_contains_char(const char* string, char check); 16 ///////////// 17 // result must be freed 18 char* file_path_get_path(const char* path); 19 int is_file_type(const char* file_path, const char* file_type); 20 int path_is_folder(const char* path); 21 22 int fb_is_on_a_word(const struct file_buffer* fb, int offset, const char* word_seperators); 23 int fb_is_start_of_a_word(const struct file_buffer* fb, int offset, const char* word_seperators); 24 int fb_is_on_word(const struct file_buffer* fb, int offset, const char* word_seperators, const char* word); 25 26 int fb_offset_starts_with(const struct file_buffer* fb, int offset, const char* start); 27 28 int fb_seek_char(const struct file_buffer* fb, int offset, char byte); 29 int fb_seek_char_backwards(const struct file_buffer* fb, int offset, char byte); 30 31 int fb_seek_string(const struct file_buffer* fb, int offset, const char* string); 32 int fb_seek_string_not_escaped(const struct file_buffer* fb, int offset, const char* string); 33 int fb_seek_string_backwards(const struct file_buffer* fb, int offset, const char* string); 34 int fb_seek_string_backwards_not_escaped(const struct file_buffer* fb, int offset, const char* string); 35 int wb_seek_string_wrap(const struct window_buffer* wb, int offset, const char* search); 36 int wb_seek_string_wrap_backwards(const struct window_buffer* wb, int offset, const char* search); 37 38 int fb_seek_word(const struct file_buffer* fb, int offset, const char* word_seperators); 39 int fb_seek_word_end(const struct file_buffer* fb, int offset, const char* word_seperators); 40 int fb_seek_word_backwards(const struct file_buffer* fb, int offset, const char* word_seperators); 41 int fb_seek_start_of_word_backwards(const struct file_buffer* fb, int offset, const char* word_seperators); 42 43 int fb_seek_whitespace(const struct file_buffer* fb, int offset); 44 int fb_seek_whitespace_backwards(const struct file_buffer* fb, int offset); 45 int fb_seek_not_whitespace(const struct file_buffer* fb, int offset); 46 int fb_seek_not_whitespace_backwards(const struct file_buffer* fb, int offset); 47 // TODO: 48 //int fb_has_whitespace_between(const struct file_buffer* fb, int start, int end); 49 50 int fb_count_string_instances(const struct file_buffer* fb, const char* string, int offset, int* before_offset); 51 52 //////////////////////// 53 // struct delimiter* ignore is a null terminated pointer array 54 int fb_get_delimiter(const struct file_buffer* fb, int offset, struct delimiter d, struct delimiter* ignore, int* start, int* end); 55 56 57 #endif // SEEK_H_