[pango/avoid-overlong-lines: 4/6] Add pango_item_unsplit
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/avoid-overlong-lines: 4/6] Add pango_item_unsplit
- Date: Fri, 12 Nov 2021 01:01:28 +0000 (UTC)
commit 88eacd0e3e8dc2b6230eb693df4b08d203a57450
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Nov 11 19:48:19 2021 -0500
Add pango_item_unsplit
This undoes the effect of pango_item_split.
We will use this in future commits.
Private for now.
pango/pango-item-private.h | 4 ++++
pango/pango-item.c | 27 ++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
---
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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]