summaryrefslogtreecommitdiff
path: root/examples/dte/search.h
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2023-11-09 23:19:53 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2023-11-09 23:19:53 +0100
commit1566b6faa8534118c3566188181367cd0868468f (patch)
tree1de8d4b369efb5e592685a31088f798a6b63ffa1 /examples/dte/search.h
parent349991bf6efe473ab9a5cbdae0a8114d72b997e3 (diff)
downloadcrep-1566b6faa8534118c3566188181367cd0868468f.tar.gz
Added partial matching and introduced threads
Diffstat (limited to 'examples/dte/search.h')
-rw-r--r--examples/dte/search.h34
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
9typedef enum {
10 CSS_FALSE,
11 CSS_TRUE,
12 CSS_AUTO,
13} SearchCaseSensitivity;
14
15typedef 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
22static inline void toggle_search_direction(SearchState *search)
23{
24 search->reverse ^= 1;
25}
26
27bool search_tag(View *view, const char *pattern) NONNULL_ARGS WARN_UNUSED_RESULT;
28void search_set_regexp(SearchState *search, const char *pattern) NONNULL_ARGS;
29void search_free_regexp(SearchState *search) NONNULL_ARGS;
30bool search_prev(View *view, SearchState *search, SearchCaseSensitivity cs) NONNULL_ARGS WARN_UNUSED_RESULT;
31bool search_next(View *view, SearchState *search, SearchCaseSensitivity cs) NONNULL_ARGS WARN_UNUSED_RESULT;
32bool search_next_word(View *view, SearchState *search, SearchCaseSensitivity cs) NONNULL_ARGS WARN_UNUSED_RESULT;
33
34#endif