diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2023-11-09 23:19:53 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2023-11-09 23:19:53 +0100 |
| commit | 1566b6faa8534118c3566188181367cd0868468f (patch) | |
| tree | 1de8d4b369efb5e592685a31088f798a6b63ffa1 /examples/dte/search.h | |
| parent | 349991bf6efe473ab9a5cbdae0a8114d72b997e3 (diff) | |
| download | crep-1566b6faa8534118c3566188181367cd0868468f.tar.gz | |
Added partial matching and introduced threads
Diffstat (limited to 'examples/dte/search.h')
| -rw-r--r-- | examples/dte/search.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/dte/search.h b/examples/dte/search.h new file mode 100644 index 0000000..94d3a57 --- /dev/null +++ b/examples/dte/search.h | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | #ifndef SEARCH_H | ||
| 2 | #define SEARCH_H | ||
| 3 | |||
| 4 | #include <regex.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include "util/macros.h" | ||
| 7 | #include "view.h" | ||
| 8 | |||
| 9 | typedef enum { | ||
| 10 | CSS_FALSE, | ||
| 11 | CSS_TRUE, | ||
| 12 | CSS_AUTO, | ||
| 13 | } SearchCaseSensitivity; | ||
| 14 | |||
| 15 | typedef struct { | ||
| 16 | regex_t regex; | ||
| 17 | char *pattern; | ||
| 18 | int re_flags; // If zero, regex hasn't been compiled | ||
| 19 | bool reverse; | ||
| 20 | } SearchState; | ||
| 21 | |||
| 22 | static inline void toggle_search_direction(SearchState *search) | ||
| 23 | { | ||
| 24 | search->reverse ^= 1; | ||
| 25 | } | ||
| 26 | |||
| 27 | bool search_tag(View *view, const char *pattern) NONNULL_ARGS WARN_UNUSED_RESULT; | ||
| 28 | void search_set_regexp(SearchState *search, const char *pattern) NONNULL_ARGS; | ||
| 29 | void search_free_regexp(SearchState *search) NONNULL_ARGS; | ||
| 30 | bool search_prev(View *view, SearchState *search, SearchCaseSensitivity cs) NONNULL_ARGS WARN_UNUSED_RESULT; | ||
| 31 | bool search_next(View *view, SearchState *search, SearchCaseSensitivity cs) NONNULL_ARGS WARN_UNUSED_RESULT; | ||
| 32 | bool search_next_word(View *view, SearchState *search, SearchCaseSensitivity cs) NONNULL_ARGS WARN_UNUSED_RESULT; | ||
| 33 | |||
| 34 | #endif | ||
