annotate src/match.c @ 28526:171f9def0398 v8.2.4787

patch 8.2.4787: prop_find() does not find the right property Commit: https://github.com/vim/vim/commit/9bd3ce22e36b5760a5e22e7d34d1bd6a3411258e Author: LemonBoy <thatlemon@gmail.com> Date: Mon Apr 18 21:54:02 2022 +0100 patch 8.2.4787: prop_find() does not find the right property Problem: prop_find() does not find the right property. Solution: Fix the scan order. (closes https://github.com/vim/vim/issues/10220)
author Bram Moolenaar <Bram@vim.org>
date Mon, 18 Apr 2022 23:00:03 +0200
parents 9ff0e5a29037
children e96111a91a21
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 # ifdef FEAT_RELTIME
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 // Set the time limit to 'redrawtime'.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 profile_setlimit(p_rdt, &(cur->hl.tm));
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 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
340 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
341 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
342 // 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
343 }
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 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 * 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
347 * Return zero otherwise.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 static int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 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
351 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
352 linenr_T lnum,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 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
354 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
355 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 int i;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 int found = -1;
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 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
360 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 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
362
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 == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 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
366 continue;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 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
368 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 if (found >= 0)
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 // 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
372 // them
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 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
374 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 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
376
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 *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
378 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
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 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 found = i;
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 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 posmatch->cur = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 if (found >= 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 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
389 ? 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
390 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
391 ? 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
392
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 shl->lnum = lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 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
395 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
396 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
397 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
398 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
399 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
400 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
401 return 1;
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 return 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 * 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
408 * Uses shl->buf.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 * 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
410 * 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
411 * 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
412 * 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
413 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 static void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 next_search_hl(
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 win_T *win,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 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
418 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
419 linenr_T lnum,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 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
421 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
422 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 linenr_T l;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 colnr_T matchcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 long nmatched;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 int called_emsg_before = called_emsg;
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 // 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
429 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
430 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 shl->lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 return;
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
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 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
436 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 // 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
438 // 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
439 // 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
440 // 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
441 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
442 if (lnum > l)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 shl->lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 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
445 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 // 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
449 // 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
450 for (;;)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 # ifdef FEAT_RELTIME
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 // Stop searching after passing the time limit.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 if (profile_passed_limit(&(shl->tm)))
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 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
457 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 // Three situations:
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 // 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
462 // 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
463 // 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
464 // 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
465 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
466 matchcol = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 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
468 || (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
469 && 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
470 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 char_u *ml;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 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
474 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
475 if (*ml == NUL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 ++matchcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 shl->lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 if (has_mbyte)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 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
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;
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 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 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
488
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 shl->lnum = lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 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
491 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 // 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
493 // cur->match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 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
495 && shl == &cur->hl
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 && 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
497 int timed_out = FALSE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 matchcol,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 #ifdef FEAT_RELTIME
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 &(shl->tm), &timed_out
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 #else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 NULL, NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 #endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 );
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 // 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
508 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
509 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
510
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 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
512 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 // 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
514 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
515 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 // 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
517 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
518 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
519 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 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
521 shl->lnum = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 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
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 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 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
527 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
528 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 nmatched = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 if (nmatched == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 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
533 break;
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 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
536 || 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
537 || nmatched > 1
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 || 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
539 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 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
541 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
542 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 * 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
548 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 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
551 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 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
553 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
554 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
555 // 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
556 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
557 // in progress
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 int n;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 // 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
561 // 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
562 // 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
563 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
564 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
565 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
566 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 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
568 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 shl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 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
575 && shl->lnum == 0
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 && 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
577 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 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
579 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 # ifdef FEAT_FOLDING
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 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
582 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
583 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
584 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
585 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 # else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 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
588 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 if (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 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
592 pos_inprogress = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 n = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 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
595 || (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
596 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 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
598 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
599 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
600 ? FALSE : TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 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
602 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 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
604 + 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
605 - 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
606 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
607 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 else
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 ++shl->first_lnum;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 n = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 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
616 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 * 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
622 * 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
623 * current highlight attribute.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626 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
627 win_T *wp,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 linenr_T lnum,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 colnr_T mincol,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 char_u **line,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 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
632 int *search_attr)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 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
635 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
636 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
637 // 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
638 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
639
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 // 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
641 // 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
642 // 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
643 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
644 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
645 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
646 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 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
648 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 shl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 shl->startcol = MAXCOL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 shl->endcol = MAXCOL;
28399
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
656 shl->lines = 0;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 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
658 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
659 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
660 if (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 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
662 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
663 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
664
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 // 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
666 // invalid.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 *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
668
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 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
670 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 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
672 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
673 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 shl->startcol = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 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
676 - 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
677 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
678 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 shl->endcol = MAXCOL;
28399
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
680 if (shl->rm.endpos[0].lnum != shl->rm.startpos[0].lnum)
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
681 shl->lines = shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
682 else
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
683 shl->lines = 1;
28469
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
684
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
685 // check if the cursor is in the match before changing the columns
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
686 if (wp->w_cursor.lnum >= shl->lnum
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
687 && wp->w_cursor.lnum
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
688 <= shl->lnum + shl->rm.endpos[0].lnum
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
689 && (wp->w_cursor.lnum > shl->lnum
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
690 || wp->w_cursor.col >= shl->rm.startpos[0].col)
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
691 && (wp->w_cursor.lnum < shl->lnum + shl->lines
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
692 || wp->w_cursor.col < shl->rm.endpos[0].col))
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
693 shl->has_cursor = TRUE;
9ff0e5a29037 patch 8.2.4759: CurSearch highlight does not work for multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 28399
diff changeset
694
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 // 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
696 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
697 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 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
699 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
700 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 ++shl->endcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703 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
704 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 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
706 *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
707 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 area_highlighting = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 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
711 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
712 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 return area_highlighting;
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 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 * 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
718 * matches.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 * 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
720 * 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
721 * 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
722 * "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
723 * is endcol.
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 * 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
725 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 update_search_hl(
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 win_T *wp,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 linenr_T lnum,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730 colnr_T col,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 char_u **line,
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 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
733 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
734 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
735 int did_line_attr,
26334
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
736 int lcs_eol_one,
baec4e1cee43 patch 8.2.3698: match highlighting continues over breakindent
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
737 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
738 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
739 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
740 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
741 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
742 // 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
743 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
744 // progress
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 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
746
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 // 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
749 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
750 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
751 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
752 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753 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
754 && (cur == NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 || 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
756 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 shl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 if (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 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
764 pos_inprogress = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 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
766 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 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
768 && col >= shl->startcol
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 && col < shl->endcol)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771 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
772
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 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
774 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
775 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
776 # ifdef FEAT_CONCEAL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 // 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
778 // the match.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779 if (cur != NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 && shl != search_hl
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 && 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
782 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 *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
784 *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
785 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 *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
788 # 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
789 // 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
790 // 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
791 if (shl == search_hl && shl->has_cursor)
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);
d395fadbaf67 patch 8.2.4724: current instance of last search pattern not easily spotted
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
793
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
794 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795 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
796 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797 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
798 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
799 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
800 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
801
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802 // 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
803 // made it invalid.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
804 *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
805
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
806 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
807 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808 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
809 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
810 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
811 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 shl->endcol = MAXCOL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
813
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
814 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
815 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816 // 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
817 // it
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 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
819 {
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
820 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
821
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
822 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
823 // 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
824 ++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
825 else
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
826 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
827 }
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
829 ++shl->endcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
830 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
831
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
832 // 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
833 // current position
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
834 continue;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
835 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
837 break;
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 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
840 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 }
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 // 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
844 // the match list.
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 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
846 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
847 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
848 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849 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
850 && (cur == NULL ||
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 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
852 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 shl_flag = TRUE;
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 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 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
859 {
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 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
861 *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
862 }
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 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
864 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 // 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
867 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
868 || (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
869 search_attr = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 return search_attr;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 }
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 int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 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
875 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 long prevcol = curcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 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
878 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
879
24000
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
880 #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
881 // 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
882 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
883 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
884 #endif
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
885
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 // 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
887 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
888 ++prevcol;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889
24000
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
890 // 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
891 // 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
892 // (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
893 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
894 || (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
895 && 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
896 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
897 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899 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
900 while (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 {
24000
bb2e921d2601 patch 8.2.2542: highlight of char beyond line end is not correct
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
902 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
903 || (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
904 && 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
905 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 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
907 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 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
913 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914
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 * 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
917 * or match highlighting.
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 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 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
921 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 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
923 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
924 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
925 // 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
926
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 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
928 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
929 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
930 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 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
932 && ((cur != NULL
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 && 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
934 || cur == NULL))
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 shl = search_hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 shl_flag = TRUE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 shl = &cur->hl;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 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
942 && (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
943 *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
944 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
945 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 #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
950
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 #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
952 # 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
953 static int
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 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
955 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 dictitem_T *di;
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 (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
959 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
960 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
961 return FAIL;
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
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
964 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
965 *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
966 (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
967
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 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
969 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 *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
971 if (*win == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 {
26887
612339679616 patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
973 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
974 return FAIL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975 }
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
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 return OK;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
980 #endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981
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 * "clearmatches()" function
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 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986 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
987 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988 #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
989 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
990
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
991 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
992 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
993
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
994 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
995 if (win != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 clear_matches(win);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997 #endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001 * "getmatches()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 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
1005 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 # 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
1007 dict_T *dict;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008 matchitem_T *cur;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009 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
1010 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
1011
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
1012 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
1013 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
1014
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
1015 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
1016 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
1017 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019 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
1020 while (cur != NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 dict = dict_alloc();
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 if (dict == 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 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
1026 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027 // 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
1028 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
1029 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030 llpos_T *llpos;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 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
1032 list_T *l;
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 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
1035 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
1036 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 l = list_alloc();
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 if (l == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040 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
1041 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
1042 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 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
1044 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
1045 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 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
1047 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
1048 }
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 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 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
1053 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 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
1055 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
1056 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
1057 # 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
1058 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
1059 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 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
1061
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26964
diff changeset
1062 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
1063 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
1064 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 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
1067 cur = cur->next;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1069 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1070 }
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 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073 * "setmatches()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076 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
1077 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 #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
1079 list_T *l;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 listitem_T *li;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 dict_T *d;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 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
1083 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
1084
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085 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
1086
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1087 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
1088 && (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
1089 || 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
1090 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1091
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092 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
1093 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
1094 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
1095 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096 }
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 24000
diff changeset
1097 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
1098 if (win == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1101 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
1102 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 // 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
1104 // "getmatches()".
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105 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
1106 while (li != NULL)
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 (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
1109 || (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
1110 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
1111 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
1112 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 }
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
1114 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
1115 && (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
1116 || 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
1117 && 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
1118 && 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
1119 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
1120 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
1121 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1122 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 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
1124 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 clear_matches(win);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1127 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
1128 while (li != NULL)
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 int i = 0;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131 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
1132 dictitem_T *di;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1133 char_u *group;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1134 int priority;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 int id;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 char_u *conceal;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1138 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
1139 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
1140 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141 if (s == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 s = list_alloc();
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144 if (s == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 }
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 // match from matchaddpos()
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 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
1150 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151 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
1152 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
1153 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 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
1155 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 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
1158 s->lv_refcount++;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 break;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 }
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
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165 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
1166 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
1167 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
1168 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
1169 ? 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
1170 : NULL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171 if (i == 0)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 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
1174 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
1175 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
1176 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179 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
1180 list_unref(s);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181 s = NULL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 vim_free(group);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 vim_free(conceal);
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 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
1187 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1188 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
1189 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 #endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191 }
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 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1194 * "matchadd()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 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
1198 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1199 # 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
1200 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
1201 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
1202 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
1203 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
1204 int id = -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 int error = FALSE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1206 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
1207 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
1208
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1209 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
1210
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1211 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
1212 && (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
1213 || 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
1214 || 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
1215 || (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
1216 && (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
1217 || (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
1218 && 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
1219 return;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1220
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1221 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
1222 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
1223 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
1224 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225 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
1226 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1227 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
1228 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
1229 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1230 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
1231 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
1232 && 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
1233 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1234 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1235 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1236 if (error == TRUE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1237 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1238 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
1239 {
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26897
diff changeset
1240 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
1241 return;
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
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1244 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
1245 conceal_char);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1246 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1247 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1248
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 * "matchaddpos()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1251 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1252 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1253 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
1254 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255 # 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
1256 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
1257 char_u *group;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 int prio = 10;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259 int id = -1;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1260 int error = FALSE;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 list_T *l;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1262 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
1263 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
1264
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 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
1266
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1267 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
1268 && (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
1269 || 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
1270 || 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
1271 || (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
1272 && (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
1273 || (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
1274 && 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
1275 return;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
1276
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1277 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
1278 if (group == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1279 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1281 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
1282 {
26887
612339679616 patch 8.2.3972: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
1283 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
1284 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1286 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
1287 if (l == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1288 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290 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
1291 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1292 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
1293 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
1294 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295 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
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[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
1298 && 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
1299 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1300 }
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 if (error == TRUE)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305 // 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
1306 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
1307 {
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26897
diff changeset
1308 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
1309 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1310 }
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 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
1313 conceal_char);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1315 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1316
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 * "matcharg()" function
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1319 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1320 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1321 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
1322 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1323 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
1324 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1325 # 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
1326 int id;
21054
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1327 matchitem_T *m;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1328
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
1329 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
1330 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
1331
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
1332 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
1333 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
1334 {
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26964
diff changeset
1335 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
1336 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1337 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
1338 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
1339 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
1340 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1341 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1342 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1343 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
1344 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
1345 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1346 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1347 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1348 }
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
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1351 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1352 * "matchdelete()" function
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 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1355 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
1356 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1357 # 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
1358 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
1359
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
1360 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
1361 && (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
1362 || 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
1363 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
1364
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 = 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
1366 if (win == NULL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1367 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
1368 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1369 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
1370 (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
1371 # endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1372 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1373 #endif
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1374
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1375 #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
1376 /*
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1377 * ":[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
1378 * 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
1379 * 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
1380 */
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1381 void
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1382 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
1383 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1384 char_u *p;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1385 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
1386 char_u *end;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1387 int c;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1388 int id;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1389
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1390 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
1391 id = eap->line2;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1392 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1393 {
21821
0deb6f96a5a3 patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 21459
diff changeset
1394 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
1395 return;
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
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1398 // 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
1399 if (!eap->skip)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1400 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
1401
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1402 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
1403 end = eap->arg;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1404 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
1405 && (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
1406 || 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
1407 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
1408 else
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1409 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1410 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
1411 if (!eap->skip)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1412 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
1413 p = skipwhite(p);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1414 if (*p == NUL)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1415 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1416 // 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
1417 vim_free(g);
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
1418 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
1419 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1420 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1421 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
1422 if (!eap->skip)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1423 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1424 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
1425 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1426 vim_free(g);
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
1427 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
1428 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1429 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1430 if (*end != *p)
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1431 {
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1432 vim_free(g);
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26823
diff changeset
1433 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
1434 return;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1435 }
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 c = *end;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1438 *end = NUL;
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1439 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
1440 vim_free(g);
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1441 *end = c;
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 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
1445 }
b1fac55cf8a3 patch 8.2.1078: highlight and match functionality together in one file
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1446 #endif