summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-04 21:57:18 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-04 21:57:18 +0200
commita5a7882ea4a21944924b778208e1d54734891033 (patch)
tree4a65d762e9c89943a98f0934f21202c47897f42d
parent26262f87770d3a1a68b09a70152d75c2e2ae186f (diff)
downloadvim-git-a5a7882ea4a21944924b778208e1d54734891033.tar.gz
patch 8.1.1986: more functions can be used as methodsv8.1.1986
Problem: More functions can be used as methods. Solution: Make textprop functions usable as a method.
-rw-r--r--runtime/doc/textprop.txt23
-rw-r--r--src/evalfunc.c18
-rw-r--r--src/testdir/test_textprop.vim20
-rw-r--r--src/version.c2
4 files changed, 43 insertions, 20 deletions
diff --git a/runtime/doc/textprop.txt b/runtime/doc/textprop.txt
index 5facae675..df12f83e7 100644
--- a/runtime/doc/textprop.txt
+++ b/runtime/doc/textprop.txt
@@ -1,4 +1,4 @@
-*textprop.txt* For Vim version 8.1. Last change: 2019 Aug 25
+*textprop.txt* For Vim version 8.1. Last change: 2019 Sep 04
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -157,6 +157,9 @@ prop_add({lnum}, {col}, {props})
See |text-properties| for information about text properties.
+ Can also be used as a |method|: >
+ GetLnum()->prop_add(col, props)
+
prop_clear({lnum} [, {lnum-end} [, {props}]]) *prop_clear()*
Remove all text properties from line {lnum}.
@@ -168,6 +171,9 @@ prop_clear({lnum} [, {lnum-end} [, {props}]]) *prop_clear()*
See |text-properties| for information about text properties.
+ Can also be used as a |method|: >
+ GetLnum()->prop_clear()
+<
*prop_find()*
prop_find({props} [, {direction}])
{not implemented yet}
@@ -220,7 +226,9 @@ prop_list({lnum} [, {props}]) *prop_list()*
See |text-properties| for information about text properties.
-
+ Can also be used as a |method|: >
+ GetLnum()->prop_list()
+<
*prop_remove()* *E968*
prop_remove({props} [, {lnum} [, {lnum-end}]])
Remove a matching text property from line {lnum}. When
@@ -243,6 +251,9 @@ prop_remove({props} [, {lnum} [, {lnum-end}]])
See |text-properties| for information about text properties.
+ Can also be used as a |method|: >
+ GetProps()->prop_remove()
+
prop_type_add({name}, {props}) *prop_type_add()* *E969* *E970*
Add a text property type {name}. If a property type with this
@@ -267,6 +278,8 @@ prop_type_add({name}, {props}) *prop_type_add()* *E969* *E970*
See |text-properties| for information about text properties.
+ Can also be used as a |method|: >
+ GetPropName()->prop_type_add(props)
prop_type_change({name}, {props}) *prop_type_change()*
Change properties of an existing text property type. If a
@@ -275,6 +288,8 @@ prop_type_change({name}, {props}) *prop_type_change()*
See |text-properties| for information about text properties.
+ Can also be used as a |method|: >
+ GetPropName()->prop_type_change(props)
prop_type_delete({name} [, {props}]) *prop_type_delete()*
Remove the text property type {name}. When text properties
@@ -289,6 +304,8 @@ prop_type_delete({name} [, {props}]) *prop_type_delete()*
See |text-properties| for information about text properties.
+ Can also be used as a |method|: >
+ GetPropName()->prop_type_delete()
prop_type_get([{name} [, {props}]) *prop_type_get()*
Returns the properties of property type {name}. This is a
@@ -302,6 +319,8 @@ prop_type_get([{name} [, {props}]) *prop_type_get()*
See |text-properties| for information about text properties.
+ Can also be used as a |method|: >
+ GetPropName()->prop_type_get()
prop_type_list([{props}]) *prop_type_list()*
Returns a list with all property type names.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index e14aa0452..13326e32b 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -663,15 +663,15 @@ static funcentry_T global_functions[] =
{"prompt_setprompt", 2, 2, FEARG_1, f_prompt_setprompt},
#endif
#ifdef FEAT_TEXT_PROP
- {"prop_add", 3, 3, 0, f_prop_add},
- {"prop_clear", 1, 3, 0, f_prop_clear},
- {"prop_list", 1, 2, 0, f_prop_list},
- {"prop_remove", 1, 3, 0, f_prop_remove},
- {"prop_type_add", 2, 2, 0, f_prop_type_add},
- {"prop_type_change", 2, 2, 0, f_prop_type_change},
- {"prop_type_delete", 1, 2, 0, f_prop_type_delete},
- {"prop_type_get", 1, 2, 0, f_prop_type_get},
- {"prop_type_list", 0, 1, 0, f_prop_type_list},
+ {"prop_add", 3, 3, FEARG_1, f_prop_add},
+ {"prop_clear", 1, 3, FEARG_1, f_prop_clear},
+ {"prop_list", 1, 2, FEARG_1, f_prop_list},
+ {"prop_remove", 1, 3, FEARG_1, f_prop_remove},
+ {"prop_type_add", 2, 2, FEARG_1, f_prop_type_add},
+ {"prop_type_change", 2, 2, FEARG_1, f_prop_type_change},
+ {"prop_type_delete", 1, 2, FEARG_1, f_prop_type_delete},
+ {"prop_type_get", 1, 2, FEARG_1, f_prop_type_get},
+ {"prop_type_list", 0, 1, FEARG_1, f_prop_type_list},
#endif
{"pum_getpos", 0, 0, 0, f_pum_getpos},
{"pumvisible", 0, 0, 0, f_pumvisible},
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 3d3cce815..aede59b2d 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -25,7 +25,7 @@ func Test_proptype_global()
call prop_type_add('one', {})
call assert_equal(1, len(prop_type_list()))
- let proptype = prop_type_get('one')
+ let proptype = 'one'->prop_type_get()
call assert_false(has_key(proptype, 'highlight'))
call assert_equal(0, proptype['priority'])
call assert_equal(0, proptype['start_incl'])
@@ -53,7 +53,7 @@ func Test_proptype_buf()
call assert_equal(1, proptype['end_incl'])
call prop_type_delete('comment', {'bufnr': bufnr})
- call assert_equal(0, len(prop_type_list({'bufnr': bufnr})))
+ call assert_equal(0, len({'bufnr': bufnr}->prop_type_list()))
call prop_type_add('one', {'bufnr': bufnr})
let proptype = prop_type_get('one', {'bufnr': bufnr})
@@ -89,7 +89,7 @@ endfunc
func SetupPropsInFirstLine()
call setline(1, 'one two three')
call prop_add(1, 1, {'length': 3, 'id': 11, 'type': 'one'})
- call prop_add(1, 5, {'length': 3, 'id': 12, 'type': 'two'})
+ eval 1->prop_add(5, {'length': 3, 'id': 12, 'type': 'two'})
call prop_add(1, 9, {'length': 5, 'id': 13, 'type': 'three'})
call prop_add(1, 1, {'length': 13, 'id': 14, 'type': 'whole'})
endfunc
@@ -139,7 +139,7 @@ func Test_prop_remove()
call assert_equal(props, prop_list(1))
" remove by id
- call assert_equal(1, prop_remove({'id': 12}, 1))
+ call assert_equal(1, {'id': 12}->prop_remove(1))
unlet props[2]
call assert_equal(props, prop_list(1))
@@ -344,8 +344,8 @@ func Test_prop_clear()
call SetupPropsInFirstLine()
call assert_equal(Get_expected_props(), prop_list(1))
- call prop_clear(1)
- call assert_equal([], prop_list(1))
+ eval 1->prop_clear()
+ call assert_equal([], 1->prop_list())
call DeletePropTypes()
bwipe!
@@ -489,7 +489,7 @@ func Setup_three_line_prop()
endfunc
func Test_prop_multiline()
- call prop_type_add('comment', {'highlight': 'Directory'})
+ eval 'comment'->prop_type_add({'highlight': 'Directory'})
new
call setline(1, ['xxxxxxx', 'yyyyyyyyy', 'zzzzzzzz'])
@@ -672,11 +672,13 @@ func Test_textprop_screenshot_various()
\ "hi BackgroundProp ctermbg=lightgrey",
\ "hi UnderlineProp cterm=underline",
\ "call prop_type_add('number', {'highlight': 'NumberProp'})",
- \ "call prop_type_add('long', {'highlight': 'LongProp'})",
+ \ "call prop_type_add('long', {'highlight': 'NumberProp'})",
+ \ "call prop_type_change('long', {'highlight': 'LongProp'})",
\ "call prop_type_add('start', {'highlight': 'NumberProp', 'start_incl': 1})",
\ "call prop_type_add('end', {'highlight': 'NumberProp', 'end_incl': 1})",
\ "call prop_type_add('both', {'highlight': 'NumberProp', 'start_incl': 1, 'end_incl': 1})",
- \ "call prop_type_add('background', {'highlight': 'BackgroundProp', 'combine': 1})",
+ \ "call prop_type_add('background', {'highlight': 'NumberProp', 'combine': 1})",
+ \ "eval 'background'->prop_type_change({'highlight': 'BackgroundProp'})",
\ "call prop_type_add('error', {'highlight': 'UnderlineProp', 'combine': 1})",
\ "call prop_add(1, 4, {'end_lnum': 3, 'end_col': 3, 'type': 'long'})",
\ "call prop_add(2, 9, {'length': 3, 'type': 'number'})",
diff --git a/src/version.c b/src/version.c
index b3942694c..d61b59c47 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1986,
+/**/
1985,
/**/
1984,