annotate src/match.c @ 29071:b90bca860b5a v8.2.5057

patch 8.2.5057: using gettimeofday() for timeout is very inefficient Commit: https://github.com/vim/vim/commit/6574577cacd393ab7591fc776ea060eebc939e55 Author: Paul Ollis <paul@cleversheep.org> Date: Sun Jun 5 16:55:54 2022 +0100 patch 8.2.5057: using gettimeofday() for timeout is very inefficient Problem: Using gettimeofday() for timeout is very inefficient. Solution: Set a platform dependent timer. (Paul Ollis, closes https://github.com/vim/vim/issues/10505)
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Jun 2022 18:00:08 +0200
parents a2710736125a
children b66386af68f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * match.c: functions for highlighting matches
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 #include "vim.h"
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 # define SEARCH_HL_PRIORITY 0
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 * Add match to the match list of window 'wp'. The pattern 'pat' will be
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 * highlighted with the group 'grp' with priority 'prio'.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 * Optionally, a desired ID 'id' can be specified (greater than or equal to 1).
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 * If no particular ID is desired, -1 must be specified for 'id'.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 * Return ID of added match, -1 on failure.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 static int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 match_add(
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 win_T *wp,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 char_u *grp,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 char_u *pat,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 int prio,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 int id,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 list_T *pos_list,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 char_u *conceal_char UNUSED) // pointer to conceal replacement char
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 matchitem_T *cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 matchitem_T *prev;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 matchitem_T *m;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 int hlg_id;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 regprog_T *regprog = NULL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 int rtype = SOME_VALID;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 if (*grp == NUL || (pat != NULL && *pat == NUL))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 return -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 if (id < -1 || id == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 {
26964
5de60e0d65fa patch 8.2.4011: test fails because of changed error number
Bram Moolenaar <Bram@vim.org>
parents: 26962
diff changeset
48 semsg(_(e_invalid_id_nr_must_be_greater_than_or_equal_to_one_1), id);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 return -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 if (id != -1)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 while (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 if (cur->id == id)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 {
26962
85866e069c24 patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
58 semsg(_(e_id_already_taken_nr), id);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 return -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 if ((hlg_id = syn_namen2id(grp, (int)STRLEN(grp))) == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 {
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
66 semsg(_(e_no_such_highlight_group_name_str), grp);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 return -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 if (pat != NULL && (regprog = vim_regcomp(pat, RE_MAGIC)) == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
71 semsg(_(e_invalid_argument_str), pat);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 return -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 // Find available match ID.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 while (id == -1)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 while (cur != NULL && cur->id != wp->w_next_match_id)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 if (cur == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 id = wp->w_next_match_id;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 wp->w_next_match_id++;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 // Build new match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 m = ALLOC_CLEAR_ONE(matchitem_T);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 m->id = id;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 m->priority = prio;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 m->pattern = pat == NULL ? NULL : vim_strsave(pat);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 m->hlg_id = hlg_id;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 m->match.regprog = regprog;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 m->match.rmm_ic = FALSE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 m->match.rmm_maxcol = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 # if defined(FEAT_CONCEAL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 m->conceal_char = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 if (conceal_char != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 m->conceal_char = (*mb_ptr2char)(conceal_char);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 // Set up position matches
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 if (pos_list != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 linenr_T toplnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 linenr_T botlnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 listitem_T *li;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 int i;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 CHECK_LIST_MATERIALIZE(pos_list);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 for (i = 0, li = pos_list->lv_first; li != NULL && i < MAXPOSMATCH;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 i++, li = li->li_next)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 linenr_T lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 colnr_T col = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 int len = 1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 list_T *subl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 listitem_T *subli;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 int error = FALSE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 if (li->li_tv.v_type == VAR_LIST)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 subl = li->li_tv.vval.v_list;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 if (subl == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 goto fail;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 subli = subl->lv_first;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 if (subli == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 goto fail;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 lnum = tv_get_number_chk(&subli->li_tv, &error);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 if (error == TRUE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 goto fail;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 if (lnum == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 --i;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 continue;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 m->pos.pos[i].lnum = lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 subli = subli->li_next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 if (subli != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 col = tv_get_number_chk(&subli->li_tv, &error);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 if (error == TRUE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 goto fail;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 subli = subli->li_next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 if (subli != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 len = tv_get_number_chk(&subli->li_tv, &error);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 if (error == TRUE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 goto fail;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 m->pos.pos[i].col = col;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 m->pos.pos[i].len = len;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 else if (li->li_tv.v_type == VAR_NUMBER)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 if (li->li_tv.vval.v_number == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 --i;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 continue;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 m->pos.pos[i].lnum = li->li_tv.vval.v_number;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 m->pos.pos[i].col = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 m->pos.pos[i].len = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 {
26897
d02d40f0261c patch 8.2.3977: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26887
diff changeset
167 emsg(_(e_list_or_number_required));
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 goto fail;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 if (toplnum == 0 || lnum < toplnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 toplnum = lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 if (botlnum == 0 || lnum >= botlnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 botlnum = lnum + 1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 // Calculate top and bottom lines for redrawing area
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 if (toplnum != 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 if (wp->w_buffer->b_mod_set)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 if (wp->w_buffer->b_mod_top > toplnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 wp->w_buffer->b_mod_top = toplnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 if (wp->w_buffer->b_mod_bot < botlnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 wp->w_buffer->b_mod_bot = botlnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 wp->w_buffer->b_mod_set = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 wp->w_buffer->b_mod_top = toplnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 wp->w_buffer->b_mod_bot = botlnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 wp->w_buffer->b_mod_xlines = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 m->pos.toplnum = toplnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 m->pos.botlnum = botlnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 rtype = VALID;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 // Insert new match. The match list is in ascending order with regard to
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 // the match priorities.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 prev = cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 while (cur != NULL && prio >= cur->priority)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 prev = cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 if (cur == prev)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 wp->w_match_head = m;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 prev->next = m;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 m->next = cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 redraw_win_later(wp, rtype);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 return id;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 fail:
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 vim_free(m);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 return -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 * Delete match with ID 'id' in the match list of window 'wp'.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 * Print error messages if 'perr' is TRUE.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 static int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 match_delete(win_T *wp, int id, int perr)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 matchitem_T *cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 matchitem_T *prev = cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 int rtype = SOME_VALID;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 if (id < 1)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 if (perr == TRUE)
26964
5de60e0d65fa patch 8.2.4011: test fails because of changed error number
Bram Moolenaar <Bram@vim.org>
parents: 26962
diff changeset
236 semsg(_(e_invalid_id_nr_must_be_greater_than_or_equal_to_one_2), id);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 return -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 while (cur != NULL && cur->id != id)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 prev = cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 if (cur == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 if (perr == TRUE)
26962
85866e069c24 patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
247 semsg(_(e_id_not_found_nr), id);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 return -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 if (cur == prev)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 wp->w_match_head = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 prev->next = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 vim_regfree(cur->match.regprog);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 vim_free(cur->pattern);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 if (cur->pos.toplnum != 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 if (wp->w_buffer->b_mod_set)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 if (wp->w_buffer->b_mod_top > cur->pos.toplnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 wp->w_buffer->b_mod_top = cur->pos.toplnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 if (wp->w_buffer->b_mod_bot < cur->pos.botlnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 wp->w_buffer->b_mod_bot = cur->pos.botlnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 wp->w_buffer->b_mod_set = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 wp->w_buffer->b_mod_top = cur->pos.toplnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 wp->w_buffer->b_mod_bot = cur->pos.botlnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 wp->w_buffer->b_mod_xlines = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 rtype = VALID;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 vim_free(cur);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 redraw_win_later(wp, rtype);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 return 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 * Delete all matches in the match list of window 'wp'.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 clear_matches(win_T *wp)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 matchitem_T *m;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 while (wp->w_match_head != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 m = wp->w_match_head->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 vim_regfree(wp->w_match_head->match.regprog);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 vim_free(wp->w_match_head->pattern);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 vim_free(wp->w_match_head);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 wp->w_match_head = m;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 redraw_win_later(wp, SOME_VALID);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 * Get match from ID 'id' in window 'wp'.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 * Return NULL if match not found.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 static matchitem_T *
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 get_match(win_T *wp, int id)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 matchitem_T *cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 while (cur != NULL && cur->id != id)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 return cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 * Init for calling prepare_search_hl().
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 init_search_hl(win_T *wp, match_T *search_hl)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 matchitem_T *cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 // Setup for match and 'hlsearch' highlighting. Disable any previous
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 // match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 while (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 cur->hl.rm = cur->match;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 if (cur->hlg_id == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 cur->hl.attr = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 cur->hl.attr = syn_id2attr(cur->hlg_id);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 cur->hl.buf = wp->w_buffer;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 cur->hl.lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 cur->hl.first_lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 search_hl->buf = wp->w_buffer;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 search_hl->lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 search_hl->first_lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 // time limit is set at the toplevel, for all windows
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 * If there is a match fill "shl" and return one.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 * Return zero otherwise.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 static int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 next_search_hl_pos(
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 match_T *shl, // points to a match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 linenr_T lnum,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 posmatch_T *posmatch, // match positions
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 colnr_T mincol) // minimal column for a match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 int i;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 int found = -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 for (i = posmatch->cur; i < MAXPOSMATCH; i++)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 llpos_T *pos = &posmatch->pos[i];
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 if (pos->lnum == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 if (pos->len == 0 && pos->col < mincol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362 continue;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 if (pos->lnum == lnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 if (found >= 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 // if this match comes before the one at "found" then swap
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 // them
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 if (pos->col < posmatch->pos[found].col)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 llpos_T tmp = *pos;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 *pos = posmatch->pos[found];
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 posmatch->pos[found] = tmp;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 found = i;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 posmatch->cur = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 if (found >= 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 colnr_T start = posmatch->pos[found].col == 0
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 ? 0 : posmatch->pos[found].col - 1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 colnr_T end = posmatch->pos[found].col == 0
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 ? MAXCOL : start + posmatch->pos[found].len;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 shl->lnum = lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 shl->rm.startpos[0].lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 shl->rm.startpos[0].col = start;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 shl->rm.endpos[0].lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 shl->rm.endpos[0].col = end;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 shl->is_addpos = TRUE;
28469
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
395 shl->has_cursor = FALSE;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 posmatch->cur = found + 1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 return 1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 return 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 * Search for a next 'hlsearch' or match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 * Uses shl->buf.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 * Sets shl->lnum and shl->rm contents.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 * Note: Assumes a previous match is always before "lnum", unless
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 * shl->lnum is zero.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 * Careful: Any pointers for buffer lines will become invalid.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 static void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 next_search_hl(
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 win_T *win,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 match_T *search_hl,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 match_T *shl, // points to search_hl or a match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 linenr_T lnum,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 colnr_T mincol, // minimal column for a match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 matchitem_T *cur) // to retrieve match positions if any
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 linenr_T l;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 colnr_T matchcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 long nmatched;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 int called_emsg_before = called_emsg;
29071
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 29050
diff changeset
423 int timed_out = FALSE;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 // for :{range}s/pat only highlight inside the range
26823
f1618f8705e4 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Bram Moolenaar <Bram@vim.org>
parents: 26334
diff changeset
426 if ((lnum < search_first_line || lnum > search_last_line) && cur == NULL)
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 shl->lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 if (shl->lnum != 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 // Check for three situations:
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 // 1. If the "lnum" is below a previous match, start a new search.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 // 2. If the previous match includes "mincol", use it.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 // 3. Continue after the previous match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 l = shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 if (lnum > l)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 shl->lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 else if (lnum < l || shl->rm.endpos[0].col > mincol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 // Repeat searching for a match until one is found that includes "mincol"
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 // or none is found in this line.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 for (;;)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 # ifdef FEAT_RELTIME
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 // Stop searching after passing the time limit.
29071
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 29050
diff changeset
451 if (timed_out)
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 shl->lnum = 0; // no match found in time
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 // Three situations:
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 // 1. No useful previous match: search from start of line.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 // 2. Not Vi compatible or empty match: continue at next character.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 // Break the loop if this is beyond the end of the line.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 // 3. Vi compatible searching: continue at end of previous match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 if (shl->lnum == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 matchcol = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 else if (vim_strchr(p_cpo, CPO_SEARCH) == NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 || (shl->rm.endpos[0].lnum == 0
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 && shl->rm.endpos[0].col <= shl->rm.startpos[0].col))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 char_u *ml;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 matchcol = shl->rm.startpos[0].col;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 ml = ml_get_buf(shl->buf, lnum, FALSE) + matchcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 if (*ml == NUL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 ++matchcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 shl->lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 if (has_mbyte)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 matchcol += mb_ptr2len(ml);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 ++matchcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 matchcol = shl->rm.endpos[0].col;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 shl->lnum = lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 if (shl->rm.regprog != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 // Remember whether shl->rm is using a copy of the regprog in
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 // cur->match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 int regprog_is_copy = (shl != search_hl && cur != NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 && shl == &cur->hl
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 && cur->match.regprog == cur->hl.rm.regprog);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum,
29071
b90bca860b5a patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents: 29050
diff changeset
496 matchcol, &timed_out);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 // Copy the regprog, in case it got freed and recompiled.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 if (regprog_is_copy)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 cur->match.regprog = cur->hl.rm.regprog;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 if (called_emsg > called_emsg_before || got_int || timed_out)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 // Error while handling regexp: stop using this regexp.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 if (shl == search_hl)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 // don't free regprog in the match list, it's a copy
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 vim_regfree(shl->rm.regprog);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 set_no_hlsearch(TRUE);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 shl->rm.regprog = NULL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 shl->lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 got_int = FALSE; // avoid the "Type :quit to exit Vim" message
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 else if (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 nmatched = next_search_hl_pos(shl, lnum, &(cur->pos), matchcol);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 nmatched = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 if (nmatched == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 shl->lnum = 0; // no match found
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 if (shl->rm.startpos[0].lnum > 0
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 || shl->rm.startpos[0].col >= mincol
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 || nmatched > 1
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 || shl->rm.endpos[0].col > mincol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 shl->lnum += shl->rm.startpos[0].lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 break; // useful match found
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 * Advance to the match in window "wp" line "lnum" or past it.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 prepare_search_hl(win_T *wp, match_T *search_hl, linenr_T lnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 matchitem_T *cur; // points to the match list
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 match_T *shl; // points to search_hl or a match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 int shl_flag; // flag to indicate whether search_hl
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 // has been processed or not
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 int pos_inprogress; // marks that position match search is
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 // in progress
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 int n;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 // When using a multi-line pattern, start searching at the top
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 // of the window or just after a closed fold.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 // Do this both for search_hl and the match list.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 shl_flag = WIN_IS_POPUP(wp); // skip search_hl in a popup window
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 while (cur != NULL || shl_flag == FALSE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 if (shl_flag == FALSE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 shl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 if (shl->rm.regprog != NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 && shl->lnum == 0
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 && re_multiline(shl->rm.regprog))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 if (shl->first_lnum == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 # ifdef FEAT_FOLDING
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 for (shl->first_lnum = lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 shl->first_lnum > wp->w_topline; --shl->first_lnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 if (hasFoldingWin(wp, shl->first_lnum - 1,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 NULL, NULL, TRUE, NULL))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 # else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 shl->first_lnum = wp->w_topline;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 if (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 cur->pos.cur = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 pos_inprogress = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 n = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 while (shl->first_lnum < lnum && (shl->rm.regprog != NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 || (cur != NULL && pos_inprogress)))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 next_search_hl(wp, search_hl, shl, shl->first_lnum, (colnr_T)n,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 shl == search_hl ? NULL : cur);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 pos_inprogress = cur == NULL || cur->pos.cur == 0
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 ? FALSE : TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 if (shl->lnum != 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 shl->first_lnum = shl->lnum
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 + shl->rm.endpos[0].lnum
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 - shl->rm.startpos[0].lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 n = shl->rm.endpos[0].col;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 ++shl->first_lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 n = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 if (shl != search_hl && cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 /*
28562
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
611 * Update "shl->has_cursor" based on the match in "shl" and the cursor
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
612 * position.
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
613 */
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
614 static void
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
615 check_cur_search_hl(win_T *wp, match_T *shl)
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
616 {
28576
3a16a350614f patch 8.2.4812: unused struct item
Bram Moolenaar <Bram@vim.org>
parents: 28562
diff changeset
617 linenr_T linecount = shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
28562
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
618
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
619 if (wp->w_cursor.lnum >= shl->lnum
28576
3a16a350614f patch 8.2.4812: unused struct item
Bram Moolenaar <Bram@vim.org>
parents: 28562
diff changeset
620 && wp->w_cursor.lnum <= shl->lnum + linecount
28562
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
621 && (wp->w_cursor.lnum > shl->lnum
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
622 || wp->w_cursor.col >= shl->rm.startpos[0].col)
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
623 && (wp->w_cursor.lnum < shl->lnum + linecount
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
624 || wp->w_cursor.col < shl->rm.endpos[0].col))
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
625 shl->has_cursor = TRUE;
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
626 else
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
627 shl->has_cursor = FALSE;
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
628 }
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
629
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
630 /*
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 * Prepare for 'hlsearch' and match highlighting in one window line.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 * Return TRUE if there is such highlighting and set "search_attr" to the
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 * current highlight attribute.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636 prepare_search_hl_line(
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637 win_T *wp,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 linenr_T lnum,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 colnr_T mincol,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 char_u **line,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 match_T *search_hl,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 int *search_attr)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 matchitem_T *cur; // points to the match list
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 match_T *shl; // points to search_hl or a match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 int shl_flag; // flag to indicate whether search_hl
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 // has been processed or not
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 int area_highlighting = FALSE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 // Handle highlighting the last used search pattern and matches.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 // Do this for both search_hl and the match list.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 // Do not use search_hl in a popup window.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 shl_flag = WIN_IS_POPUP(wp);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 while (cur != NULL || shl_flag == FALSE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 if (shl_flag == FALSE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 shl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 shl->startcol = MAXCOL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 shl->endcol = MAXCOL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 shl->attr_cur = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 shl->is_addpos = FALSE;
28469
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
668 shl->has_cursor = FALSE;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 if (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 cur->pos.cur = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 next_search_hl(wp, search_hl, shl, lnum, mincol,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 shl == search_hl ? NULL : cur);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 // Need to get the line again, a multi-line regexp may have made it
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 // invalid.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 *line = ml_get_buf(wp->w_buffer, lnum, FALSE);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 if (shl->lnum != 0 && shl->lnum <= lnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 if (shl->lnum == lnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 shl->startcol = shl->rm.startpos[0].col;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 shl->startcol = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684 if (lnum == shl->lnum + shl->rm.endpos[0].lnum
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 - shl->rm.startpos[0].lnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 shl->endcol = shl->rm.endpos[0].col;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 shl->endcol = MAXCOL;
28469
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
689
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
690 // check if the cursor is in the match before changing the columns
28562
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
691 if (shl == search_hl)
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
692 check_cur_search_hl(wp, shl);
28469
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
693
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 // Highlight one character for an empty match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 if (shl->startcol == shl->endcol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 if (has_mbyte && (*line)[shl->endcol] != NUL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 shl->endcol += (*mb_ptr2len)((*line) + shl->endcol);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 ++shl->endcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 if ((long)shl->startcol < mincol) // match at leftcol
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 shl->attr_cur = shl->attr;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 *search_attr = shl->attr;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 area_highlighting = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 if (shl != search_hl && cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
711 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
712 return area_highlighting;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
715 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 * For a position in a line: Check for start/end of 'hlsearch' and other
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 * matches.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 * After end, check for start/end of next match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 * When another match, have to check for start again.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 * Watch out for matching an empty string!
26334
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
721 * "on_last_col" is set to TRUE with non-zero search_attr and the next column
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
722 * is endcol.
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723 * Return the updated search_attr.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 update_search_hl(
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 win_T *wp,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 linenr_T lnum,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 colnr_T col,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730 char_u **line,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 match_T *search_hl,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 int *has_match_conc UNUSED,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 int *match_conc UNUSED,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 int did_line_attr,
26334
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
735 int lcs_eol_one,
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
736 int *on_last_col)
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 matchitem_T *cur; // points to the match list
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
739 match_T *shl; // points to search_hl or a match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
740 int shl_flag; // flag to indicate whether search_hl
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
741 // has been processed or not
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
742 int pos_inprogress; // marks that position match search is in
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
743 // progress
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 int search_attr = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 // Do this for 'search_hl' and the match list (ordered by priority).
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 shl_flag = WIN_IS_POPUP(wp);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 while (cur != NULL || shl_flag == FALSE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
752 if (shl_flag == FALSE
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753 && (cur == NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 || cur->priority > SEARCH_HL_PRIORITY))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 shl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 if (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 cur->pos.cur = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 pos_inprogress = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 while (shl->rm.regprog != NULL || (cur != NULL && pos_inprogress))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 if (shl->startcol != MAXCOL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 && col >= shl->startcol
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 && col < shl->endcol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 int next_col = col + mb_ptr2len(*line + col);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 if (shl->endcol < next_col)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 shl->endcol = next_col;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 shl->attr_cur = shl->attr;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 # ifdef FEAT_CONCEAL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 // Match with the "Conceal" group results in hiding
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 // the match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 if (cur != NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779 && shl != search_hl
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 && syn_name2id((char_u *)"Conceal") == cur->hlg_id)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 *has_match_conc = col == shl->startcol ? 2 : 1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 *match_conc = cur->conceal_char;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 *has_match_conc = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 # endif
28399
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
788 // Highlight the match were the cursor is using the CurSearch
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
789 // group.
28469
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
790 if (shl == search_hl && shl->has_cursor)
29050
a2710736125a patch 8.2.5047: CurSearch highlight is often wrong
Bram Moolenaar <Bram@vim.org>
parents: 28576
diff changeset
791 {
28399
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
792 shl->attr_cur = HL_ATTR(HLF_LC);
29050
a2710736125a patch 8.2.5047: CurSearch highlight is often wrong
Bram Moolenaar <Bram@vim.org>
parents: 28576
diff changeset
793 if (shl->attr_cur != shl->attr)
a2710736125a patch 8.2.5047: CurSearch highlight is often wrong
Bram Moolenaar <Bram@vim.org>
parents: 28576
diff changeset
794 search_hl_has_cursor_lnum = lnum;
a2710736125a patch 8.2.5047: CurSearch highlight is often wrong
Bram Moolenaar <Bram@vim.org>
parents: 28576
diff changeset
795 }
28399
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
796
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798 else if (col == shl->endcol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800 shl->attr_cur = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 next_search_hl(wp, search_hl, shl, lnum, col,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802 shl == search_hl ? NULL : cur);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
803 pos_inprogress = !(cur == NULL || cur->pos.cur == 0);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
805 // Need to get the line again, a multi-line regexp may have
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806 // made it invalid.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
807 *line = ml_get_buf(wp->w_buffer, lnum, FALSE);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
809 if (shl->lnum == lnum)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 shl->startcol = shl->rm.startpos[0].col;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 if (shl->rm.endpos[0].lnum == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
813 shl->endcol = shl->rm.endpos[0].col;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
814 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
815 shl->endcol = MAXCOL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816
28562
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
817 // check if the cursor is in the match
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
818 if (shl == search_hl)
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
819 check_cur_search_hl(wp, shl);
e96111a91a21 patch 8.2.4805: CurSearch used for all matches in current line
Bram Moolenaar <Bram@vim.org>
parents: 28469
diff changeset
820
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
821 if (shl->startcol == shl->endcol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823 // highlight empty match, try again after
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
824 // it
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
825 if (has_mbyte)
24000
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
826 {
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
827 char_u *p = *line + shl->endcol;
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
828
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
829 if (*p == NUL)
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
830 // consistent with non-mbyte
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
831 ++shl->endcol;
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
832 else
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
833 shl->endcol += (*mb_ptr2len)(p);
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
834 }
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
835 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 ++shl->endcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
837 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
838
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
839 // Loop to check if the match starts at the
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 // current position
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 continue;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 if (shl != search_hl && cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 // Use attributes from match with highest priority among 'search_hl' and
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 // the match list.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 shl_flag = WIN_IS_POPUP(wp);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 while (cur != NULL || shl_flag == FALSE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 if (shl_flag == FALSE
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 && (cur == NULL ||
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 cur->priority > SEARCH_HL_PRIORITY))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
861 shl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 if (shl->attr_cur != 0)
26334
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
866 {
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 search_attr = shl->attr_cur;
26334
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
868 *on_last_col = col + 1 >= shl->endcol;
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
869 }
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 if (shl != search_hl && cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 // Only highlight one character after the last column.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 if (*(*line + col) == NUL && (did_line_attr >= 1
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 || (wp->w_p_list && lcs_eol_one == -1)))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 search_attr = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 return search_attr;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881 get_prevcol_hl_flag(win_T *wp, match_T *search_hl, long curcol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
883 long prevcol = curcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 int prevcol_hl_flag = FALSE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 matchitem_T *cur; // points to the match list
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886
24000
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
887 #if defined(FEAT_PROP_POPUP)
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
888 // don't do this in a popup window
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
889 if (popup_is_popup(wp))
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
890 return FALSE;
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
891 #endif
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
892
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 // we're not really at that column when skipping some text
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 ++prevcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896
24000
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
897 // Highlight a character after the end of the line if the match started
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
898 // at the end of the line or when the match continues in the next line
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
899 // (match includes the line break).
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
900 if (!search_hl->is_addpos && (prevcol == (long)search_hl->startcol
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
901 || (prevcol > (long)search_hl->startcol
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
902 && search_hl->endcol == MAXCOL)))
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 prevcol_hl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
904 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 while (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 {
24000
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
909 if (!cur->hl.is_addpos && (prevcol == (long)cur->hl.startcol
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
910 || (prevcol > (long)cur->hl.startcol
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
911 && cur->hl.endcol == MAXCOL)))
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 prevcol_hl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 return prevcol_hl_flag;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 * Get highlighting for the char after the text in "char_attr" from 'hlsearch'
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924 * or match highlighting.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 get_search_match_hl(win_T *wp, match_T *search_hl, long col, int *char_attr)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 matchitem_T *cur; // points to the match list
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930 match_T *shl; // points to search_hl or a match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 int shl_flag; // flag to indicate whether search_hl
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 // has been processed or not
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 cur = wp->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 shl_flag = WIN_IS_POPUP(wp);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 while (cur != NULL || shl_flag == FALSE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 if (shl_flag == FALSE
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 && ((cur != NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 && cur->priority > SEARCH_HL_PRIORITY)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 || cur == NULL))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 shl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 if (col - 1 == (long)shl->startcol
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 && (shl == search_hl || !shl->is_addpos))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 *char_attr = shl->attr;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 if (shl != search_hl && cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 #endif // FEAT_SEARCH_EXTRA
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958 #if defined(FEAT_EVAL) || defined(PROTO)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959 # ifdef FEAT_SEARCH_EXTRA
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960 static int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 matchadd_dict_arg(typval_T *tv, char_u **conceal_char, win_T **win)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 dictitem_T *di;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965 if (tv->v_type != VAR_DICT)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
967 emsg(_(e_dictionary_required));
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 return FAIL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970
28315
62cc3b60493b patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
971 if (dict_has_key(tv->vval.v_dict, "conceal"))
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 *conceal_char = dict_get_string(tv->vval.v_dict,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 (char_u *)"conceal", FALSE);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975 if ((di = dict_find(tv->vval.v_dict, (char_u *)"window", -1)) != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 *win = find_win_by_nr_or_id(&di->di_tv);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 if (*win == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 {
26887
612339679616 patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
980 emsg(_(e_invalid_window_number));
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981 return FAIL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 return OK;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 #endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 * "clearmatches()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
992 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 f_clearmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995 #ifdef FEAT_SEARCH_EXTRA
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
996 win_T *win;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
998 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
999 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1000
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1001 win = get_optional_window(argvars, 0);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 if (win != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 clear_matches(win);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 #endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1007 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008 * "getmatches()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1010 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1011 f_getmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013 # ifdef FEAT_SEARCH_EXTRA
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1014 dict_T *dict;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 matchitem_T *cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 int i;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1017 win_T *win;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1019 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1020 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1021
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1022 win = get_optional_window(argvars, 0);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 if (rettv_list_alloc(rettv) == FAIL || win == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1024 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1025
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 cur = win->w_match_head;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027 while (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029 dict = dict_alloc();
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030 if (dict == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032 if (cur->match.regprog == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034 // match added with matchaddpos()
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035 for (i = 0; i < MAXPOSMATCH; ++i)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1036 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 llpos_T *llpos;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 char buf[30]; // use 30 to avoid compiler warning
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 list_T *l;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 llpos = &cur->pos.pos[i];
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1042 if (llpos->lnum == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 l = list_alloc();
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 if (l == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 list_append_number(l, (varnumber_T)llpos->lnum);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1048 if (llpos->col > 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1050 list_append_number(l, (varnumber_T)llpos->col);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 list_append_number(l, (varnumber_T)llpos->len);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053 sprintf(buf, "pos%d", i + 1);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 dict_add_list(dict, buf, l);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 dict_add_string(dict, "pattern", cur->pattern);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1061 dict_add_string(dict, "group", syn_id2name(cur->hlg_id));
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 dict_add_number(dict, "priority", (long)cur->priority);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063 dict_add_number(dict, "id", (long)cur->id);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 # if defined(FEAT_CONCEAL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065 if (cur->conceal_char)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 char_u buf[MB_MAXBYTES + 1];
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26964
diff changeset
1069 buf[(*mb_char2bytes)(cur->conceal_char, buf)] = NUL;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1070 dict_add_string(dict, "conceal", (char_u *)&buf);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1071 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1072 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073 list_append_dict(rettv->vval.v_list, dict);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1079 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 * "setmatches()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085 #ifdef FEAT_SEARCH_EXTRA
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1086 list_T *l;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 listitem_T *li;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 dict_T *d;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089 list_T *s = NULL;
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1090 win_T *win;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092 rettv->vval.v_number = -1;
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1093
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1094 if (in_vim9script()
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1095 && (check_for_list_arg(argvars, 0) == FAIL
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1096 || check_for_opt_number_arg(argvars, 1) == FAIL))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1097 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1098
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099 if (argvars[0].v_type != VAR_LIST)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
1101 emsg(_(e_list_required));
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1102 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 }
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1104 win = get_optional_window(argvars, 1);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105 if (win == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1106 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1107
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 if ((l = argvars[0].vval.v_list) != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1109 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110 // To some extent make sure that we are dealing with a list from
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 // "getmatches()".
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 li = l->lv_first;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 while (li != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1114 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115 if (li->li_tv.v_type != VAR_DICT
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1116 || (d = li->li_tv.vval.v_dict) == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1117 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
1118 emsg(_(e_invalid_argument));
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1119 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120 }
28315
62cc3b60493b patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
1121 if (!(dict_has_key(d, "group")
62cc3b60493b patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
1122 && (dict_has_key(d, "pattern")
62cc3b60493b patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
1123 || dict_has_key(d, "pos1"))
62cc3b60493b patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
1124 && dict_has_key(d, "priority")
62cc3b60493b patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
1125 && dict_has_key(d, "id")))
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
1127 emsg(_(e_invalid_argument));
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1128 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1129 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1130 li = li->li_next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1132
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1133 clear_matches(win);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1134 li = l->lv_first;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 while (li != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137 int i = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1138 char buf[30]; // use 30 to avoid compiler warning
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1139 dictitem_T *di;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1140 char_u *group;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141 int priority;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142 int id;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 char_u *conceal;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 d = li->li_tv.vval.v_dict;
28315
62cc3b60493b patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
1146 if (!dict_has_key(d, "pattern"))
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148 if (s == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 s = list_alloc();
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151 if (s == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1155 // match from matchaddpos()
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156 for (i = 1; i < 9; i++)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158 sprintf((char *)buf, (char *)"pos%d", i);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 if ((di = dict_find(d, (char_u *)buf, -1)) != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 if (di->di_tv.v_type != VAR_LIST)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 list_append_tv(s, &di->di_tv);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165 s->lv_refcount++;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1166 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1169 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1170 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 group = dict_get_string(d, (char_u *)"group", TRUE);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 priority = (int)dict_get_number(d, (char_u *)"priority");
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 id = (int)dict_get_number(d, (char_u *)"id");
28315
62cc3b60493b patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
1175 conceal = dict_has_key(d, "conceal")
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1176 ? dict_get_string(d, (char_u *)"conceal", TRUE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 : NULL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 if (i == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 match_add(win, group,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181 dict_get_string(d, (char_u *)"pattern", FALSE),
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182 priority, id, NULL, conceal);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186 match_add(win, group, NULL, priority, id, s, conceal);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1187 list_unref(s);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1188 s = NULL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 vim_free(group);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191 vim_free(conceal);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1192
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1193 li = li->li_next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1194 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 rettv->vval.v_number = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 #endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1198 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1199
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1200 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201 * "matchadd()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1202 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1204 f_matchadd(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1206 # ifdef FEAT_SEARCH_EXTRA
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1207 char_u buf[NUMBUFLEN];
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1208 char_u *grp; // group
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1209 char_u *pat; // pattern
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1210 int prio = 10; // default priority
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211 int id = -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1212 int error = FALSE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1213 char_u *conceal_char = NULL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1214 win_T *win = curwin;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1215
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1216 rettv->vval.v_number = -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1218 if (in_vim9script()
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1219 && (check_for_string_arg(argvars, 0) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1220 || check_for_string_arg(argvars, 1) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1221 || check_for_opt_number_arg(argvars, 2) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1222 || (argvars[2].v_type != VAR_UNKNOWN
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1223 && (check_for_opt_number_arg(argvars, 3) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1224 || (argvars[3].v_type != VAR_UNKNOWN
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1225 && check_for_opt_dict_arg(argvars, 4) == FAIL)))))
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1226 return;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1227
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1228 grp = tv_get_string_buf_chk(&argvars[0], buf); // group
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1229 pat = tv_get_string_buf_chk(&argvars[1], buf); // pattern
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1230 if (grp == NULL || pat == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1231 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1232 if (argvars[2].v_type != VAR_UNKNOWN)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1233 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1234 prio = (int)tv_get_number_chk(&argvars[2], &error);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1235 if (argvars[3].v_type != VAR_UNKNOWN)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1236 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1237 id = (int)tv_get_number_chk(&argvars[3], &error);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1238 if (argvars[4].v_type != VAR_UNKNOWN
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1239 && matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1240 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1241 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1242 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243 if (error == TRUE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1244 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1245 if (id >= 1 && id <= 3)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1246 {
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26897
diff changeset
1247 semsg(_(e_id_is_reserved_for_match_nr), id);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1248 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1249 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1250
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1251 rettv->vval.v_number = match_add(win, grp, pat, prio, id, NULL,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1252 conceal_char);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1253 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1254 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1256 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1257 * "matchaddpos()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1260 f_matchaddpos(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1262 # ifdef FEAT_SEARCH_EXTRA
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1263 char_u buf[NUMBUFLEN];
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1264 char_u *group;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 int prio = 10;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1266 int id = -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1267 int error = FALSE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1268 list_T *l;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1269 char_u *conceal_char = NULL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1270 win_T *win = curwin;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1271
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1272 rettv->vval.v_number = -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1274 if (in_vim9script()
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1275 && (check_for_string_arg(argvars, 0) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1276 || check_for_list_arg(argvars, 1) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1277 || check_for_opt_number_arg(argvars, 2) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1278 || (argvars[2].v_type != VAR_UNKNOWN
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1279 && (check_for_opt_number_arg(argvars, 3) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1280 || (argvars[3].v_type != VAR_UNKNOWN
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1281 && check_for_opt_dict_arg(argvars, 4) == FAIL)))))
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1282 return;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1283
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 group = tv_get_string_buf_chk(&argvars[0], buf);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285 if (group == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1286 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1287
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1288 if (argvars[1].v_type != VAR_LIST)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289 {
26887
612339679616 patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
1290 semsg(_(e_argument_of_str_must_be_list), "matchaddpos()");
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1291 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1292 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1293 l = argvars[1].vval.v_list;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1294 if (l == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1296
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1297 if (argvars[2].v_type != VAR_UNKNOWN)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1298 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1299 prio = (int)tv_get_number_chk(&argvars[2], &error);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1300 if (argvars[3].v_type != VAR_UNKNOWN)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1301 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1302 id = (int)tv_get_number_chk(&argvars[3], &error);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304 if (argvars[4].v_type != VAR_UNKNOWN
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305 && matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1306 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1307 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1308 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1309 if (error == TRUE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1310 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1311
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1312 // id == 3 is ok because matchaddpos() is supposed to substitute :3match
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1313 if (id == 1 || id == 2)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314 {
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26897
diff changeset
1315 semsg(_(e_id_is_reserved_for_match_nr), id);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1316 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1317 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1318
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1319 rettv->vval.v_number = match_add(win, group, NULL, prio, id, l,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1320 conceal_char);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1321 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1322 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1323
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1324 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1325 * "matcharg()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1326 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1327 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1328 f_matcharg(typval_T *argvars UNUSED, typval_T *rettv)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1329 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1330 if (rettv_list_alloc(rettv) == OK)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1331 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1332 # ifdef FEAT_SEARCH_EXTRA
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1333 int id;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1334 matchitem_T *m;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1335
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1336 if (in_vim9script() && check_for_number_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1337 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1338
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1339 id = (int)tv_get_number(&argvars[0]);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1340 if (id >= 1 && id <= 3)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1341 {
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26964
diff changeset
1342 if ((m = get_match(curwin, id)) != NULL)
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1343 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1344 list_append_string(rettv->vval.v_list,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1345 syn_id2name(m->hlg_id), -1);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1346 list_append_string(rettv->vval.v_list, m->pattern, -1);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1347 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1348 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1349 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1350 list_append_string(rettv->vval.v_list, NULL, -1);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1351 list_append_string(rettv->vval.v_list, NULL, -1);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1352 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1353 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1354 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1355 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1356 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1357
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1358 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1359 * "matchdelete()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1360 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1361 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1362 f_matchdelete(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1363 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1364 # ifdef FEAT_SEARCH_EXTRA
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1365 win_T *win;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1366
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1367 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1368 && (check_for_number_arg(argvars, 0) == FAIL
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1369 || check_for_opt_number_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1370 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1371
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
1372 win = get_optional_window(argvars, 1);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1373 if (win == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1374 rettv->vval.v_number = -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1375 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1376 rettv->vval.v_number = match_delete(win,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1377 (int)tv_get_number(&argvars[0]), TRUE);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1378 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1379 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1380 #endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1381
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1382 #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1383 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1384 * ":[N]match {group} {pattern}"
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1385 * Sets nextcmd to the start of the next command, if any. Also called when
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1386 * skipping commands to find the next command.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1387 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1388 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1389 ex_match(exarg_T *eap)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1390 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1391 char_u *p;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1392 char_u *g = NULL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1393 char_u *end;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1394 int c;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1395 int id;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1396
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1397 if (eap->line2 <= 3)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1398 id = eap->line2;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1399 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1400 {
21821
0deb6f96a5a3 patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 21459
diff changeset
1401 emsg(_(e_invalid_command));
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1402 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1403 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1404
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1405 // First clear any old pattern.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1406 if (!eap->skip)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1407 match_delete(curwin, id, FALSE);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1408
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1409 if (ends_excmd2(eap->cmd, eap->arg))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1410 end = eap->arg;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1411 else if ((STRNICMP(eap->arg, "none", 4) == 0
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1412 && (VIM_ISWHITE(eap->arg[4])
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1413 || ends_excmd2(eap->arg, eap->arg + 4))))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1414 end = eap->arg + 4;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1415 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1416 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1417 p = skiptowhite(eap->arg);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1418 if (!eap->skip)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1419 g = vim_strnsave(eap->arg, p - eap->arg);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1420 p = skipwhite(p);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1421 if (*p == NUL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1422 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1423 // There must be two arguments.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1424 vim_free(g);
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
1425 semsg(_(e_invalid_argument_str), eap->arg);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1426 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1427 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1428 end = skip_regexp(p + 1, *p, TRUE);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1429 if (!eap->skip)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1430 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1431 if (*end != NUL && !ends_excmd2(end, skipwhite(end + 1)))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1432 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1433 vim_free(g);
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
1434 eap->errmsg = ex_errmsg(e_trailing_characters_str, end);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1435 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1436 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1437 if (*end != *p)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1438 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1439 vim_free(g);
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
1440 semsg(_(e_invalid_argument_str), p);
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1441 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1442 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1443
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1444 c = *end;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1445 *end = NUL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1446 match_add(curwin, g, p + 1, 10, id, NULL, NULL);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1447 vim_free(g);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1448 *end = c;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1449 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1450 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1451 eap->nextcmd = find_nextcmd(end);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1452 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1453 #endif