Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/runtime/doc/textprop.txt +++ b/runtime/doc/textprop.txt @@ -108,6 +108,9 @@ prop_type_list([{props}]) get list of p 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}.