1#ifndef NVIM_SEARCH_H
2#define NVIM_SEARCH_H
3
4#include <stdbool.h>
5#include <stdint.h>
6
7#include "nvim/vim.h"
8#include "nvim/buffer_defs.h"
9#include "nvim/eval/typval.h"
10#include "nvim/normal.h"
11#include "nvim/os/time.h"
12
13/* Values for the find_pattern_in_path() function args 'type' and 'action': */
14#define FIND_ANY 1
15#define FIND_DEFINE 2
16#define CHECK_PATH 3
17
18#define ACTION_SHOW 1
19#define ACTION_GOTO 2
20#define ACTION_SPLIT 3
21#define ACTION_SHOW_ALL 4
22#define ACTION_EXPAND 5
23
24// Values for 'options' argument in do_search() and searchit()
25#define SEARCH_REV 0x01 ///< go in reverse of previous dir.
26#define SEARCH_ECHO 0x02 ///< echo the search command and handle options
27#define SEARCH_MSG 0x0c ///< give messages (yes, it's not 0x04)
28#define SEARCH_NFMSG 0x08 ///< give all messages except not found
29#define SEARCH_OPT 0x10 ///< interpret optional flags
30#define SEARCH_HIS 0x20 ///< put search pattern in history
31#define SEARCH_END 0x40 ///< put cursor at end of match
32#define SEARCH_NOOF 0x80 ///< don't add offset to position
33#define SEARCH_START 0x100 ///< start search without col offset
34#define SEARCH_MARK 0x200 ///< set previous context mark
35#define SEARCH_KEEP 0x400 ///< keep previous search pattern
36#define SEARCH_PEEK 0x800 ///< peek for typed char, cancel search
37#define SEARCH_COL 0x1000 ///< start at specified column instead of zero
38
39/* Values for flags argument for findmatchlimit() */
40#define FM_BACKWARD 0x01 /* search backwards */
41#define FM_FORWARD 0x02 /* search forwards */
42#define FM_BLOCKSTOP 0x04 /* stop at start/end of block */
43#define FM_SKIPCOMM 0x08 /* skip comments */
44
45/* Values for sub_cmd and which_pat argument for search_regcomp() */
46/* Also used for which_pat argument for searchit() */
47#define RE_SEARCH 0 /* save/use pat in/from search_pattern */
48#define RE_SUBST 1 /* save/use pat in/from subst_pattern */
49#define RE_BOTH 2 /* save pat in both patterns */
50#define RE_LAST 2 /* use last used pattern if "pat" is NULL */
51
52/// Structure containing offset definition for the last search pattern
53///
54/// @note Only offset for the last search pattern is used, not for the last
55/// substitute pattern.
56typedef struct soffset {
57 char dir; ///< Search direction: forward ('/') or backward ('?')
58 bool line; ///< True if search has line offset.
59 bool end; ///< True if search sets cursor at the end.
60 int64_t off; ///< Actual offset value.
61} SearchOffset;
62
63/// Structure containing last search pattern and its attributes.
64typedef struct spat {
65 char_u *pat; ///< The pattern (in allocated memory) or NULL.
66 bool magic; ///< Magicness of the pattern.
67 bool no_scs; ///< No smartcase for this pattern.
68 Timestamp timestamp; ///< Time of the last change.
69 SearchOffset off; ///< Pattern offset.
70 dict_T *additional_data; ///< Additional data from ShaDa file.
71} SearchPattern;
72
73#ifdef INCLUDE_GENERATED_DECLARATIONS
74# include "search.h.generated.h"
75#endif
76#endif // NVIM_SEARCH_H
77