Pango.AttrList¶
Fields¶
None
Methods¶
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Pango.AttrList¶
A
PangoAttrList
represents a list of attributes that apply to a section of text.The attributes in a
PangoAttrList
are, in general, allowed to overlap in an arbitrary fashion. However, if the attributes are manipulated only through [method`Pango`.AttrList.change], the overlap between properties will meet stricter criteria.Since the
PangoAttrList
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 singlePangoAttrList
for more than one paragraph of text.- classmethod from_string(text)[source]¶
- Parameters:
text (
str
) – a string- Returns:
a new
PangoAttrList
- Return type:
Deserializes a
PangoAttrList
from a string.This is the counterpart to [method`Pango`.AttrList.to_string]. See that functions for details about the format.
New in version 1.50.
- classmethod new()[source]¶
- Returns:
the newly allocated
PangoAttrList
, which should be freed with [method`Pango`.AttrList.unref]- Return type:
Create a new empty attribute list with a reference count of one.
- change(attr)[source]¶
- Parameters:
attr (
Pango.Attribute
) – the attribute to insert
Insert the given attribute into the
PangoAttrList
.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 [method`Pango`.AttrList.insert] for creating an attribute list in order (potentially much slower for large lists). However, [method`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
PangoAttrList
, with a reference count of one, which should be freed with [method`Pango`.AttrList.unref]. ReturnsNone
if self wasNone
.- Return type:
Copy self and return an identical new list.
- equal(other_list)[source]¶
- Parameters:
other_list (
Pango.AttrList
) – the otherPangoAttrList
- Returns:
- Return type:
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:
func (
Pango.AttrFilterFunc
) – callback function; returnsTrue
if an attribute should be filtered out
- Returns:
the new
PangoAttrList
orNone
if no attributes of the given types were found- Return type:
Given a
PangoAttrList
and callback function, removes any elements of self for which func returnsTrue
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 [method`Pango`.Attribute.destroy] on each value and g_slist_free() on the list.
- Return type:
Gets a list of all attributes in self.
New in version 1.44.
- get_iterator()[source]¶
- Returns:
the newly allocated
PangoAttrIterator
, which should be freed with [method`Pango`.AttrIterator.destroy]- Return type:
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
Insert the given attribute into the
PangoAttrList
.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
Insert the given attribute into the
PangoAttrList
.It will be inserted before all other attributes with a matching start_index.
- ref()[source]¶
- Returns:
The attribute list passed in
- Return type:
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
) – anotherPangoAttrList
pos (
int
) – the position in self at which to insert otherlen (
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 [method`Pango`.AttrList.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 self.
This mode is useful for merging two lists of attributes together.
- to_string()[source]¶
- Returns:
a newly allocated string
- Return type:
Serializes a
PangoAttrList
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:
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
Pango.Language
as stringPango.FontDescription
as serialized by [method`Pango`.FontDescription.to_string], quotedPango.Color
as serialized by [method`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 ``
To parse the returned value, use [func`Pango`.AttrList.from_string].
Note that shape attributes can not be serialized.
New in version 1.50.
- 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:
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.