diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-01-10 04:23:05 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-01-10 04:23:05 +0000 |
commit | 86569043ad626edf9c8d856376696b63f6094060 (patch) | |
tree | e11be4d0f4944f044598f29b6e31893ad6088dd8 /pango | |
parent | 9bca506cfbf0b969f2d1b086448916c91261c22a (diff) | |
parent | d04872ad221b56f80ff20503816fde4dd10636c6 (diff) | |
download | pango-86569043ad626edf9c8d856376696b63f6094060.tar.gz |
Merge branch 'attrlist-splice' into 'main'
Clarify pango_attr_list_splice docs
Closes #653
See merge request GNOME/pango!574
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-attributes.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index cafe0df3..696f9ba1 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -2289,10 +2289,16 @@ pango_attr_list_update (PangoAttrList *list, * that applies at position @pos in @list by an amount @len, * and then calling [method@Pango.AttrList.change] with a copy * of each attribute in @other in sequence (offset in position - * by @pos). + * by @pos, and limited in length to @len). * * This operation proves useful for, for instance, inserting * a pre-edit string in the middle of an edit buffer. + * + * For backwards compatibility, the function behaves differently + * when @len is 0. In this case, the attributes from @other are + * not imited to @len, and are just overlayed on top of @list. + * + * This mode is useful for merging two lists of attributes together. */ void pango_attr_list_splice (PangoAttrList *list, @@ -2347,8 +2353,16 @@ pango_attr_list_splice (PangoAttrList *list, for (i = 0, p = other->attributes->len; i < p; i++) { PangoAttribute *attr = pango_attribute_copy (g_ptr_array_index (other->attributes, i)); - attr->start_index = MIN (CLAMP_ADD (attr->start_index, upos), end); - attr->end_index = MIN (CLAMP_ADD (attr->end_index, upos), end); + if (ulen > 0) + { + attr->start_index = MIN (CLAMP_ADD (attr->start_index, upos), end); + attr->end_index = MIN (CLAMP_ADD (attr->end_index, upos), end); + } + else + { + attr->start_index = CLAMP_ADD (attr->start_index, upos); + attr->end_index = CLAMP_ADD (attr->end_index, upos); + } /* Same as above, the attribute could be squashed to zero-length; here * pango_attr_list_change() will take care of deleting it. |