patch 8.2.3356: adding many text properties requires a lot of function calls
Problem: Adding many text properties requires a lot of function calls.
Solution: Add the prop_add_list() function. (Yegappan Lakshmanan,
closes #8751)
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 31e901a..db74f9c 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2801,7 +2801,9 @@
prompt_setcallback({buf}, {expr}) none set prompt callback function
prompt_setinterrupt({buf}, {text}) none set prompt interrupt function
prompt_setprompt({buf}, {text}) none set prompt text
-prop_add({lnum}, {col}, {props}) none add a text property
+prop_add({lnum}, {col}, {props}) none add one text property
+prop_add_list({props}, [[{lnum}, {col}, {end-lnum}, {end-col}], ...])
+ none add multiple text properties
prop_clear({lnum} [, {lnum-end} [, {props}]])
none remove all text properties
prop_find({props} [, {direction}])
diff --git a/runtime/doc/textprop.txt b/runtime/doc/textprop.txt
index 52191ae..c742293 100644
--- a/runtime/doc/textprop.txt
+++ b/runtime/doc/textprop.txt
@@ -108,6 +108,9 @@
Manipulating text properties:
prop_add({lnum}, {col}, {props}) add a text property
+prop_add_list({props}, [[{lnum}, {col}, {end-lnum}, {end-col}], ...])
+ add a text property at multiple
+ positions.
prop_clear({lnum} [, {lnum-end} [, {bufnr}]])
remove all text properties
prop_find({props} [, {direction}]) search for a text property
@@ -158,6 +161,35 @@
Can also be used as a |method|: >
GetLnum()->prop_add(col, props)
+ *prop_add_list()*
+prop_add_list({props}, [[{lnum}, {col}, {end-lnum}, {end-col}], ...])
+ Similar to prop_add(), but attaches a text property at
+ multiple positions in a buffer.
+
+ {props} is a dictionary with these fields:
+ bufnr buffer to add the property to; when omitted
+ the current buffer is used
+ id user defined ID for the property; must be a
+ number; when omitted zero is used
+ type name of the text property type
+ All fields except "type" are optional.
+
+ The second argument is a List of Lists where each list
+ specifies the starting and ending position of the text. The
+ first two items {lnum} and {col} specify the starting position
+ of the text where the property will be attached and the last
+ two items {end-lnum} and {end-col} specify the position just
+ after the text.
+
+ Example:
+ call prop_add_list(#{type: 'MyProp', id: 2},
+ \ [[1, 4, 1, 7],
+ \ [1, 15, 1, 20],
+ \ [2, 30, 3, 30]]
+
+ Can also be used as a |method|: >
+ GetProp()->prop_add_list([[1, 1, 1, 2], [1, 4, 1, 8]])
+
prop_clear({lnum} [, {lnum-end} [, {props}]]) *prop_clear()*
Remove all text properties from line {lnum}.
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 3a3a0fc..a5dde18 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1161,6 +1161,7 @@
Text Properties: *text-property-functions*
prop_add() attach a property at a position
+ prop_add_list() attach a property at multiple positions
prop_clear() remove all properties from a line or lines
prop_find() search for a property
prop_list() return a list of all properties in a line