1
0
forked from aniani/vim

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)
This commit is contained in:
Yegappan Lakshmanan
2021-08-16 21:39:09 +02:00
committed by Bram Moolenaar
parent 434df7a401
commit ccfb7c6758
9 changed files with 277 additions and 101 deletions

View File

@@ -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}])

View File

@@ -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}.

View File

@@ -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