Mirror of the Vim source from https://github.com/vim/vim
修訂 | d5ec1b42ceb06062f03d828acca852a4ccfbc7a4 (tree) |
---|---|
時間 | 2005-07-21 07:06:07 |
作者 | vimboss |
Commiter | vimboss |
updated for version 7.0111
@@ -2,7 +2,7 @@ | ||
2 | 2 | " Language: HTML |
3 | 3 | " Maintainer: Claudio Fleiner <claudio@fleiner.com> |
4 | 4 | " URL: http://www.fleiner.com/vim/syntax/html.vim |
5 | -" Last Change: 2005 Jul 18 | |
5 | +" Last Change: 2005 Jul 20 | |
6 | 6 | |
7 | 7 | " Please check :help html.vim for some comments and a description of the options |
8 | 8 |
@@ -27,7 +27,9 @@ | ||
27 | 27 | |
28 | 28 | syn case ignore |
29 | 29 | |
30 | -syn spell toplevel | |
30 | +if main_syntax == "html" | |
31 | + syn spell toplevel | |
32 | +endif | |
31 | 33 | |
32 | 34 | " mark illegal characters |
33 | 35 | syn match htmlError "[<>&]" |
@@ -493,6 +493,7 @@ | ||
493 | 493 | static void f_function __ARGS((typval_T *argvars, typval_T *rettv)); |
494 | 494 | static void f_garbagecollect __ARGS((typval_T *argvars, typval_T *rettv)); |
495 | 495 | static void f_get __ARGS((typval_T *argvars, typval_T *rettv)); |
496 | +static void f_getbufline __ARGS((typval_T *argvars, typval_T *rettv)); | |
496 | 497 | static void f_getbufvar __ARGS((typval_T *argvars, typval_T *rettv)); |
497 | 498 | static void f_getchar __ARGS((typval_T *argvars, typval_T *rettv)); |
498 | 499 | static void f_getcharmod __ARGS((typval_T *argvars, typval_T *rettv)); |
@@ -6676,6 +6677,7 @@ | ||
6676 | 6677 | {"function", 1, 1, f_function}, |
6677 | 6678 | {"garbagecollect", 0, 0, f_garbagecollect}, |
6678 | 6679 | {"get", 2, 3, f_get}, |
6680 | + {"getbufline", 2, 3, f_getbufline}, | |
6679 | 6681 | {"getbufvar", 2, 2, f_getbufvar}, |
6680 | 6682 | {"getchar", 0, 1, f_getchar}, |
6681 | 6683 | {"getcharmod", 0, 0, f_getcharmod}, |
@@ -9076,6 +9078,101 @@ | ||
9076 | 9078 | copy_tv(tv, rettv); |
9077 | 9079 | } |
9078 | 9080 | |
9081 | +static void get_buffer_lines __ARGS((buf_T *buf, linenr_T start, linenr_T end, typval_T *rettv)); | |
9082 | + | |
9083 | +/* | |
9084 | + * Get line or list of lines from buffer "buf" into "rettv". | |
9085 | + */ | |
9086 | + static void | |
9087 | +get_buffer_lines(buf, start, end, rettv) | |
9088 | + buf_T *buf; | |
9089 | + linenr_T start; | |
9090 | + linenr_T end; | |
9091 | + typval_T *rettv; | |
9092 | +{ | |
9093 | + char_u *p; | |
9094 | + list_T *l; | |
9095 | + listitem_T *li; | |
9096 | + | |
9097 | + if (start < 0) | |
9098 | + rettv->vval.v_number = 0; /* failure; error message already given */ | |
9099 | + else if (end == 0) | |
9100 | + { | |
9101 | + /* getline(lnum): return one line as a string */ | |
9102 | + if (start >= 1 && start <= buf->b_ml.ml_line_count) | |
9103 | + p = ml_get_buf(buf, start, FALSE); | |
9104 | + else | |
9105 | + p = (char_u *)""; | |
9106 | + | |
9107 | + rettv->v_type = VAR_STRING; | |
9108 | + rettv->vval.v_string = vim_strsave(p); | |
9109 | + } | |
9110 | + else | |
9111 | + { | |
9112 | + if (end < start) | |
9113 | + { | |
9114 | + if (end >= 0) /* else: error message already given */ | |
9115 | + EMSG(_(e_invrange)); | |
9116 | + rettv->vval.v_number = 0; | |
9117 | + } | |
9118 | + else | |
9119 | + { | |
9120 | + l = list_alloc(); | |
9121 | + if (l != NULL) | |
9122 | + { | |
9123 | + if (start < 1) | |
9124 | + start = 1; | |
9125 | + if (end > buf->b_ml.ml_line_count) | |
9126 | + end = buf->b_ml.ml_line_count; | |
9127 | + while (start <= end) | |
9128 | + { | |
9129 | + li = listitem_alloc(); | |
9130 | + if (li == NULL) | |
9131 | + break; | |
9132 | + list_append(l, li); | |
9133 | + li->li_tv.v_type = VAR_STRING; | |
9134 | + li->li_tv.v_lock = 0; | |
9135 | + li->li_tv.vval.v_string = | |
9136 | + vim_strsave(ml_get_buf(buf, start++, FALSE)); | |
9137 | + } | |
9138 | + rettv->vval.v_list = l; | |
9139 | + rettv->v_type = VAR_LIST; | |
9140 | + ++l->lv_refcount; | |
9141 | + } | |
9142 | + } | |
9143 | + } | |
9144 | +} | |
9145 | + | |
9146 | +/* | |
9147 | + * "getbufline()" function | |
9148 | + */ | |
9149 | + static void | |
9150 | +f_getbufline(argvars, rettv) | |
9151 | + typval_T *argvars; | |
9152 | + typval_T *rettv; | |
9153 | +{ | |
9154 | + linenr_T lnum; | |
9155 | + linenr_T end; | |
9156 | + buf_T *buf; | |
9157 | + | |
9158 | + (void)get_tv_number(&argvars[0]); /* issue errmsg if type error */ | |
9159 | + ++emsg_off; | |
9160 | + buf = get_buf_tv(&argvars[0]); | |
9161 | + --emsg_off; | |
9162 | + | |
9163 | + if (buf == NULL || buf->b_ml.ml_mfp == NULL) | |
9164 | + rettv->vval.v_number = 0; | |
9165 | + else | |
9166 | + { | |
9167 | + lnum = get_tv_lnum(&argvars[1]); | |
9168 | + if (argvars[2].v_type == VAR_UNKNOWN) | |
9169 | + end = lnum; | |
9170 | + else | |
9171 | + end = get_tv_lnum(&argvars[2]); | |
9172 | + get_buffer_lines(buf, lnum, end, rettv); | |
9173 | + } | |
9174 | +} | |
9175 | + | |
9079 | 9176 | /* |
9080 | 9177 | * "getbufvar()" function |
9081 | 9178 | */ |
@@ -9444,7 +9541,7 @@ | ||
9444 | 9541 | } |
9445 | 9542 | |
9446 | 9543 | /* |
9447 | - * "getline(lnum)" function | |
9544 | + * "getline(lnum, [end])" function | |
9448 | 9545 | */ |
9449 | 9546 | static void |
9450 | 9547 | f_getline(argvars, rettv) |
@@ -9453,57 +9550,14 @@ | ||
9453 | 9550 | { |
9454 | 9551 | linenr_T lnum; |
9455 | 9552 | linenr_T end; |
9456 | - char_u *p; | |
9457 | - list_T *l; | |
9458 | - listitem_T *li; | |
9459 | 9553 | |
9460 | 9554 | lnum = get_tv_lnum(argvars); |
9461 | - if (lnum < 0) | |
9462 | - rettv->vval.v_number = 0; /* failure; error message already given */ | |
9463 | - else if (argvars[1].v_type == VAR_UNKNOWN) | |
9464 | - { | |
9465 | - if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count) | |
9466 | - p = ml_get(lnum); | |
9467 | - else | |
9468 | - p = (char_u *)""; | |
9469 | - | |
9470 | - rettv->v_type = VAR_STRING; | |
9471 | - rettv->vval.v_string = vim_strsave(p); | |
9472 | - } | |
9473 | - else | |
9474 | - { | |
9555 | + if (argvars[1].v_type == VAR_UNKNOWN) | |
9556 | + end = 0; | |
9557 | + else | |
9475 | 9558 | end = get_tv_lnum(&argvars[1]); |
9476 | - if (end < lnum) | |
9477 | - { | |
9478 | - if (end >= 0) /* else: error message already given */ | |
9479 | - EMSG(_(e_invrange)); | |
9480 | - rettv->vval.v_number = 0; | |
9481 | - } | |
9482 | - else | |
9483 | - { | |
9484 | - l = list_alloc(); | |
9485 | - if (l != NULL) | |
9486 | - { | |
9487 | - if (lnum < 1) | |
9488 | - lnum = 1; | |
9489 | - if (end > curbuf->b_ml.ml_line_count) | |
9490 | - end = curbuf->b_ml.ml_line_count; | |
9491 | - while (lnum <= end) | |
9492 | - { | |
9493 | - li = listitem_alloc(); | |
9494 | - if (li == NULL) | |
9495 | - break; | |
9496 | - list_append(l, li); | |
9497 | - li->li_tv.v_type = VAR_STRING; | |
9498 | - li->li_tv.v_lock = 0; | |
9499 | - li->li_tv.vval.v_string = vim_strsave(ml_get(lnum++)); | |
9500 | - } | |
9501 | - rettv->vval.v_list = l; | |
9502 | - rettv->v_type = VAR_LIST; | |
9503 | - ++l->lv_refcount; | |
9504 | - } | |
9505 | - } | |
9506 | - } | |
9559 | + | |
9560 | + get_buffer_lines(curbuf, lnum, end, rettv); | |
9507 | 9561 | } |
9508 | 9562 | |
9509 | 9563 | /* |