diff options
author | Owen Taylor <otaylor@redhat.com> | 2000-09-11 03:04:49 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2000-09-11 03:04:49 +0000 |
commit | b19ed06afbc88f37adf25f63ca52e0a73c00ee23 (patch) | |
tree | 1ef16385ebffdebe1a726434ec2312e99f17a399 /pango/pango-attributes.c | |
parent | 2ea04c9040af34b36ed4b1536fd08c5843467446 (diff) | |
download | pango-b19ed06afbc88f37adf25f63ca52e0a73c00ee23.tar.gz |
Fix bug where wrong attribute list was unreferenced.
Sun Sep 10 03:01:53 2000 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_set_attributes): Fix
bug where wrong attribute list was unreferenced.
* pango/pango-attributes.[ch]: Add function
pango_attr_list_splice() to splice contents of one
attribute list into another attribute list.
* pango/pango-utils.h: Add include of pango-font.h since
it now depends on declarations from there.
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r-- | pango/pango-attributes.c | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index b87f6542..9a640239 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -898,7 +898,7 @@ pango_attr_list_change (PangoAttrList *list, } else { - /* Truncate and/or remove the old attribute + /* Split, truncate, or remove the old attribute */ if (tmp_attr->end_index > attr->end_index) { @@ -1012,6 +1012,69 @@ pango_attr_list_change (PangoAttrList *list, } /** + * pango_attr_list_splice: + * @list: a #PangoAttrList + * @other: another #PangoAttrList + * @pos: the position in @list at which to insert @other + * @len: the length of the spliced segment. (Note that this + * must be specified since the attributes in @other + * may only be present at some subsection of this range) + * + * This function splices attribute list @other into @list. + * This operation is equivalent to stretching every attribute + * applies at position @pos in @list by an amount @len, + * and then calling pango_attr_list_change() with a copy + * of each attributes in @other in sequence (offset in position by @pos). + * + * This operation proves useful for, for instance, inserting + * a preedit string in the middle of an edit buffer. + **/ +void +pango_attr_list_splice (PangoAttrList *list, + PangoAttrList *other, + gint pos, + gint len) +{ + GSList *tmp_list; + + g_return_if_fail (list != NULL); + g_return_if_fail (other != NULL); + g_return_if_fail (pos >= 0); + g_return_if_fail (len >= 0); + + tmp_list = list->attributes; + while (tmp_list) + { + PangoAttribute *attr = tmp_list->data; + + if (attr->start_index <= pos) + { + if (attr->end_index > pos) + attr->end_index += len; + } + else + { + attr->start_index += len; + attr->end_index += len; + } + + tmp_list = tmp_list->next; + } + + tmp_list = other->attributes; + while (tmp_list) + { + PangoAttribute *attr = pango_attribute_copy (tmp_list->data); + attr->start_index += pos; + attr->end_index += pos; + + pango_attr_list_change (list, attr); + + tmp_list = tmp_list->next; + } +} + +/** * pango_attr_list_get_iterator: * @list: a #PangoAttrList * |