summaryrefslogtreecommitdiff
path: root/pango/pango-item.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-12 01:31:05 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-11-12 01:31:05 +0000
commitae15885600be2e3ac3fe48aff821881a0feb018b (patch)
treeb39cd51dd5ac0892348f9c014587d5d7d45bf279 /pango/pango-item.c
parent907b6e21fcb846995cc5b03d2cb1b68fbbc2a2b5 (diff)
parent401237f4f19690771b5383a08dd71a638f77b2a0 (diff)
downloadpango-ae15885600be2e3ac3fe48aff821881a0feb018b.tar.gz
Merge branch 'avoid-overlong-lines' into 'main'
layout: Try harder to not produce overlong lines See merge request GNOME/pango!501
Diffstat (limited to 'pango/pango-item.c')
-rw-r--r--pango/pango-item.c27
1 files changed, 26 insertions, 1 deletions
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)
{