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