diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-11-11 19:48:19 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-11-11 20:23:47 -0500 |
commit | 0c80c6d0b80cce4443e9a18fad2b4bccabaf4325 (patch) | |
tree | dcf1e5d1a61450f982632ea3487265328267691b /pango | |
parent | 399a4b9ba16e32edce848339f6a77389b93b09bc (diff) | |
download | pango-0c80c6d0b80cce4443e9a18fad2b4bccabaf4325.tar.gz |
Add pango_item_unsplit
This undoes the effect of pango_item_split.
We will use this in future commits.
Private for now.
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-item-private.h | 4 | ||||
-rw-r--r-- | pango/pango-item.c | 27 |
2 files changed, 30 insertions, 1 deletions
diff --git a/pango/pango-item-private.h b/pango/pango-item-private.h index ef3e8ed0..d37fc3f8 100644 --- a/pango/pango-item-private.h +++ b/pango/pango-item-private.h @@ -88,6 +88,10 @@ GList * pango_itemize_post_process_items (PangoContext PangoLogAttr *log_attrs, GList *items); +void pango_item_unsplit (PangoItem *orig, + int split_index, + int split_offset); + G_END_DECLS diff --git a/pango/pango-item.c b/pango/pango-item.c index 4b02c277..2b2664c5 100644 --- a/pango/pango-item.c +++ b/pango/pango-item.c @@ -138,7 +138,7 @@ G_DEFINE_BOXED_TYPE (PangoItem, pango_item, * Return value: new item representing text before @split_index, which * should be freed with [method@Pango.Item.free]. */ -PangoItem* +PangoItem * pango_item_split (PangoItem *orig, int split_index, int split_offset) @@ -164,6 +164,31 @@ pango_item_split (PangoItem *orig, return new_item; } +/*< private > + * pango_item_unsplit: + * @orig: the item to unsplit + * @split_index: value passed to pango_item_split() + * @split_offset: value passed to pango_item_split() + * + * Undoes the effect of a pango_item_split() call with + * the same arguments. + * + * You are expected to free the new item that was returned + * by pango_item_split() yourself. + */ +void +pango_item_unsplit (PangoItem *orig, + int split_index, + int split_offset) +{ + orig->offset -= split_index; + orig->length += split_index; + orig->num_chars += split_offset; + + if (orig->analysis.flags & PANGO_ANALYSIS_FLAG_HAS_CHAR_OFFSET) + ((PangoItemPrivate *)orig)->char_offset -= split_offset; +} + static int compare_attr (gconstpointer p1, gconstpointer p2) { |