Pango.AttrList

Fields

None

Methods

class new ()
  change (attr)
  copy ()
  equal (other_list)
  filter (func, *data)
  get_attributes ()
  get_iterator ()
  insert (attr)
  insert_before (attr)
  ref ()
  splice (other, pos, len)
  unref ()
  update (pos, remove, add)

Details

class Pango.AttrList

The Pango.AttrList structure 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.

classmethod new()[source]
Returns:the newly allocated Pango.AttrList, which should be freed with Pango.AttrList.unref().
Return type:Pango.AttrList

Create a new empty attribute list with a reference count of one.

change(attr)[source]
Parameters:attr (Pango.Attribute) – the attribute to insert. Ownership of this value is assumed by the list.

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 Pango.AttrList.insert() for creating an attribute list in order (potentially much slower for large lists). However, Pango.AttrList.insert() is not suitable for continually changing a set of attributes since it never removes or combines existing attributes.

copy()[source]
Returns:the newly allocated Pango.AttrList, with a reference count of one, which should be freed with Pango.AttrList.unref(). Returns None if self was None.
Return type:Pango.AttrList or None

Copy self and return an identical new list.

equal(other_list)[source]
Parameters:other_list (Pango.AttrList) – the other Pango.AttrList
Returns:True if the lists are equal, False if they aren’t.
Return type:bool

Checks whether self 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.

New in version 1.46.

filter(func, *data)[source]
Parameters:
Returns:

the new Pango.AttrList or None if no attributes of the given types were found.

Return type:

Pango.AttrList or None

Given a Pango.AttrList and callback function, removes any elements of self for which func returns True and inserts them into a new list.

New in version 1.2.

get_attributes()[source]
Returns:a list of all attributes in self. To free this value, call Pango.Attribute.destroy() on each value and g_slist_free() on the list.
Return type:[Pango.Attribute]

Gets a list of all attributes in self.

New in version 1.44.

get_iterator()[source]
Returns:the newly allocated Pango.AttrIterator, which should be freed with Pango.AttrIterator.destroy().
Return type:Pango.AttrIterator

Create a iterator initialized to the beginning of the list. self must not be modified until this iterator is freed.

insert(attr)[source]
Parameters:attr (Pango.Attribute) – the attribute to insert. Ownership of this value is assumed by the list.

Insert the given attribute into the Pango.AttrList. It will be inserted after all other attributes with a matching start_index.

insert_before(attr)[source]
Parameters:attr (Pango.Attribute) – the attribute to insert. Ownership of this value is assumed by the list.

Insert the given attribute into the Pango.AttrList. It will be inserted before all other attributes with a matching start_index.

ref()[source]
Returns:The attribute list passed in
Return type:Pango.AttrList

Increase the reference count of the given attribute list by one.

New in version 1.10.

splice(other, pos, len)[source]
Parameters:
  • other (Pango.AttrList) – another Pango.AttrList
  • pos (int) – the position in self at which to insert other
  • len (int) – 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)

This function opens up a hole in self, 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 self by an amount len, and then calling Pango.AttrList.change() with a copy of each attribute in other in sequence (offset in position by pos).

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

unref()[source]

Decrease the reference count of the given attribute list by one. If the result is zero, free the attribute list and the attributes it contains.

update(pos, remove, add)[source]
Parameters:
  • pos (int) – the position of the change
  • remove (int) – the number of removed bytes
  • add (int) – the number of added bytes

Update indices of attributes in self 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.

New in version 1.44.