diff options
author | Bram Moolenaar <Bram@vim.org> | 2008-01-10 21:24:39 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2008-01-10 21:24:39 +0000 |
commit | 9d188ab0877700f215b23c17ef254770605ec134 (patch) | |
tree | 99f7e2dfb06677c0c7970bc9b31be5ff29312434 | |
parent | bd7cc03e57c71f3e3c0c7ca72489a4108d5af7d1 (diff) |
updated for version 7.1-215v7.1.215
-rw-r--r-- | runtime/doc/eval.txt | 21 | ||||
-rw-r--r-- | src/eval.c | 42 | ||||
-rw-r--r-- | src/proto/syntax.pro | 1 | ||||
-rw-r--r-- | src/syntax.c | 16 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 81 insertions, 1 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index c82a8f8ad5..97439fa98c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 7.1. Last change: 2008 Jan 06 +*eval.txt* For Vim version 7.1. Last change: 2008 Jan 10 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1786,6 +1786,7 @@ synID( {lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} synIDattr( {synID}, {what} [, {mode}]) String attribute {what} of syntax ID {synID} synIDtrans( {synID}) Number translated syntax ID of {synID} +synstack({lnum}, {col}) List stack of syntax IDs at {lnum} and {col} system( {expr} [, {input}]) String output of shell command/filter {expr} tabpagebuflist( [{arg}]) List list of buffer numbers in tab page tabpagenr( [{arg}]) Number number of current or last tab page @@ -4962,6 +4963,24 @@ synIDtrans({synID}) *synIDtrans()* highlight the character. Highlight links given with ":highlight link" are followed. +synstack({lnum}, {col}) *synstack()* + Return a |List|, which is the stack of syntax items at the + position {lnum} and {col} in the current window. Each item in + the List is an ID like what |synID()| returns. + The stack is the situation in between the character at "col" + and the next character. Note that a region of only one + character will not show up, it only exists inside that + character, not in between characters. + The first item in the List is the outer region, following are + items contained in that one. The last one is what |synID()| + returns, unless not the whole item is highlighted or it is a + transparent item. + This function is useful for debugging a syntax file. + Example that shows the syntax stack under the cursor: > + for id in synstack(line("."), col(".")) + echo synIDattr(id, "name") + endfor + system({expr} [, {input}]) *system()* *E677* Get the output of the shell command {expr}. When {input} is given, this string is written to a file and diff --git a/src/eval.c b/src/eval.c index 4afcb189cb..ade6f5a1ce 100644 --- a/src/eval.c +++ b/src/eval.c @@ -651,6 +651,7 @@ static void f_substitute __ARGS((typval_T *argvars, typval_T *rettv)); static void f_synID __ARGS((typval_T *argvars, typval_T *rettv)); static void f_synIDattr __ARGS((typval_T *argvars, typval_T *rettv)); static void f_synIDtrans __ARGS((typval_T *argvars, typval_T *rettv)); +static void f_synstack __ARGS((typval_T *argvars, typval_T *rettv)); static void f_system __ARGS((typval_T *argvars, typval_T *rettv)); static void f_tabpagebuflist __ARGS((typval_T *argvars, typval_T *rettv)); static void f_tabpagenr __ARGS((typval_T *argvars, typval_T *rettv)); @@ -7252,6 +7253,7 @@ static struct fst {"synID", 3, 3, f_synID}, {"synIDattr", 2, 3, f_synIDattr}, {"synIDtrans", 1, 1, f_synIDtrans}, + {"synstack", 2, 2, f_synstack}, {"system", 1, 2, f_system}, {"tabpagebuflist", 0, 1, f_tabpagebuflist}, {"tabpagenr", 0, 1, f_tabpagenr}, @@ -15846,6 +15848,46 @@ f_synIDtrans(argvars, rettv) } /* + * "synstack(lnum, col)" function + */ +/*ARGSUSED*/ + static void +f_synstack(argvars, rettv) + typval_T *argvars; + typval_T *rettv; +{ +#ifdef FEAT_SYN_HL + long lnum; + long col; + int i; + int id; +#endif + + rettv->v_type = VAR_LIST; + rettv->vval.v_list = NULL; + +#ifdef FEAT_SYN_HL + lnum = get_tv_lnum(argvars); /* -1 on type error */ + col = get_tv_number(&argvars[1]) - 1; /* -1 on type error */ + + if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count + && col >= 0 && col < (long)STRLEN(ml_get(lnum)) + && rettv_list_alloc(rettv) != FAIL) + { + (void)syn_get_id(curwin, lnum, (colnr_T)col, FALSE, NULL); + for (i = 0; ; ++i) + { + id = syn_get_stack_item(i); + if (id < 0) + break; + if (list_append_number(rettv->vval.v_list, id) == FAIL) + break; + } + } +#endif +} + +/* * "system()" function */ static void diff --git a/src/proto/syntax.pro b/src/proto/syntax.pro index 4fe080136a..b6f008f6fe 100644 --- a/src/proto/syntax.pro +++ b/src/proto/syntax.pro @@ -13,6 +13,7 @@ void set_context_in_echohl_cmd __ARGS((expand_T *xp, char_u *arg)); void set_context_in_syntax_cmd __ARGS((expand_T *xp, char_u *arg)); char_u *get_syntax_name __ARGS((expand_T *xp, int idx)); int syn_get_id __ARGS((win_T *wp, long lnum, colnr_T col, int trans, int *spellp)); +int syn_get_stack_item __ARGS((int i)); int syn_get_foldlevel __ARGS((win_T *wp, long lnum)); void init_highlight __ARGS((int both, int reset)); int load_colors __ARGS((char_u *name)); diff --git a/src/syntax.c b/src/syntax.c index e321313bed..f9fbb0129c 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -6105,6 +6105,22 @@ syn_get_id(wp, lnum, col, trans, spellp) return (trans ? current_trans_id : current_id); } +#if defined(FEAT_EVAL) || defined(PROTO) +/* + * Return the syntax ID at position "i" in the current stack. + * The caller must have called syn_get_id() before to fill the stack. + * Returns -1 when "i" is out of range. + */ + int +syn_get_stack_item(i) + int i; +{ + if (i >= current_state.ga_len ) + return -1; + return CUR_STATE(i).si_id; +} +#endif + #if defined(FEAT_FOLDING) || defined(PROTO) /* * Function called to get folding level for line "lnum" in window "wp". diff --git a/src/version.c b/src/version.c index 0723d53319..35227e3d6c 100644 --- a/src/version.c +++ b/src/version.c @@ -667,6 +667,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 215, +/**/ 214, /**/ 213, |