[pango/visible-things: 59/71] Add an attribute for showing invisible chars
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/visible-things: 59/71] Add an attribute for showing invisible chars
- Date: Tue, 23 Jul 2019 06:06:51 +0000 (UTC)
commit 80cc60d13579d5c37f99d56f281bdf89f2efa3d7
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jul 13 15:49:25 2019 -0400
Add an attribute for showing invisible chars
Allow to opt-in to showing spaces, line breaks,
and default-ignorable chars, separately.
docs/pango-sections.txt | 2 ++
pango/pango-attributes.c | 24 ++++++++++++++++++++++++
pango/pango-attributes.h | 24 +++++++++++++++++++++++-
3 files changed, 49 insertions(+), 1 deletion(-)
---
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index 5050a1f3..51e85095 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -415,6 +415,8 @@ pango_color_parse
pango_color_copy
pango_color_free
pango_color_to_string
+PangoShowFlags
+pango_attr_show_new
<SUBSECTION>
PangoAttrList
PANGO_TYPE_ATTR_LIST
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 15edfbe8..b773b67c 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1206,6 +1206,30 @@ pango_attr_allow_breaks_new (gboolean allow_breaks)
return pango_attr_int_new (&klass, (int)allow_breaks);
}
+/**
+ * pango_attr_show_new:
+ * @show: #PangoShowFlags to apply
+ *
+ * Create a new show attribute.
+ *
+ * Return value: (transfer full): the newly allocated #PangoAttribute,
+ * which should be freed with pango_attribute_destroy().
+ *
+ * Since: 1.44
+ **/
+PangoAttribute *
+pango_attr_show_new (PangoShowFlags flags)
+{
+ static const PangoAttrClass klass = {
+ PANGO_ATTR_SHOW,
+ pango_attr_int_copy,
+ pango_attr_int_destroy,
+ pango_attr_int_equal,
+ };
+
+ return pango_attr_int_new (&klass, (int)flags);
+}
+
/*
* Attribute List
*/
diff --git a/pango/pango-attributes.h b/pango/pango-attributes.h
index f7a0c1cb..b6a786f4 100644
--- a/pango/pango-attributes.h
+++ b/pango/pango-attributes.h
@@ -148,6 +148,7 @@ typedef struct _PangoAttrIterator PangoAttrIterator;
* @PANGO_ATTR_FOREGROUND_ALPHA: foreground alpha (#PangoAttrInt). Since 1.38
* @PANGO_ATTR_BACKGROUND_ALPHA: background alpha (#PangoAttrInt). Since 1.38
* @PANGO_ATTR_ALLOW_BREAKS: whether breaks are allowed (#PangoAttrInt). Since 1.44
+ * @PANGO_ATTR_SHOW: how to render invisible characters (#PangoAttrInt). Since 1.44
*
* The #PangoAttrType
* distinguishes between different types of attributes. Along with the
@@ -184,7 +185,8 @@ typedef enum
PANGO_ATTR_FONT_FEATURES, /* PangoAttrString */
PANGO_ATTR_FOREGROUND_ALPHA, /* PangoAttrInt */
PANGO_ATTR_BACKGROUND_ALPHA, /* PangoAttrInt */
- PANGO_ATTR_ALLOW_BREAKS /* PangoAttrInt */
+ PANGO_ATTR_ALLOW_BREAKS, /* PangoAttrInt */
+ PANGO_ATTR_SHOW, /* PangoAttrInt */
} PangoAttrType;
/**
@@ -527,6 +529,26 @@ PangoAttribute *pango_attr_background_alpha_new (guint16 alpha);
PANGO_AVAILABLE_IN_1_44
PangoAttribute *pango_attr_allow_breaks_new (gboolean allow_breaks);
+/**
+ * PangoShowFlags:
+ * @PANGO_SHOW_NONE: No special treatment
+ * @PANGO_SHOW_SPACES: Render spaces, tabs and newlines visibly
+ * @PANGO_SHOW_LINE_BREAKS: Render line breaks visibly
+ * @PANGO_SHOW_IGNORABLES: Render default-ignorable Unicode
+ * characters visibly
+ *
+ * These flags affect how Pango treats characters that are normally
+ * not visible in the output.
+ */
+typedef enum {
+ PANGO_SHOW_NONE = 0,
+ PANGO_SHOW_SPACES = 1 << 0,
+ PANGO_SHOW_LINE_BREAKS = 1 << 1,
+ PANGO_SHOW_IGNORABLES = 1 << 2
+} PangoShowFlags;
+PANGO_AVAILABLE_IN_1_44
+PangoAttribute *pango_attr_show_new (PangoShowFlags flags);
+
PANGO_AVAILABLE_IN_ALL
GType pango_attr_list_get_type (void) G_GNUC_CONST;
PANGO_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]