|
|
22c937 |
To: vim_dev@googlegroups.com
|
|
|
22c937 |
Subject: Patch 7.4.330
|
|
|
22c937 |
Fcc: outbox
|
|
|
22c937 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
|
22c937 |
Mime-Version: 1.0
|
|
|
22c937 |
Content-Type: text/plain; charset=UTF-8
|
|
|
22c937 |
Content-Transfer-Encoding: 8bit
|
|
|
22c937 |
------------
|
|
|
22c937 |
|
|
|
22c937 |
Patch 7.4.330
|
|
|
22c937 |
Problem: Using a regexp pattern to highlight a specific position can be
|
|
|
22c937 |
slow.
|
|
|
22c937 |
Solution: Add matchaddpos() to highlight specific positions efficiently.
|
|
|
22c937 |
(Alexey Radkov)
|
|
|
22c937 |
Files: runtime/doc/eval.txt, runtime/doc/usr_41.txt,
|
|
|
22c937 |
runtime/plugin/matchparen.vim, src/eval.c, src/ex_docmd.c,
|
|
|
22c937 |
src/proto/window.pro, src/screen.c, src/structs.h,
|
|
|
22c937 |
src/testdir/test63.in, src/testdir/test63.ok, src/window.c
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.329/runtime/doc/eval.txt 2014-05-28 20:31:37.500292805 +0200
|
|
|
22c937 |
--- runtime/doc/eval.txt 2014-06-17 16:31:35.572453748 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 1887,1892 ****
|
|
|
22c937 |
--- 1887,1894 ----
|
|
|
22c937 |
Number position where {pat} matches in {expr}
|
|
|
22c937 |
matchadd( {group}, {pattern}[, {priority}[, {id}]])
|
|
|
22c937 |
Number highlight {pattern} with {group}
|
|
|
22c937 |
+ matchaddpos( {group}, {list}[, {priority}[, {id}]])
|
|
|
22c937 |
+ Number highlight positions with {group}
|
|
|
22c937 |
matcharg( {nr}) List arguments of |:match|
|
|
|
22c937 |
matchdelete( {id}) Number delete match identified by {id}
|
|
|
22c937 |
matchend( {expr}, {pat}[, {start}[, {count}]])
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 4342,4347 ****
|
|
|
22c937 |
--- 4382,4422 ----
|
|
|
22c937 |
available from |getmatches()|. All matches can be deleted in
|
|
|
22c937 |
one operation by |clearmatches()|.
|
|
|
22c937 |
|
|
|
22c937 |
+ matchaddpos({group}, {pos}[, {priority}[, {id}]]) *matchaddpos()*
|
|
|
22c937 |
+ Same as |matchadd()|, but requires a list of positions {pos}
|
|
|
22c937 |
+ instead of a pattern. This command is faster than |matchadd()|
|
|
|
22c937 |
+ because it does not require to handle regular expressions and
|
|
|
22c937 |
+ sets buffer line boundaries to redraw screen. It is supposed
|
|
|
22c937 |
+ to be used when fast match additions and deletions are
|
|
|
22c937 |
+ required, for example to highlight matching parentheses.
|
|
|
22c937 |
+
|
|
|
22c937 |
+ The list {pos} can contain one of these items:
|
|
|
22c937 |
+ - A number. This while line will be highlighted. The first
|
|
|
22c937 |
+ line has number 1.
|
|
|
22c937 |
+ - A list with one number, e.g., [23]. The whole line with this
|
|
|
22c937 |
+ number will be highlighted.
|
|
|
22c937 |
+ - A list with two numbers, e.g., [23, 11]. The first number is
|
|
|
22c937 |
+ the line number, the second one the column number (first
|
|
|
22c937 |
+ column is 1). The character at this position will be
|
|
|
22c937 |
+ highlighted.
|
|
|
22c937 |
+ - A list with three numbers, e.g., [23, 11, 3]. As above, but
|
|
|
22c937 |
+ the third number gives the length of the highlight in screen
|
|
|
22c937 |
+ cells.
|
|
|
22c937 |
+
|
|
|
22c937 |
+ The maximum number of positions is 8.
|
|
|
22c937 |
+
|
|
|
22c937 |
+ Example: >
|
|
|
22c937 |
+ :highlight MyGroup ctermbg=green guibg=green
|
|
|
22c937 |
+ :let m = matchaddpos("MyGroup", [[23, 24], 34])
|
|
|
22c937 |
+ < Deletion of the pattern: >
|
|
|
22c937 |
+ :call matchdelete(m)
|
|
|
22c937 |
+
|
|
|
22c937 |
+ < Matches added by |matchaddpos()| are returned by
|
|
|
22c937 |
+ |getmatches()| with an entry "pos1", "pos2", etc., with the
|
|
|
22c937 |
+ value a list like the {pos} item.
|
|
|
22c937 |
+ These matches cannot be set via |setmatches()|, however they
|
|
|
22c937 |
+ can still be deleted by |clearmatches()|.
|
|
|
22c937 |
+
|
|
|
22c937 |
matcharg({nr}) *matcharg()*
|
|
|
22c937 |
Selects the {nr} match item, as set with a |:match|,
|
|
|
22c937 |
|:2match| or |:3match| command.
|
|
|
22c937 |
*** ../vim-7.4.329/runtime/doc/usr_41.txt 2014-05-28 18:22:37.872225054 +0200
|
|
|
22c937 |
--- runtime/doc/usr_41.txt 2014-06-17 14:06:44.836124965 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 824,829 ****
|
|
|
22c937 |
--- 827,833 ----
|
|
|
22c937 |
synconcealed() get info about concealing
|
|
|
22c937 |
diff_hlID() get highlight ID for diff mode at a position
|
|
|
22c937 |
matchadd() define a pattern to highlight (a "match")
|
|
|
22c937 |
+ matchaddpos() define a list of positions to highlight
|
|
|
22c937 |
matcharg() get info about |:match| arguments
|
|
|
22c937 |
matchdelete() delete a match defined by |matchadd()| or a
|
|
|
22c937 |
|:match| command
|
|
|
22c937 |
*** ../vim-7.4.329/runtime/plugin/matchparen.vim 2013-05-08 05:15:53.000000000 +0200
|
|
|
22c937 |
--- runtime/plugin/matchparen.vim 2014-06-17 14:14:45.712143158 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 1,6 ****
|
|
|
22c937 |
" Vim plugin for showing matching parens
|
|
|
22c937 |
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
|
|
22c937 |
! " Last Change: 2013 May 08
|
|
|
22c937 |
|
|
|
22c937 |
" Exit quickly when:
|
|
|
22c937 |
" - this plugin was already loaded (or disabled)
|
|
|
22c937 |
--- 1,6 ----
|
|
|
22c937 |
" Vim plugin for showing matching parens
|
|
|
22c937 |
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
|
|
22c937 |
! " Last Change: 2014 Jun 17
|
|
|
22c937 |
|
|
|
22c937 |
" Exit quickly when:
|
|
|
22c937 |
" - this plugin was already loaded (or disabled)
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 39,45 ****
|
|
|
22c937 |
function! s:Highlight_Matching_Pair()
|
|
|
22c937 |
" Remove any previous match.
|
|
|
22c937 |
if exists('w:paren_hl_on') && w:paren_hl_on
|
|
|
22c937 |
! 3match none
|
|
|
22c937 |
let w:paren_hl_on = 0
|
|
|
22c937 |
endif
|
|
|
22c937 |
|
|
|
22c937 |
--- 39,45 ----
|
|
|
22c937 |
function! s:Highlight_Matching_Pair()
|
|
|
22c937 |
" Remove any previous match.
|
|
|
22c937 |
if exists('w:paren_hl_on') && w:paren_hl_on
|
|
|
22c937 |
! silent! call matchdelete(3)
|
|
|
22c937 |
let w:paren_hl_on = 0
|
|
|
22c937 |
endif
|
|
|
22c937 |
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 152,165 ****
|
|
|
22c937 |
|
|
|
22c937 |
" If a match is found setup match highlighting.
|
|
|
22c937 |
if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom
|
|
|
22c937 |
! exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
|
|
|
22c937 |
! \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
|
|
|
22c937 |
let w:paren_hl_on = 1
|
|
|
22c937 |
endif
|
|
|
22c937 |
endfunction
|
|
|
22c937 |
|
|
|
22c937 |
" Define commands that will disable and enable the plugin.
|
|
|
22c937 |
! command! NoMatchParen windo 3match none | unlet! g:loaded_matchparen |
|
|
|
22c937 |
\ au! matchparen
|
|
|
22c937 |
command! DoMatchParen runtime plugin/matchparen.vim | windo doau CursorMoved
|
|
|
22c937 |
|
|
|
22c937 |
--- 152,169 ----
|
|
|
22c937 |
|
|
|
22c937 |
" If a match is found setup match highlighting.
|
|
|
22c937 |
if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom
|
|
|
22c937 |
! if exists('*matchaddpos')
|
|
|
22c937 |
! call matchaddpos('MatchParen', [[c_lnum, c_col - before], [m_lnum, m_col]], 10, 3)
|
|
|
22c937 |
! else
|
|
|
22c937 |
! exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
|
|
|
22c937 |
! \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
|
|
|
22c937 |
! endif
|
|
|
22c937 |
let w:paren_hl_on = 1
|
|
|
22c937 |
endif
|
|
|
22c937 |
endfunction
|
|
|
22c937 |
|
|
|
22c937 |
" Define commands that will disable and enable the plugin.
|
|
|
22c937 |
! command! NoMatchParen windo silent! call matchdelete(3) | unlet! g:loaded_matchparen |
|
|
|
22c937 |
\ au! matchparen
|
|
|
22c937 |
command! DoMatchParen runtime plugin/matchparen.vim | windo doau CursorMoved
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.329/src/eval.c 2014-06-17 12:51:13.207953527 +0200
|
|
|
22c937 |
--- src/eval.c 2014-06-17 17:02:25.388523729 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 622,627 ****
|
|
|
22c937 |
--- 622,628 ----
|
|
|
22c937 |
static void f_mapcheck __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
static void f_match __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
static void f_matchadd __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
+ static void f_matchaddpos __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
static void f_matcharg __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
static void f_matchdelete __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
static void f_matchend __ARGS((typval_T *argvars, typval_T *rettv));
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 8054,8059 ****
|
|
|
22c937 |
--- 8055,8061 ----
|
|
|
22c937 |
{"mapcheck", 1, 3, f_mapcheck},
|
|
|
22c937 |
{"match", 2, 4, f_match},
|
|
|
22c937 |
{"matchadd", 2, 4, f_matchadd},
|
|
|
22c937 |
+ {"matchaddpos", 2, 4, f_matchaddpos},
|
|
|
22c937 |
{"matcharg", 1, 1, f_matcharg},
|
|
|
22c937 |
{"matchdelete", 1, 1, f_matchdelete},
|
|
|
22c937 |
{"matchend", 2, 4, f_matchend},
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 11767,11772 ****
|
|
|
22c937 |
--- 11769,11775 ----
|
|
|
22c937 |
#ifdef FEAT_SEARCH_EXTRA
|
|
|
22c937 |
dict_T *dict;
|
|
|
22c937 |
matchitem_T *cur = curwin->w_match_head;
|
|
|
22c937 |
+ int i;
|
|
|
22c937 |
|
|
|
22c937 |
if (rettv_list_alloc(rettv) == OK)
|
|
|
22c937 |
{
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 11775,11782 ****
|
|
|
22c937 |
dict = dict_alloc();
|
|
|
22c937 |
if (dict == NULL)
|
|
|
22c937 |
return;
|
|
|
22c937 |
dict_add_nr_str(dict, "group", 0L, syn_id2name(cur->hlg_id));
|
|
|
22c937 |
- dict_add_nr_str(dict, "pattern", 0L, cur->pattern);
|
|
|
22c937 |
dict_add_nr_str(dict, "priority", (long)cur->priority, NULL);
|
|
|
22c937 |
dict_add_nr_str(dict, "id", (long)cur->id, NULL);
|
|
|
22c937 |
list_append_dict(rettv->vval.v_list, dict);
|
|
|
22c937 |
--- 11778,11813 ----
|
|
|
22c937 |
dict = dict_alloc();
|
|
|
22c937 |
if (dict == NULL)
|
|
|
22c937 |
return;
|
|
|
22c937 |
+ if (cur->match.regprog == NULL)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ /* match added with matchaddpos() */
|
|
|
22c937 |
+ for (i = 0; i < MAXPOSMATCH; ++i)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ llpos_T *llpos;
|
|
|
22c937 |
+ char buf[6];
|
|
|
22c937 |
+ list_T *l;
|
|
|
22c937 |
+
|
|
|
22c937 |
+ llpos = &cur->pos.pos[i];
|
|
|
22c937 |
+ if (llpos->lnum == 0)
|
|
|
22c937 |
+ break;
|
|
|
22c937 |
+ l = list_alloc();
|
|
|
22c937 |
+ if (l == NULL)
|
|
|
22c937 |
+ break;
|
|
|
22c937 |
+ list_append_number(l, (varnumber_T)llpos->lnum);
|
|
|
22c937 |
+ if (llpos->col > 0)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ list_append_number(l, (varnumber_T)llpos->col);
|
|
|
22c937 |
+ list_append_number(l, (varnumber_T)llpos->len);
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ sprintf(buf, "pos%d", i + 1);
|
|
|
22c937 |
+ dict_add_list(dict, buf, l);
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ else
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ dict_add_nr_str(dict, "pattern", 0L, cur->pattern);
|
|
|
22c937 |
+ }
|
|
|
22c937 |
dict_add_nr_str(dict, "group", 0L, syn_id2name(cur->hlg_id));
|
|
|
22c937 |
dict_add_nr_str(dict, "priority", (long)cur->priority, NULL);
|
|
|
22c937 |
dict_add_nr_str(dict, "id", (long)cur->id, NULL);
|
|
|
22c937 |
list_append_dict(rettv->vval.v_list, dict);
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 14313,14319 ****
|
|
|
22c937 |
return;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
! rettv->vval.v_number = match_add(curwin, grp, pat, prio, id);
|
|
|
22c937 |
#endif
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
--- 14344,14401 ----
|
|
|
22c937 |
return;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
! rettv->vval.v_number = match_add(curwin, grp, pat, prio, id, NULL);
|
|
|
22c937 |
! #endif
|
|
|
22c937 |
! }
|
|
|
22c937 |
!
|
|
|
22c937 |
! /*
|
|
|
22c937 |
! * "matchaddpos()" function
|
|
|
22c937 |
! */
|
|
|
22c937 |
! static void
|
|
|
22c937 |
! f_matchaddpos(argvars, rettv)
|
|
|
22c937 |
! typval_T *argvars UNUSED;
|
|
|
22c937 |
! typval_T *rettv UNUSED;
|
|
|
22c937 |
! {
|
|
|
22c937 |
! #ifdef FEAT_SEARCH_EXTRA
|
|
|
22c937 |
! char_u buf[NUMBUFLEN];
|
|
|
22c937 |
! char_u *group;
|
|
|
22c937 |
! int prio = 10;
|
|
|
22c937 |
! int id = -1;
|
|
|
22c937 |
! int error = FALSE;
|
|
|
22c937 |
! list_T *l;
|
|
|
22c937 |
!
|
|
|
22c937 |
! rettv->vval.v_number = -1;
|
|
|
22c937 |
!
|
|
|
22c937 |
! group = get_tv_string_buf_chk(&argvars[0], buf);
|
|
|
22c937 |
! if (group == NULL)
|
|
|
22c937 |
! return;
|
|
|
22c937 |
!
|
|
|
22c937 |
! if (argvars[1].v_type != VAR_LIST)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! EMSG2(_(e_listarg), "matchaddpos()");
|
|
|
22c937 |
! return;
|
|
|
22c937 |
! }
|
|
|
22c937 |
! l = argvars[1].vval.v_list;
|
|
|
22c937 |
! if (l == NULL)
|
|
|
22c937 |
! return;
|
|
|
22c937 |
!
|
|
|
22c937 |
! if (argvars[2].v_type != VAR_UNKNOWN)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! prio = get_tv_number_chk(&argvars[2], &error);
|
|
|
22c937 |
! if (argvars[3].v_type != VAR_UNKNOWN)
|
|
|
22c937 |
! id = get_tv_number_chk(&argvars[3], &error);
|
|
|
22c937 |
! }
|
|
|
22c937 |
! if (error == TRUE)
|
|
|
22c937 |
! return;
|
|
|
22c937 |
!
|
|
|
22c937 |
! /* id == 3 is ok because matchaddpos() is supposed to substitute :3match */
|
|
|
22c937 |
! if (id == 1 || id == 2)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! EMSGN("E798: ID is reserved for \":match\": %ld", id);
|
|
|
22c937 |
! return;
|
|
|
22c937 |
! }
|
|
|
22c937 |
!
|
|
|
22c937 |
! rettv->vval.v_number = match_add(curwin, group, NULL, prio, id, l);
|
|
|
22c937 |
#endif
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 16816,16822 ****
|
|
|
22c937 |
match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
|
|
|
22c937 |
get_dict_string(d, (char_u *)"pattern", FALSE),
|
|
|
22c937 |
(int)get_dict_number(d, (char_u *)"priority"),
|
|
|
22c937 |
! (int)get_dict_number(d, (char_u *)"id"));
|
|
|
22c937 |
li = li->li_next;
|
|
|
22c937 |
}
|
|
|
22c937 |
rettv->vval.v_number = 0;
|
|
|
22c937 |
--- 16898,16904 ----
|
|
|
22c937 |
match_add(curwin, get_dict_string(d, (char_u *)"group", FALSE),
|
|
|
22c937 |
get_dict_string(d, (char_u *)"pattern", FALSE),
|
|
|
22c937 |
(int)get_dict_number(d, (char_u *)"priority"),
|
|
|
22c937 |
! (int)get_dict_number(d, (char_u *)"id"), NULL);
|
|
|
22c937 |
li = li->li_next;
|
|
|
22c937 |
}
|
|
|
22c937 |
rettv->vval.v_number = 0;
|
|
|
22c937 |
*** ../vim-7.4.329/src/ex_docmd.c 2014-05-28 18:22:37.876225054 +0200
|
|
|
22c937 |
--- src/ex_docmd.c 2014-06-17 14:06:44.844124966 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 11489,11495 ****
|
|
|
22c937 |
|
|
|
22c937 |
c = *end;
|
|
|
22c937 |
*end = NUL;
|
|
|
22c937 |
! match_add(curwin, g, p + 1, 10, id);
|
|
|
22c937 |
vim_free(g);
|
|
|
22c937 |
*end = c;
|
|
|
22c937 |
}
|
|
|
22c937 |
--- 11489,11495 ----
|
|
|
22c937 |
|
|
|
22c937 |
c = *end;
|
|
|
22c937 |
*end = NUL;
|
|
|
22c937 |
! match_add(curwin, g, p + 1, 10, id, NULL);
|
|
|
22c937 |
vim_free(g);
|
|
|
22c937 |
*end = c;
|
|
|
22c937 |
}
|
|
|
22c937 |
*** ../vim-7.4.329/src/proto/window.pro 2013-08-14 17:11:14.000000000 +0200
|
|
|
22c937 |
--- src/proto/window.pro 2014-06-17 14:06:44.844124966 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 75,81 ****
|
|
|
22c937 |
void switch_buffer __ARGS((buf_T **save_curbuf, buf_T *buf));
|
|
|
22c937 |
void restore_buffer __ARGS((buf_T *save_curbuf));
|
|
|
22c937 |
int win_hasvertsplit __ARGS((void));
|
|
|
22c937 |
! int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id));
|
|
|
22c937 |
int match_delete __ARGS((win_T *wp, int id, int perr));
|
|
|
22c937 |
void clear_matches __ARGS((win_T *wp));
|
|
|
22c937 |
matchitem_T *get_match __ARGS((win_T *wp, int id));
|
|
|
22c937 |
--- 75,81 ----
|
|
|
22c937 |
void switch_buffer __ARGS((buf_T **save_curbuf, buf_T *buf));
|
|
|
22c937 |
void restore_buffer __ARGS((buf_T *save_curbuf));
|
|
|
22c937 |
int win_hasvertsplit __ARGS((void));
|
|
|
22c937 |
! int match_add __ARGS((win_T *wp, char_u *grp, char_u *pat, int prio, int id, list_T *pos));
|
|
|
22c937 |
int match_delete __ARGS((win_T *wp, int id, int perr));
|
|
|
22c937 |
void clear_matches __ARGS((win_T *wp));
|
|
|
22c937 |
matchitem_T *get_match __ARGS((win_T *wp, int id));
|
|
|
22c937 |
*** ../vim-7.4.329/src/screen.c 2014-05-28 21:40:47.092329130 +0200
|
|
|
22c937 |
--- src/screen.c 2014-06-17 17:04:08.064527614 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 144,150 ****
|
|
|
22c937 |
static void end_search_hl __ARGS((void));
|
|
|
22c937 |
static void init_search_hl __ARGS((win_T *wp));
|
|
|
22c937 |
static void prepare_search_hl __ARGS((win_T *wp, linenr_T lnum));
|
|
|
22c937 |
! static void next_search_hl __ARGS((win_T *win, match_T *shl, linenr_T lnum, colnr_T mincol));
|
|
|
22c937 |
#endif
|
|
|
22c937 |
static void screen_start_highlight __ARGS((int attr));
|
|
|
22c937 |
static void screen_char __ARGS((unsigned off, int row, int col));
|
|
|
22c937 |
--- 144,151 ----
|
|
|
22c937 |
static void end_search_hl __ARGS((void));
|
|
|
22c937 |
static void init_search_hl __ARGS((win_T *wp));
|
|
|
22c937 |
static void prepare_search_hl __ARGS((win_T *wp, linenr_T lnum));
|
|
|
22c937 |
! static void next_search_hl __ARGS((win_T *win, match_T *shl, linenr_T lnum, colnr_T mincol, matchitem_T *cur));
|
|
|
22c937 |
! static int next_search_hl_pos __ARGS((match_T *shl, linenr_T lnum, posmatch_T *pos, colnr_T mincol));
|
|
|
22c937 |
#endif
|
|
|
22c937 |
static void screen_start_highlight __ARGS((int attr));
|
|
|
22c937 |
static void screen_char __ARGS((unsigned off, int row, int col));
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 2929,2934 ****
|
|
|
22c937 |
--- 2930,2937 ----
|
|
|
22c937 |
match_T *shl; /* points to search_hl or a match */
|
|
|
22c937 |
int shl_flag; /* flag to indicate whether search_hl
|
|
|
22c937 |
has been processed or not */
|
|
|
22c937 |
+ int pos_inprogress; /* marks that position match search is
|
|
|
22c937 |
+ in progress */
|
|
|
22c937 |
int prevcol_hl_flag; /* flag to indicate whether prevcol
|
|
|
22c937 |
equals startcol of search_hl or one
|
|
|
22c937 |
of the matches */
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 3439,3482 ****
|
|
|
22c937 |
shl->startcol = MAXCOL;
|
|
|
22c937 |
shl->endcol = MAXCOL;
|
|
|
22c937 |
shl->attr_cur = 0;
|
|
|
22c937 |
! if (shl->rm.regprog != NULL)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! v = (long)(ptr - line);
|
|
|
22c937 |
! next_search_hl(wp, shl, lnum, (colnr_T)v);
|
|
|
22c937 |
!
|
|
|
22c937 |
! /* Need to get the line again, a multi-line regexp may have made it
|
|
|
22c937 |
! * invalid. */
|
|
|
22c937 |
! line = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
|
|
22c937 |
! ptr = line + v;
|
|
|
22c937 |
|
|
|
22c937 |
! if (shl->lnum != 0 && shl->lnum <= lnum)
|
|
|
22c937 |
{
|
|
|
22c937 |
- if (shl->lnum == lnum)
|
|
|
22c937 |
- shl->startcol = shl->rm.startpos[0].col;
|
|
|
22c937 |
- else
|
|
|
22c937 |
- shl->startcol = 0;
|
|
|
22c937 |
- if (lnum == shl->lnum + shl->rm.endpos[0].lnum
|
|
|
22c937 |
- - shl->rm.startpos[0].lnum)
|
|
|
22c937 |
- shl->endcol = shl->rm.endpos[0].col;
|
|
|
22c937 |
- else
|
|
|
22c937 |
- shl->endcol = MAXCOL;
|
|
|
22c937 |
- /* Highlight one character for an empty match. */
|
|
|
22c937 |
- if (shl->startcol == shl->endcol)
|
|
|
22c937 |
- {
|
|
|
22c937 |
#ifdef FEAT_MBYTE
|
|
|
22c937 |
! if (has_mbyte && line[shl->endcol] != NUL)
|
|
|
22c937 |
! shl->endcol += (*mb_ptr2len)(line + shl->endcol);
|
|
|
22c937 |
! else
|
|
|
22c937 |
#endif
|
|
|
22c937 |
! ++shl->endcol;
|
|
|
22c937 |
! }
|
|
|
22c937 |
! if ((long)shl->startcol < v) /* match at leftcol */
|
|
|
22c937 |
! {
|
|
|
22c937 |
! shl->attr_cur = shl->attr;
|
|
|
22c937 |
! search_attr = shl->attr;
|
|
|
22c937 |
! }
|
|
|
22c937 |
! area_highlighting = TRUE;
|
|
|
22c937 |
}
|
|
|
22c937 |
}
|
|
|
22c937 |
if (shl != &search_hl && cur != NULL)
|
|
|
22c937 |
cur = cur->next;
|
|
|
22c937 |
--- 3442,3484 ----
|
|
|
22c937 |
shl->startcol = MAXCOL;
|
|
|
22c937 |
shl->endcol = MAXCOL;
|
|
|
22c937 |
shl->attr_cur = 0;
|
|
|
22c937 |
! v = (long)(ptr - line);
|
|
|
22c937 |
! if (cur != NULL)
|
|
|
22c937 |
! cur->pos.cur = 0;
|
|
|
22c937 |
! next_search_hl(wp, shl, lnum, (colnr_T)v, cur);
|
|
|
22c937 |
!
|
|
|
22c937 |
! /* Need to get the line again, a multi-line regexp may have made it
|
|
|
22c937 |
! * invalid. */
|
|
|
22c937 |
! line = ml_get_buf(wp->w_buffer, lnum, FALSE);
|
|
|
22c937 |
! ptr = line + v;
|
|
|
22c937 |
|
|
|
22c937 |
! if (shl->lnum != 0 && shl->lnum <= lnum)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! if (shl->lnum == lnum)
|
|
|
22c937 |
! shl->startcol = shl->rm.startpos[0].col;
|
|
|
22c937 |
! else
|
|
|
22c937 |
! shl->startcol = 0;
|
|
|
22c937 |
! if (lnum == shl->lnum + shl->rm.endpos[0].lnum
|
|
|
22c937 |
! - shl->rm.startpos[0].lnum)
|
|
|
22c937 |
! shl->endcol = shl->rm.endpos[0].col;
|
|
|
22c937 |
! else
|
|
|
22c937 |
! shl->endcol = MAXCOL;
|
|
|
22c937 |
! /* Highlight one character for an empty match. */
|
|
|
22c937 |
! if (shl->startcol == shl->endcol)
|
|
|
22c937 |
{
|
|
|
22c937 |
#ifdef FEAT_MBYTE
|
|
|
22c937 |
! if (has_mbyte && line[shl->endcol] != NUL)
|
|
|
22c937 |
! shl->endcol += (*mb_ptr2len)(line + shl->endcol);
|
|
|
22c937 |
! else
|
|
|
22c937 |
#endif
|
|
|
22c937 |
! ++shl->endcol;
|
|
|
22c937 |
}
|
|
|
22c937 |
+ if ((long)shl->startcol < v) /* match at leftcol */
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ shl->attr_cur = shl->attr;
|
|
|
22c937 |
+ search_attr = shl->attr;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ area_highlighting = TRUE;
|
|
|
22c937 |
}
|
|
|
22c937 |
if (shl != &search_hl && cur != NULL)
|
|
|
22c937 |
cur = cur->next;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 3488,3494 ****
|
|
|
22c937 |
* when Visual mode is active, because it's not clear what is selected
|
|
|
22c937 |
* then. */
|
|
|
22c937 |
if (wp->w_p_cul && lnum == wp->w_cursor.lnum
|
|
|
22c937 |
! && !(wp == curwin && VIsual_active))
|
|
|
22c937 |
{
|
|
|
22c937 |
line_attr = hl_attr(HLF_CUL);
|
|
|
22c937 |
area_highlighting = TRUE;
|
|
|
22c937 |
--- 3490,3496 ----
|
|
|
22c937 |
* when Visual mode is active, because it's not clear what is selected
|
|
|
22c937 |
* then. */
|
|
|
22c937 |
if (wp->w_p_cul && lnum == wp->w_cursor.lnum
|
|
|
22c937 |
! && !(wp == curwin && VIsual_active))
|
|
|
22c937 |
{
|
|
|
22c937 |
line_attr = hl_attr(HLF_CUL);
|
|
|
22c937 |
area_highlighting = TRUE;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 3792,3798 ****
|
|
|
22c937 |
}
|
|
|
22c937 |
else
|
|
|
22c937 |
shl = &cur->hl;
|
|
|
22c937 |
! while (shl->rm.regprog != NULL)
|
|
|
22c937 |
{
|
|
|
22c937 |
if (shl->startcol != MAXCOL
|
|
|
22c937 |
&& v >= (long)shl->startcol
|
|
|
22c937 |
--- 3794,3804 ----
|
|
|
22c937 |
}
|
|
|
22c937 |
else
|
|
|
22c937 |
shl = &cur->hl;
|
|
|
22c937 |
! if (cur != NULL)
|
|
|
22c937 |
! cur->pos.cur = 0;
|
|
|
22c937 |
! pos_inprogress = TRUE;
|
|
|
22c937 |
! while (shl->rm.regprog != NULL
|
|
|
22c937 |
! || (cur != NULL && pos_inprogress))
|
|
|
22c937 |
{
|
|
|
22c937 |
if (shl->startcol != MAXCOL
|
|
|
22c937 |
&& v >= (long)shl->startcol
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 3803,3810 ****
|
|
|
22c937 |
else if (v == (long)shl->endcol)
|
|
|
22c937 |
{
|
|
|
22c937 |
shl->attr_cur = 0;
|
|
|
22c937 |
!
|
|
|
22c937 |
! next_search_hl(wp, shl, lnum, (colnr_T)v);
|
|
|
22c937 |
|
|
|
22c937 |
/* Need to get the line again, a multi-line regexp
|
|
|
22c937 |
* may have made it invalid. */
|
|
|
22c937 |
--- 3809,3817 ----
|
|
|
22c937 |
else if (v == (long)shl->endcol)
|
|
|
22c937 |
{
|
|
|
22c937 |
shl->attr_cur = 0;
|
|
|
22c937 |
! next_search_hl(wp, shl, lnum, (colnr_T)v, cur);
|
|
|
22c937 |
! pos_inprogress = cur == NULL || cur->pos.cur == 0
|
|
|
22c937 |
! ? FALSE : TRUE;
|
|
|
22c937 |
|
|
|
22c937 |
/* Need to get the line again, a multi-line regexp
|
|
|
22c937 |
* may have made it invalid. */
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 7277,7282 ****
|
|
|
22c937 |
--- 7284,7291 ----
|
|
|
22c937 |
match_T *shl; /* points to search_hl or a match */
|
|
|
22c937 |
int shl_flag; /* flag to indicate whether search_hl
|
|
|
22c937 |
has been processed or not */
|
|
|
22c937 |
+ int pos_inprogress; /* marks that position match search is
|
|
|
22c937 |
+ in progress */
|
|
|
22c937 |
int n;
|
|
|
22c937 |
|
|
|
22c937 |
/*
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 7311,7320 ****
|
|
|
22c937 |
shl->first_lnum = wp->w_topline;
|
|
|
22c937 |
# endif
|
|
|
22c937 |
}
|
|
|
22c937 |
n = 0;
|
|
|
22c937 |
! while (shl->first_lnum < lnum && shl->rm.regprog != NULL)
|
|
|
22c937 |
{
|
|
|
22c937 |
! next_search_hl(wp, shl, shl->first_lnum, (colnr_T)n);
|
|
|
22c937 |
if (shl->lnum != 0)
|
|
|
22c937 |
{
|
|
|
22c937 |
shl->first_lnum = shl->lnum
|
|
|
22c937 |
--- 7320,7335 ----
|
|
|
22c937 |
shl->first_lnum = wp->w_topline;
|
|
|
22c937 |
# endif
|
|
|
22c937 |
}
|
|
|
22c937 |
+ if (cur != NULL)
|
|
|
22c937 |
+ cur->pos.cur = 0;
|
|
|
22c937 |
+ pos_inprogress = TRUE;
|
|
|
22c937 |
n = 0;
|
|
|
22c937 |
! while (shl->first_lnum < lnum && (shl->rm.regprog != NULL
|
|
|
22c937 |
! || (cur != NULL && pos_inprogress)))
|
|
|
22c937 |
{
|
|
|
22c937 |
! next_search_hl(wp, shl, shl->first_lnum, (colnr_T)n, cur);
|
|
|
22c937 |
! pos_inprogress = cur == NULL || cur->pos.cur == 0
|
|
|
22c937 |
! ? FALSE : TRUE;
|
|
|
22c937 |
if (shl->lnum != 0)
|
|
|
22c937 |
{
|
|
|
22c937 |
shl->first_lnum = shl->lnum
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 7343,7353 ****
|
|
|
22c937 |
* Careful: Any pointers for buffer lines will become invalid.
|
|
|
22c937 |
*/
|
|
|
22c937 |
static void
|
|
|
22c937 |
! next_search_hl(win, shl, lnum, mincol)
|
|
|
22c937 |
! win_T *win;
|
|
|
22c937 |
! match_T *shl; /* points to search_hl or a match */
|
|
|
22c937 |
! linenr_T lnum;
|
|
|
22c937 |
! colnr_T mincol; /* minimal column for a match */
|
|
|
22c937 |
{
|
|
|
22c937 |
linenr_T l;
|
|
|
22c937 |
colnr_T matchcol;
|
|
|
22c937 |
--- 7358,7369 ----
|
|
|
22c937 |
* Careful: Any pointers for buffer lines will become invalid.
|
|
|
22c937 |
*/
|
|
|
22c937 |
static void
|
|
|
22c937 |
! next_search_hl(win, shl, lnum, mincol, cur)
|
|
|
22c937 |
! win_T *win;
|
|
|
22c937 |
! match_T *shl; /* points to search_hl or a match */
|
|
|
22c937 |
! linenr_T lnum;
|
|
|
22c937 |
! colnr_T mincol; /* minimal column for a match */
|
|
|
22c937 |
! matchitem_T *cur; /* to retrieve match postions if any */
|
|
|
22c937 |
{
|
|
|
22c937 |
linenr_T l;
|
|
|
22c937 |
colnr_T matchcol;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 7415,7440 ****
|
|
|
22c937 |
matchcol = shl->rm.endpos[0].col;
|
|
|
22c937 |
|
|
|
22c937 |
shl->lnum = lnum;
|
|
|
22c937 |
! nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum, matchcol,
|
|
|
22c937 |
#ifdef FEAT_RELTIME
|
|
|
22c937 |
! &(shl->tm)
|
|
|
22c937 |
#else
|
|
|
22c937 |
! NULL
|
|
|
22c937 |
#endif
|
|
|
22c937 |
! );
|
|
|
22c937 |
! if (called_emsg || got_int)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! /* Error while handling regexp: stop using this regexp. */
|
|
|
22c937 |
! if (shl == &search_hl)
|
|
|
22c937 |
{
|
|
|
22c937 |
! /* don't free regprog in the match list, it's a copy */
|
|
|
22c937 |
! vim_regfree(shl->rm.regprog);
|
|
|
22c937 |
! SET_NO_HLSEARCH(TRUE);
|
|
|
22c937 |
}
|
|
|
22c937 |
! shl->rm.regprog = NULL;
|
|
|
22c937 |
! shl->lnum = 0;
|
|
|
22c937 |
! got_int = FALSE; /* avoid the "Type :quit to exit Vim" message */
|
|
|
22c937 |
! break;
|
|
|
22c937 |
}
|
|
|
22c937 |
if (nmatched == 0)
|
|
|
22c937 |
{
|
|
|
22c937 |
--- 7431,7465 ----
|
|
|
22c937 |
matchcol = shl->rm.endpos[0].col;
|
|
|
22c937 |
|
|
|
22c937 |
shl->lnum = lnum;
|
|
|
22c937 |
! if (shl->rm.regprog != NULL)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum,
|
|
|
22c937 |
! matchcol,
|
|
|
22c937 |
#ifdef FEAT_RELTIME
|
|
|
22c937 |
! &(shl->tm)
|
|
|
22c937 |
#else
|
|
|
22c937 |
! NULL
|
|
|
22c937 |
#endif
|
|
|
22c937 |
! );
|
|
|
22c937 |
! if (called_emsg || got_int)
|
|
|
22c937 |
{
|
|
|
22c937 |
! /* Error while handling regexp: stop using this regexp. */
|
|
|
22c937 |
! if (shl == &search_hl)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! /* don't free regprog in the match list, it's a copy */
|
|
|
22c937 |
! vim_regfree(shl->rm.regprog);
|
|
|
22c937 |
! SET_NO_HLSEARCH(TRUE);
|
|
|
22c937 |
! }
|
|
|
22c937 |
! shl->rm.regprog = NULL;
|
|
|
22c937 |
! shl->lnum = 0;
|
|
|
22c937 |
! got_int = FALSE; /* avoid the "Type :quit to exit Vim"
|
|
|
22c937 |
! message */
|
|
|
22c937 |
! break;
|
|
|
22c937 |
}
|
|
|
22c937 |
! }
|
|
|
22c937 |
! else if (cur != NULL)
|
|
|
22c937 |
! {
|
|
|
22c937 |
! nmatched = next_search_hl_pos(shl, lnum, &(cur->pos), matchcol);
|
|
|
22c937 |
}
|
|
|
22c937 |
if (nmatched == 0)
|
|
|
22c937 |
{
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 7453,7458 ****
|
|
|
22c937 |
--- 7478,7539 ----
|
|
|
22c937 |
}
|
|
|
22c937 |
#endif
|
|
|
22c937 |
|
|
|
22c937 |
+ static int
|
|
|
22c937 |
+ next_search_hl_pos(shl, lnum, posmatch, mincol)
|
|
|
22c937 |
+ match_T *shl; /* points to a match */
|
|
|
22c937 |
+ linenr_T lnum;
|
|
|
22c937 |
+ posmatch_T *posmatch; /* match positions */
|
|
|
22c937 |
+ colnr_T mincol; /* minimal column for a match */
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ int i;
|
|
|
22c937 |
+ int bot = -1;
|
|
|
22c937 |
+
|
|
|
22c937 |
+ shl->lnum = 0;
|
|
|
22c937 |
+ for (i = posmatch->cur; i < MAXPOSMATCH; i++)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ if (posmatch->pos[i].lnum == 0)
|
|
|
22c937 |
+ break;
|
|
|
22c937 |
+ if (posmatch->pos[i].col < mincol)
|
|
|
22c937 |
+ continue;
|
|
|
22c937 |
+ if (posmatch->pos[i].lnum == lnum)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ if (shl->lnum == lnum)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ /* partially sort positions by column numbers
|
|
|
22c937 |
+ * on the same line */
|
|
|
22c937 |
+ if (posmatch->pos[i].col < posmatch->pos[bot].col)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ llpos_T tmp = posmatch->pos[i];
|
|
|
22c937 |
+
|
|
|
22c937 |
+ posmatch->pos[i] = posmatch->pos[bot];
|
|
|
22c937 |
+ posmatch->pos[bot] = tmp;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ else
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ bot = i;
|
|
|
22c937 |
+ shl->lnum = lnum;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ posmatch->cur = 0;
|
|
|
22c937 |
+ if (shl->lnum == lnum)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ colnr_T start = posmatch->pos[bot].col == 0
|
|
|
22c937 |
+ ? 0 : posmatch->pos[bot].col - 1;
|
|
|
22c937 |
+ colnr_T end = posmatch->pos[bot].col == 0
|
|
|
22c937 |
+ ? MAXCOL : start + posmatch->pos[bot].len;
|
|
|
22c937 |
+
|
|
|
22c937 |
+ shl->rm.startpos[0].lnum = 0;
|
|
|
22c937 |
+ shl->rm.startpos[0].col = start;
|
|
|
22c937 |
+ shl->rm.endpos[0].lnum = 0;
|
|
|
22c937 |
+ shl->rm.endpos[0].col = end;
|
|
|
22c937 |
+ posmatch->cur = bot + 1;
|
|
|
22c937 |
+ return TRUE;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ return FALSE;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+
|
|
|
22c937 |
static void
|
|
|
22c937 |
screen_start_highlight(attr)
|
|
|
22c937 |
int attr;
|
|
|
22c937 |
*** ../vim-7.4.329/src/structs.h 2014-05-28 18:22:37.876225054 +0200
|
|
|
22c937 |
--- src/structs.h 2014-06-17 17:00:55.524520330 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 1927,1932 ****
|
|
|
22c937 |
--- 1927,1958 ----
|
|
|
22c937 |
#endif
|
|
|
22c937 |
} match_T;
|
|
|
22c937 |
|
|
|
22c937 |
+ /* number of positions supported by matchaddpos() */
|
|
|
22c937 |
+ #define MAXPOSMATCH 8
|
|
|
22c937 |
+
|
|
|
22c937 |
+ /*
|
|
|
22c937 |
+ * Same as lpos_T, but with additional field len.
|
|
|
22c937 |
+ */
|
|
|
22c937 |
+ typedef struct
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ linenr_T lnum; /* line number */
|
|
|
22c937 |
+ colnr_T col; /* column number */
|
|
|
22c937 |
+ int len; /* length: 0 - to the end of line */
|
|
|
22c937 |
+ } llpos_T;
|
|
|
22c937 |
+
|
|
|
22c937 |
+ /*
|
|
|
22c937 |
+ * posmatch_T provides an array for storing match items for matchaddpos()
|
|
|
22c937 |
+ * function.
|
|
|
22c937 |
+ */
|
|
|
22c937 |
+ typedef struct posmatch posmatch_T;
|
|
|
22c937 |
+ struct posmatch
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ llpos_T pos[MAXPOSMATCH]; /* array of positions */
|
|
|
22c937 |
+ int cur; /* internal position counter */
|
|
|
22c937 |
+ linenr_T toplnum; /* top buffer line */
|
|
|
22c937 |
+ linenr_T botlnum; /* bottom buffer line */
|
|
|
22c937 |
+ };
|
|
|
22c937 |
+
|
|
|
22c937 |
/*
|
|
|
22c937 |
* matchitem_T provides a linked list for storing match items for ":match" and
|
|
|
22c937 |
* the match functions.
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 1940,1945 ****
|
|
|
22c937 |
--- 1966,1972 ----
|
|
|
22c937 |
char_u *pattern; /* pattern to highlight */
|
|
|
22c937 |
int hlg_id; /* highlight group ID */
|
|
|
22c937 |
regmmatch_T match; /* regexp program for pattern */
|
|
|
22c937 |
+ posmatch_T pos; /* position matches */
|
|
|
22c937 |
match_T hl; /* struct for doing the actual highlighting */
|
|
|
22c937 |
};
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.329/src/testdir/test63.in 2010-05-15 13:04:10.000000000 +0200
|
|
|
22c937 |
--- src/testdir/test63.in 2014-06-17 16:29:36.056449227 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 1,5 ****
|
|
|
22c937 |
Test for ":match", ":2match", ":3match", "clearmatches()", "getmatches()",
|
|
|
22c937 |
! "matchadd()", "matcharg()", "matchdelete()", and "setmatches()".
|
|
|
22c937 |
|
|
|
22c937 |
STARTTEST
|
|
|
22c937 |
:so small.vim
|
|
|
22c937 |
--- 1,5 ----
|
|
|
22c937 |
Test for ":match", ":2match", ":3match", "clearmatches()", "getmatches()",
|
|
|
22c937 |
! "matchadd()", "matchaddpos", "matcharg()", "matchdelete()", and "setmatches()".
|
|
|
22c937 |
|
|
|
22c937 |
STARTTEST
|
|
|
22c937 |
:so small.vim
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 147,155 ****
|
|
|
22c937 |
:unlet rf1
|
|
|
22c937 |
:unlet rf2
|
|
|
22c937 |
:unlet rf3
|
|
|
22c937 |
! :highlight clear MyGroup1
|
|
|
22c937 |
! :highlight clear MyGroup2
|
|
|
22c937 |
! :highlight clear MyGroup3
|
|
|
22c937 |
G"rp
|
|
|
22c937 |
:/^Results/,$wq! test.out
|
|
|
22c937 |
ENDTEST
|
|
|
22c937 |
--- 147,172 ----
|
|
|
22c937 |
:unlet rf1
|
|
|
22c937 |
:unlet rf2
|
|
|
22c937 |
:unlet rf3
|
|
|
22c937 |
! :" --- Check that "matchaddpos()" positions matches correctly
|
|
|
22c937 |
! :let @r .= "*** Test 11:\n"
|
|
|
22c937 |
! :set nolazyredraw
|
|
|
22c937 |
! :call setline(1, 'abcdefghijklmnopq')
|
|
|
22c937 |
! :call matchaddpos("MyGroup1", [[1, 5], [1, 8, 3]], 10, 3)
|
|
|
22c937 |
! :1
|
|
|
22c937 |
! :redraw!
|
|
|
22c937 |
! :let v1 = screenattr(1, 1)
|
|
|
22c937 |
! :let v5 = screenattr(1, 5)
|
|
|
22c937 |
! :let v6 = screenattr(1, 6)
|
|
|
22c937 |
! :let v8 = screenattr(1, 8)
|
|
|
22c937 |
! :let v10 = screenattr(1, 10)
|
|
|
22c937 |
! :let v11 = screenattr(1, 11)
|
|
|
22c937 |
! :let @r .= string(getmatches())."\n"
|
|
|
22c937 |
! :if v1 != v5 && v6 == v1 && v8 == v5 && v10 == v5 && v11 == v1
|
|
|
22c937 |
! : let @r .= "OK\n"
|
|
|
22c937 |
! :else
|
|
|
22c937 |
! : let @r .= "FAILED\n"
|
|
|
22c937 |
! :endif
|
|
|
22c937 |
! :call clearmatches()
|
|
|
22c937 |
G"rp
|
|
|
22c937 |
:/^Results/,$wq! test.out
|
|
|
22c937 |
ENDTEST
|
|
|
22c937 |
*** ../vim-7.4.329/src/testdir/test63.ok 2010-05-15 13:04:10.000000000 +0200
|
|
|
22c937 |
--- src/testdir/test63.ok 2014-06-17 17:32:57.036593023 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 9,11 ****
|
|
|
22c937 |
--- 9,14 ----
|
|
|
22c937 |
*** Test 8: OK
|
|
|
22c937 |
*** Test 9: OK
|
|
|
22c937 |
*** Test 10: OK
|
|
|
22c937 |
+ *** Test 11:
|
|
|
22c937 |
+ [{'group': 'MyGroup1', 'id': 3, 'priority': 10, 'pos1': [1, 5, 1], 'pos2': [1, 8, 3]}]
|
|
|
22c937 |
+ OK
|
|
|
22c937 |
*** ../vim-7.4.329/src/window.c 2014-06-17 13:52:35.868092848 +0200
|
|
|
22c937 |
--- src/window.c 2014-06-17 17:04:51.060529240 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6751,6770 ****
|
|
|
22c937 |
* Return ID of added match, -1 on failure.
|
|
|
22c937 |
*/
|
|
|
22c937 |
int
|
|
|
22c937 |
! match_add(wp, grp, pat, prio, id)
|
|
|
22c937 |
win_T *wp;
|
|
|
22c937 |
char_u *grp;
|
|
|
22c937 |
char_u *pat;
|
|
|
22c937 |
int prio;
|
|
|
22c937 |
int id;
|
|
|
22c937 |
{
|
|
|
22c937 |
! matchitem_T *cur;
|
|
|
22c937 |
! matchitem_T *prev;
|
|
|
22c937 |
! matchitem_T *m;
|
|
|
22c937 |
int hlg_id;
|
|
|
22c937 |
! regprog_T *regprog;
|
|
|
22c937 |
|
|
|
22c937 |
! if (*grp == NUL || *pat == NUL)
|
|
|
22c937 |
return -1;
|
|
|
22c937 |
if (id < -1 || id == 0)
|
|
|
22c937 |
{
|
|
|
22c937 |
--- 6751,6772 ----
|
|
|
22c937 |
* Return ID of added match, -1 on failure.
|
|
|
22c937 |
*/
|
|
|
22c937 |
int
|
|
|
22c937 |
! match_add(wp, grp, pat, prio, id, pos_list)
|
|
|
22c937 |
win_T *wp;
|
|
|
22c937 |
char_u *grp;
|
|
|
22c937 |
char_u *pat;
|
|
|
22c937 |
int prio;
|
|
|
22c937 |
int id;
|
|
|
22c937 |
+ list_T *pos_list;
|
|
|
22c937 |
{
|
|
|
22c937 |
! matchitem_T *cur;
|
|
|
22c937 |
! matchitem_T *prev;
|
|
|
22c937 |
! matchitem_T *m;
|
|
|
22c937 |
int hlg_id;
|
|
|
22c937 |
! regprog_T *regprog = NULL;
|
|
|
22c937 |
! int rtype = SOME_VALID;
|
|
|
22c937 |
|
|
|
22c937 |
! if (*grp == NUL || (pat != NULL && *pat == NUL))
|
|
|
22c937 |
return -1;
|
|
|
22c937 |
if (id < -1 || id == 0)
|
|
|
22c937 |
{
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6789,6795 ****
|
|
|
22c937 |
EMSG2(_(e_nogroup), grp);
|
|
|
22c937 |
return -1;
|
|
|
22c937 |
}
|
|
|
22c937 |
! if ((regprog = vim_regcomp(pat, RE_MAGIC)) == NULL)
|
|
|
22c937 |
{
|
|
|
22c937 |
EMSG2(_(e_invarg2), pat);
|
|
|
22c937 |
return -1;
|
|
|
22c937 |
--- 6791,6797 ----
|
|
|
22c937 |
EMSG2(_(e_nogroup), grp);
|
|
|
22c937 |
return -1;
|
|
|
22c937 |
}
|
|
|
22c937 |
! if (pat != NULL && (regprog = vim_regcomp(pat, RE_MAGIC)) == NULL)
|
|
|
22c937 |
{
|
|
|
22c937 |
EMSG2(_(e_invarg2), pat);
|
|
|
22c937 |
return -1;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6810,6821 ****
|
|
|
22c937 |
m = (matchitem_T *)alloc(sizeof(matchitem_T));
|
|
|
22c937 |
m->id = id;
|
|
|
22c937 |
m->priority = prio;
|
|
|
22c937 |
! m->pattern = vim_strsave(pat);
|
|
|
22c937 |
m->hlg_id = hlg_id;
|
|
|
22c937 |
m->match.regprog = regprog;
|
|
|
22c937 |
m->match.rmm_ic = FALSE;
|
|
|
22c937 |
m->match.rmm_maxcol = 0;
|
|
|
22c937 |
|
|
|
22c937 |
/* Insert new match. The match list is in ascending order with regard to
|
|
|
22c937 |
* the match priorities. */
|
|
|
22c937 |
cur = wp->w_match_head;
|
|
|
22c937 |
--- 6812,6922 ----
|
|
|
22c937 |
m = (matchitem_T *)alloc(sizeof(matchitem_T));
|
|
|
22c937 |
m->id = id;
|
|
|
22c937 |
m->priority = prio;
|
|
|
22c937 |
! m->pattern = pat == NULL ? NULL : vim_strsave(pat);
|
|
|
22c937 |
! m->pos.cur = 0;
|
|
|
22c937 |
m->hlg_id = hlg_id;
|
|
|
22c937 |
m->match.regprog = regprog;
|
|
|
22c937 |
m->match.rmm_ic = FALSE;
|
|
|
22c937 |
m->match.rmm_maxcol = 0;
|
|
|
22c937 |
|
|
|
22c937 |
+ /* Set up position matches */
|
|
|
22c937 |
+ if (pos_list != NULL)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ linenr_T toplnum = 0;
|
|
|
22c937 |
+ linenr_T botlnum = 0;
|
|
|
22c937 |
+ listitem_T *li;
|
|
|
22c937 |
+ int i;
|
|
|
22c937 |
+
|
|
|
22c937 |
+ for (i = 0, li = pos_list->lv_first; i < MAXPOSMATCH;
|
|
|
22c937 |
+ i++, li = li->li_next)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ linenr_T lnum = 0;
|
|
|
22c937 |
+ colnr_T col = 0;
|
|
|
22c937 |
+ int len = 1;
|
|
|
22c937 |
+ list_T *subl;
|
|
|
22c937 |
+ listitem_T *subli;
|
|
|
22c937 |
+ int error;
|
|
|
22c937 |
+
|
|
|
22c937 |
+ if (li == NULL)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ m->pos.pos[i].lnum = 0;
|
|
|
22c937 |
+ break;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ if (li->li_tv.v_type == VAR_LIST)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ subl = li->li_tv.vval.v_list;
|
|
|
22c937 |
+ if (subl == NULL)
|
|
|
22c937 |
+ goto fail;
|
|
|
22c937 |
+ subli = subl->lv_first;
|
|
|
22c937 |
+ if (subli == NULL)
|
|
|
22c937 |
+ goto fail;
|
|
|
22c937 |
+ lnum = get_tv_number_chk(&subli->li_tv, &error);
|
|
|
22c937 |
+ if (error == TRUE)
|
|
|
22c937 |
+ goto fail;
|
|
|
22c937 |
+ m->pos.pos[i].lnum = lnum;
|
|
|
22c937 |
+ if (lnum == 0)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ --i;
|
|
|
22c937 |
+ continue;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ subli = subli->li_next;
|
|
|
22c937 |
+ if (subli != NULL)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ col = get_tv_number_chk(&subli->li_tv, &error);
|
|
|
22c937 |
+ if (error == TRUE)
|
|
|
22c937 |
+ goto fail;
|
|
|
22c937 |
+ subli = subli->li_next;
|
|
|
22c937 |
+ if (subli != NULL)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ len = get_tv_number_chk(&subli->li_tv, &error);
|
|
|
22c937 |
+ if (error == TRUE)
|
|
|
22c937 |
+ goto fail;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ m->pos.pos[i].col = col;
|
|
|
22c937 |
+ m->pos.pos[i].len = len;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ else if (li->li_tv.v_type == VAR_NUMBER)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ if (li->li_tv.vval.v_number == 0)
|
|
|
22c937 |
+ continue;
|
|
|
22c937 |
+ m->pos.pos[i].lnum = li->li_tv.vval.v_number;
|
|
|
22c937 |
+ m->pos.pos[i].col = 0;
|
|
|
22c937 |
+ m->pos.pos[i].len = 0;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ else
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ EMSG(_("List or number required"));
|
|
|
22c937 |
+ goto fail;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ if (toplnum == 0 || lnum < toplnum)
|
|
|
22c937 |
+ toplnum = lnum;
|
|
|
22c937 |
+ if (botlnum == 0 || lnum > botlnum)
|
|
|
22c937 |
+ botlnum = lnum;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+
|
|
|
22c937 |
+ /* Calculate top and bottom lines for redrawing area */
|
|
|
22c937 |
+ if (toplnum != 0)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ if (wp->w_buffer->b_mod_set)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ if (wp->w_buffer->b_mod_top > toplnum)
|
|
|
22c937 |
+ wp->w_buffer->b_mod_top = toplnum;
|
|
|
22c937 |
+ if (wp->w_buffer->b_mod_bot < botlnum)
|
|
|
22c937 |
+ wp->w_buffer->b_mod_bot = botlnum;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ else
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ wp->w_buffer->b_mod_top = toplnum;
|
|
|
22c937 |
+ wp->w_buffer->b_mod_bot = botlnum;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ m->pos.toplnum = toplnum;
|
|
|
22c937 |
+ m->pos.botlnum = botlnum;
|
|
|
22c937 |
+ wp->w_buffer->b_mod_set = TRUE;
|
|
|
22c937 |
+ rtype = VALID;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+
|
|
|
22c937 |
/* Insert new match. The match list is in ascending order with regard to
|
|
|
22c937 |
* the match priorities. */
|
|
|
22c937 |
cur = wp->w_match_head;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6831,6838 ****
|
|
|
22c937 |
prev->next = m;
|
|
|
22c937 |
m->next = cur;
|
|
|
22c937 |
|
|
|
22c937 |
! redraw_later(SOME_VALID);
|
|
|
22c937 |
return id;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
/*
|
|
|
22c937 |
--- 6932,6943 ----
|
|
|
22c937 |
prev->next = m;
|
|
|
22c937 |
m->next = cur;
|
|
|
22c937 |
|
|
|
22c937 |
! redraw_later(rtype);
|
|
|
22c937 |
return id;
|
|
|
22c937 |
+
|
|
|
22c937 |
+ fail:
|
|
|
22c937 |
+ vim_free(m);
|
|
|
22c937 |
+ return -1;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
/*
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6845,6852 ****
|
|
|
22c937 |
int id;
|
|
|
22c937 |
int perr;
|
|
|
22c937 |
{
|
|
|
22c937 |
! matchitem_T *cur = wp->w_match_head;
|
|
|
22c937 |
! matchitem_T *prev = cur;
|
|
|
22c937 |
|
|
|
22c937 |
if (id < 1)
|
|
|
22c937 |
{
|
|
|
22c937 |
--- 6950,6958 ----
|
|
|
22c937 |
int id;
|
|
|
22c937 |
int perr;
|
|
|
22c937 |
{
|
|
|
22c937 |
! matchitem_T *cur = wp->w_match_head;
|
|
|
22c937 |
! matchitem_T *prev = cur;
|
|
|
22c937 |
! int rtype = SOME_VALID;
|
|
|
22c937 |
|
|
|
22c937 |
if (id < 1)
|
|
|
22c937 |
{
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6872,6879 ****
|
|
|
22c937 |
prev->next = cur->next;
|
|
|
22c937 |
vim_regfree(cur->match.regprog);
|
|
|
22c937 |
vim_free(cur->pattern);
|
|
|
22c937 |
vim_free(cur);
|
|
|
22c937 |
! redraw_later(SOME_VALID);
|
|
|
22c937 |
return 0;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
--- 6978,7002 ----
|
|
|
22c937 |
prev->next = cur->next;
|
|
|
22c937 |
vim_regfree(cur->match.regprog);
|
|
|
22c937 |
vim_free(cur->pattern);
|
|
|
22c937 |
+ if (cur->pos.toplnum != 0)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ if (wp->w_buffer->b_mod_set)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ if (wp->w_buffer->b_mod_top > cur->pos.toplnum)
|
|
|
22c937 |
+ wp->w_buffer->b_mod_top = cur->pos.toplnum;
|
|
|
22c937 |
+ if (wp->w_buffer->b_mod_bot < cur->pos.botlnum)
|
|
|
22c937 |
+ wp->w_buffer->b_mod_bot = cur->pos.botlnum;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ else
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ wp->w_buffer->b_mod_top = cur->pos.toplnum;
|
|
|
22c937 |
+ wp->w_buffer->b_mod_bot = cur->pos.botlnum;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ wp->w_buffer->b_mod_set = TRUE;
|
|
|
22c937 |
+ rtype = VALID;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
vim_free(cur);
|
|
|
22c937 |
! redraw_later(rtype);
|
|
|
22c937 |
return 0;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.329/src/version.c 2014-06-17 13:52:35.868092848 +0200
|
|
|
22c937 |
--- src/version.c 2014-06-17 14:11:53.764136653 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 736,737 ****
|
|
|
22c937 |
--- 736,739 ----
|
|
|
22c937 |
{ /* Add new patch number below this line */
|
|
|
22c937 |
+ /**/
|
|
|
22c937 |
+ 330,
|
|
|
22c937 |
/**/
|
|
|
22c937 |
|
|
|
22c937 |
--
|
|
|
22c937 |
I'd like to meet the man who invented sex and see what he's working on now.
|
|
|
22c937 |
|
|
|
22c937 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
|
22c937 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
|
22c937 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
|
22c937 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|