summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2021-08-16 21:39:09 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-16 21:39:09 +0200
commitccfb7c6758510e0fe5f390149ea14aee6ff4f55e (patch)
treebc6984780b38233a25aff66d15d9af2798999bb0 /runtime
parent434df7a401c92d4084bb0a01ffd6d1737ae0193b (diff)
downloadvim-git-ccfb7c6758510e0fe5f390149ea14aee6ff4f55e.tar.gz
patch 8.2.3356: adding many text properties requires a lot of function callsv8.2.3356
Problem: Adding many text properties requires a lot of function calls. Solution: Add the prop_add_list() function. (Yegappan Lakshmanan, closes #8751)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/eval.txt4
-rw-r--r--runtime/doc/textprop.txt32
-rw-r--r--runtime/doc/usr_41.txt1
3 files changed, 36 insertions, 1 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 31e901a54..db74f9c10 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2801,7 +2801,9 @@ prompt_getprompt({buf}) String get prompt text
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 52191ae03..c742293db 100644
--- a/runtime/doc/textprop.txt
+++ b/runtime/doc/textprop.txt
@@ -108,6 +108,9 @@ prop_type_list([{props}]) get list of property types
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 @@ prop_add({lnum}, {col}, {props})
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 3a3a0fca7..a5dde18c3 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1161,6 +1161,7 @@ Prompt Buffer: *promptbuffer-functions*
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