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