comparison runtime/doc/textprop.txt @ 25640:78ef12e0ce8c v8.2.3356

patch 8.2.3356: adding many text properties requires a lot of function calls Commit: https://github.com/vim/vim/commit/ccfb7c6758510e0fe5f390149ea14aee6ff4f55e Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Aug 16 21:39:09 2021 +0200 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)
author Bram Moolenaar <Bram@vim.org>
date Mon, 16 Aug 2021 21:45:03 +0200
parents b427a26b0210
children d4faa2c5211b
comparison
equal deleted inserted replaced
25639:b5eedbdaca91 25640:78ef12e0ce8c
106 106
107 107
108 Manipulating text properties: 108 Manipulating text properties:
109 109
110 prop_add({lnum}, {col}, {props}) add a text property 110 prop_add({lnum}, {col}, {props}) add a text property
111 prop_add_list({props}, [[{lnum}, {col}, {end-lnum}, {end-col}], ...])
112 add a text property at multiple
113 positions.
111 prop_clear({lnum} [, {lnum-end} [, {bufnr}]]) 114 prop_clear({lnum} [, {lnum-end} [, {bufnr}]])
112 remove all text properties 115 remove all text properties
113 prop_find({props} [, {direction}]) search for a text property 116 prop_find({props} [, {direction}]) search for a text property
114 prop_list({lnum} [, {props}]) text properties in {lnum} 117 prop_list({lnum} [, {props}]) text properties in {lnum}
115 prop_remove({props} [, {lnum} [, {lnum-end}]]) 118 prop_remove({props} [, {lnum} [, {lnum-end}]])
155 added to. When not found, the global property types are used. 158 added to. When not found, the global property types are used.
156 If not found an error is given. 159 If not found an error is given.
157 160
158 Can also be used as a |method|: > 161 Can also be used as a |method|: >
159 GetLnum()->prop_add(col, props) 162 GetLnum()->prop_add(col, props)
163
164 *prop_add_list()*
165 prop_add_list({props}, [[{lnum}, {col}, {end-lnum}, {end-col}], ...])
166 Similar to prop_add(), but attaches a text property at
167 multiple positions in a buffer.
168
169 {props} is a dictionary with these fields:
170 bufnr buffer to add the property to; when omitted
171 the current buffer is used
172 id user defined ID for the property; must be a
173 number; when omitted zero is used
174 type name of the text property type
175 All fields except "type" are optional.
176
177 The second argument is a List of Lists where each list
178 specifies the starting and ending position of the text. The
179 first two items {lnum} and {col} specify the starting position
180 of the text where the property will be attached and the last
181 two items {end-lnum} and {end-col} specify the position just
182 after the text.
183
184 Example:
185 call prop_add_list(#{type: 'MyProp', id: 2},
186 \ [[1, 4, 1, 7],
187 \ [1, 15, 1, 20],
188 \ [2, 30, 3, 30]]
189
190 Can also be used as a |method|: >
191 GetProp()->prop_add_list([[1, 1, 1, 2], [1, 4, 1, 8]])
160 192
161 193
162 prop_clear({lnum} [, {lnum-end} [, {props}]]) *prop_clear()* 194 prop_clear({lnum} [, {lnum-end} [, {props}]]) *prop_clear()*
163 Remove all text properties from line {lnum}. 195 Remove all text properties from line {lnum}.
164 When {lnum-end} is given, remove all text properties from line 196 When {lnum-end} is given, remove all text properties from line