pangomm 2.56.2

Public Member Functions | Static Public Member Functions | Protected Attributes | Related Symbols | List of all members
Pango::AttrList Class Reference

A Pango::AttrList represents a list of attributes that apply to a section of text. More...

`#include <pangomm/attrlist.h>`

## Public Member Functions
| AttrList ()
| AttrList (PangoAttrList * gobject, bool make_a_copy=true)
| AttrList (const AttrList & other)
AttrList & | operator= (const AttrList & other)
| AttrList (AttrList && other) noexcept
AttrList & | operator= (AttrList && other) noexcept
| ~AttrList () noexcept
void | swap (AttrList & other) noexcept
PangoAttrList * | gobj ()
| Provides access to the underlying C instance.
const PangoAttrList * | gobj () const
| Provides access to the underlying C instance.
PangoAttrList * | gobj_copy () const
| Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
| AttrList (const Glib::ustring & markup_text, gunichar accel_marker=0)
| Constructs an attribute list by parsing a marked-up text (see markup format).
| AttrList (const Glib::ustring & markup_text, gunichar accel_marker, Glib::ustring & text, gunichar & accel_char)
| Constructs an attribute list by parsing a marked-up text (see markup format).
| operator bool () const
| Tests whether the AttrList is valid.
void | insert (Attribute & attr)
| Insert the given attribute into the Pango::AttrList.
void | insert_before (Attribute & attr)
| Insert the given attribute into the Pango::AttrList.
void | change (Attribute & attr)
| Insert the given attribute into the Pango::AttrList.
void | splice (AttrList & other, int pos, int len)
| This function opens up a hole in list, fills it in with attributes from the left, and then merges other on top of the hole.
void | update (int pos, int remove, int add)
| Update indices of attributes in list for a change in the text they refer to.
std::vector< Attribute > | get_attributes () const
| Gets a list of all attributes in list.
bool | equal (const AttrList & other_list) const
| Checks whether list and other_list contain the same attributes and whether those attributes apply to the same ranges.
Glib::ustring | to_string () const
| Serializes a Pango::AttrList to a string.
AttrIter | get_iter ()
| Create a iterator initialized to the beginning of the list.

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.
static AttrList | from_string (const Glib::ustring & text)
| Deserializes a Pango::AttrList from a string.

## Protected Attributes
PangoAttrList * | gobject_

## Related Symbols
(Note that these are not member symbols.)
void | swap (AttrList & lhs, AttrList & rhs) noexcept
Pango::AttrList | wrap (PangoAttrList * object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

A Pango::AttrList represents a list of attributes that apply to a section of text.

The attributes are, in general, allowed to overlap in an arbitrary fashion, however, if the attributes are manipulated only through Pango::AttrList::change(), the overlap between properties will meet stricter criteria.

Since the Pango::AttrList structure is stored as a linear list, it is not suitable for storing attributes for large amounts of text. In general, you should not use a single Pango::AttrList for more than one paragraph of text.

When obtaining an AttrList, you should check that it is valid. For instance, if(attrlist).

## Constructor & Destructor Documentation

## ◆ AttrList() [1/6]

Pango::AttrList::AttrList | ( |  | ) |

## ◆ AttrList() [2/6]

Pango::AttrList::AttrList | ( | PangoAttrList * | gobject,
|  | bool | make_a_copy = true )
| explicit

## ◆ AttrList() [3/6]

Pango::AttrList::AttrList | ( | const AttrList & | other | ) |

## ◆ AttrList() [4/6]

Pango::AttrList::AttrList | ( | AttrList && | other | ) |
| noexcept

## ◆ ~AttrList()

Pango::AttrList::~AttrList | ( |  | ) |
| noexcept

## ◆ AttrList() [5/6]

Pango::AttrList::AttrList | ( | const Glib::ustring & | markup_text,
|  | gunichar | accel_marker = 0 )
| explicit

Constructs an attribute list by parsing a marked-up text (see markup format).

If accel_marker is nonzero, the given character will mark the character following it as an accelerator. For example, the accel marker might be an ampersand or underscore. All characters marked as an accelerator will receive a Pango::Underline::LOW attribute. Two accel_marker characters following each other produce a single literal accel_marker character.

Parameters

  markup_text | Markup to parse (see markup format).
  accel_marker | Character that precedes an accelerator, or 0 for none.

## ◆ AttrList() [6/6]

Pango::AttrList::AttrList | ( | const Glib::ustring & | markup_text,
|  | gunichar | accel_marker,
|  | Glib::ustring & | text,
|  | gunichar & | accel_char )

Constructs an attribute list by parsing a marked-up text (see markup format).

text is set to the plaintext string. If accel_marker is nonzero, the given character will mark the character following it as an accelerator. For example, the accel marker might be an ampersand or underscore. All characters marked as an accelerator will receive a Pango::Underline::LOW attribute. The first character so marked will be returned in accel_char. Two accel_marker characters following each other produce a single literal accel_marker character.

Parameters

  markup_text | Markup to parse (see markup format).
  accel_marker | Character that precedes an accelerator, or 0 for none.
  text | Return location for text with tags stripped.
  accel_char | Return location for accelerator char.

## Member Function Documentation

## ◆ change()

void Pango::AttrList::change | ( | Attribute & | attr | ) |

Insert the given attribute into the Pango::AttrList.

It will replace any attributes of the same type on that segment and be merged with any adjoining attributes that are identical.

This function is slower than insert() for creating an attribute list in order (potentially much slower for large lists). However, insert() is not suitable for continually changing a set of attributes since it never removes or combines existing attributes.

Parameters

  attr | The attribute to insert.

## ◆ equal()

bool Pango::AttrList::equal | ( | const AttrList & | other_list | ) | const

Checks whether list and other_list contain the same attributes and whether those attributes apply to the same ranges.

Beware that this will return wrong values if any list contains duplicates.

Since pangomm 2.50

Parameters

  other_list | The other Pango::AttrList.

Returns
  true if the lists are equal, false if they aren't.

## ◆ from_string()

AttrList Pango::AttrList::from_string | ( | const Glib::ustring & | text | ) |
| static

Deserializes a Pango::AttrList from a string.

This is the counterpart to to_string(). See that functions for details about the format.

Since pangomm 2.50

Parameters

  text | A string.

Returns
  A new Pango::AttrList.

## ◆ get_attributes()

std::vector< Attribute > Pango::AttrList::get_attributes | ( |  | ) | const

Gets a list of all attributes in list.

Since pangomm 2.50

Returns
  A list of all attributes in list. To free this value, call [method Pango.Attribute.

## ◆ get_iter()

AttrIter Pango::AttrList::get_iter | ( |  | ) |

Create a iterator initialized to the beginning of the list.

list must not be modified until this iterator is freed.

Returns
  The newly allocated Pango::AttrIterator, which should be freed with Pango::AttrIterator::destroy().

## ◆ get_type()

GType Pango::AttrList::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ gobj() [1/2]

PangoAttrList * Pango::AttrList::gobj | ( |  | ) |
| inline

Provides access to the underlying C instance.

## ◆ gobj() [2/2]

const PangoAttrList * Pango::AttrList::gobj | ( |  | ) | const
| inline

Provides access to the underlying C instance.

## ◆ gobj_copy()

PangoAttrList * Pango::AttrList::gobj_copy | ( |  | ) | const

Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.

## ◆ insert()

void Pango::AttrList::insert | ( | Attribute & | attr | ) |

Insert the given attribute into the Pango::AttrList.

It will be inserted after all other attributes with a matching start_index.

Parameters

  attr | The attribute to insert.

## ◆ insert_before()

void Pango::AttrList::insert_before | ( | Attribute & | attr | ) |

Insert the given attribute into the Pango::AttrList.

It will be inserted before all other attributes with a matching start_index.

Parameters

  attr | The attribute to insert.

## ◆ operator bool()

Pango::AttrList::operator bool | ( |  | ) | const
| explicit

Tests whether the AttrList is valid.

## ◆ operator=() [1/2]

AttrList & Pango::AttrList::operator= | ( | AttrList && | other | ) |
| noexcept

## ◆ operator=() [2/2]

AttrList & Pango::AttrList::operator= | ( | const AttrList & | other | ) |

## ◆ splice()

void Pango::AttrList::splice | ( | AttrList & | other,
|  | int | pos,
|  | int | len )

This function opens up a hole in list, fills it in with attributes from the left, and then merges other on top of the hole.

This operation is equivalent to stretching every attribute that applies at position pos in list by an amount len, and then calling change() with a copy of each attribute in other in sequence (offset in position by pos, and limited in length to len).

This operation proves useful for, for instance, inserting a pre-edit string in the middle of an edit buffer.

For backwards compatibility, the function behaves differently when len is 0. In this case, the attributes from other are not imited to len, and are just overlayed on top of list.

This mode is useful for merging two lists of attributes together.

Parameters

  other | Another Pango::AttrList.
  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).

## ◆ swap()

void Pango::AttrList::swap | ( | AttrList & | other | ) |
| noexcept

## ◆ to_string()

Glib::ustring Pango::AttrList::to_string | ( |  | ) | const

Serializes a Pango::AttrList to a string.

In the resulting string, serialized attributes are separated by newlines or commas. Individual attributes are serialized to a string of the form

[START END] TYPE VALUE

Where START and END are the indices (with -1 being accepted in place of MAXUINT), TYPE is the nickname of the attribute value type, e.g. weight or stretch, and the value is serialized according to its type:

Optionally, START and END can be omitted to indicate unlimited extent.

- enum values as nick or numeric value
- boolean values as true or false
- integers and floats as numbers
- strings as string, optionally quoted
- font features as quoted string
- PangoLanguage as string
- PangoFontDescription as serialized by Pango::FontDescription::to_string(), quoted
- PangoColor as serialized by Pango::Color::to_string()

Examples:

0 10 foreground red, 5 15 weight bold, 0 200 font-desc "Sans 10"

0 -1 weight 700 0 100 family Times

weight bold

To parse the returned value, use from_string().

Note that shape attributes can not be serialized.

Since pangomm 2.50

Returns
  A newly allocated string.

## ◆ update()

void Pango::AttrList::update | ( | int | pos,
|  | int | remove,
|  | int | add )

Update indices of attributes in list for a change in the text they refer to.

The change that this function applies is removing remove bytes at position pos and inserting add bytes instead.

Attributes that fall entirely in the ( pos, pos + remove) range are removed.

Attributes that start or end inside the ( pos, pos + remove) range are shortened to reflect the removal.

Attributes start and end positions are updated if they are behind pos + remove.

Since pangomm 2.50

Parameters

  pos | The position of the change.
  remove | The number of removed bytes.
  add | The number of added bytes.

## Friends And Related Symbol Documentation

## ◆ swap()

void swap | ( | AttrList & | lhs,
|  | AttrList & | rhs )
| related

Parameters

  lhs | The left-hand side
  rhs | The right-hand side

## ◆ wrap()

Pango::AttrList wrap | ( | PangoAttrList * | object,
|  | bool | take_copy = false )
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.

## Member Data Documentation

## ◆ gobject_

PangoAttrList* Pango::AttrList::gobject_
| protected