On 11/28/18 5:01 PM, Bram Moolenaar wrote:
This is the result of the poll for features needed for supporting plugins.
These functions are to be added to support highlighting text, as defined
with text properties and text property types.

A text property type defines the highlighting and further attributes for
a kind of text property, such as the priority.

A text property defines the position where a text property type applies.
Text properties can overlap, the one with the highest priority will be
used for the highlighting.  Text properties move with the text when
changes are made.

Although both syntax highlighting and text properties can be active at
the same time, normally only one of them would be present in a buffer.
In case they do both exist, text properties overrule syntax
highlighting.


Please have a look at this and give feedback before I finish a first
implementation.


                                                        *prop_add()*
prop_add({lnum}, {col}, {props})
                Add a text property at position {lnum}, {col}.  Use one for
                the first column.
                If {lnum} is invalid an error is given.
                If {col} is invalid the text property has no effect, no error
                is given.

                {props} is a dictionary with these fields:
                        "length"   - length of text in characters, can only be
                                        used for a property that does not
                                        continue in another line
                        "end_lnum" - line number for end of text
                        "end_col"  - column for end of text
                        "bufnr        - buffer to add the property to, when
                                     omitted the current buffer is used
                        "id"     - user defined ID for the property; when
                                     omitted zero is used
                        "type"           - name of the text property type
                All fields except "type" are optional.
                It is an error when both "length" and 'end_lnum" or "end_col"
                are passed.
                When neither "length" or "end_col" are passed the property
                will apply to one character.
                "type" will first be looked up in the buffer the property is
                added to. When not found, the the global property types are
                used.  If not found and error is given.

prop_clear({lnum} [, {lnum_end} [, {bufnr}]])           *prop_clear()*
                Remove all text properties from line {lnum}.
                When {lnum_end} is given, remove all text properties from line
                {lnum} to {lnum_end} (inclusive).
                When {bufnr} is given use this buffer, otherwise use the
                current buffer.

prop_list({lnum} [, {bufnr}])                           *prop_list()*
                Return a List with all text properties in line {lnum}.
                When {bufnr} is given, use this buffer instead of the current
                buffer.

prop_remove({what}, {props}, {lnum} [, {lnum_end})      *prop_remove()*
                Remove a matching text property from line {lnum}.  When
                {lnum_end} is given, remove matching text properties from line
                {lnum} to {lnum_end} (inclusive).

                When {what} is "first" only remove the first matching
                property.
                When {what} is "all" remove all matching properties.

                {props} is a dictionary with these fields:
                        "id"    - remove text properties with this ID
                        "type"  - remove text properties with this type name
                        "bufnr" - use this buffer instead of the current one
                A property matches when either "id" or "type" matches.

                Returns the number of properties that were removed.

prop_type_add({name}, {props})                          *prop_type_add()*
                Add a text property type {name}.  If a property type with this
                name allready exists an error is given.
                {props} is a dictionary with these optional fields:
                        "bufnr"             - define the property only for this
                                        buffer; this avoids name collisions and
                                        automatically clears the property types
                                        when the buffer is deleted.
                        "highlight"   - name of highlight group to use
                        "priority"    - when a character has multiple text
                                        properties the one with the highest
                                        priority will be used; negative values
                                        can be used, the default priority is
                                        zero
                        "start_incl"  - when non-zero inserts at the start
                                        position will be included in the text
                                        property
                        "end_incl"    - when non-zero inserts at the end
                                        position will be included in the text
                                        property

prop_type_change({name}, {props})                       *prop_type_change()*
                Change properties of an existing text property type.  If a
                property with this name does not exist an error is given.
                The {props} argument is just like |prop_type_add()|.

prop_type_delete({name} [, {bufnr}])                    *prop_type_delete()*
                Remove the text property type {name}.  When text properties
                with this {name} are still in place, they will not have an
                effect and can no longer be removed by name.
                When {bufnr} is given, delete a property type from this buffer
                instead of from the global property types.
                When text property type {name} is not found there is no error.

prop_type_get([{name} [, {bufnr}])                      *prop_type_get()*
                Returns the properties of property type {name}.  This is a
                dictionary with the same fields as was given to
                prop_type_add().
                When the property type {name} does not exist, an empty
                dictionary is returned.
                When {bufnr} is given, use this buffer instead of the global
                property types.

prop_type_list([{bufnr}])                               *prop_type_list()*
                Returns a list with all property type names.
                When {bufnr} is given, use this buffer instead of the global
                property types.


1. Do text properties move their column positions with edits or only their line positions (like marks)?  If the former, I think this would be a major feature for plugin developers.


2. How does the (highlight) priority interact with that of matchadd[pos]?  Should the default priority be 10 or is the intent for matchaddpos to take precedence?


3. Is there a way to retrieve a text property by its ID instead of by line+column?  Since a plugin does not know where the property may end up after some editing and plugins can use this feature to track positions in the text.


4. How can plugins manage conflicts between IDs?


--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui