Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: PangoAttrList

[19:7] extends: object

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 single PangoAttrList for more than one paragraph of text.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • PangoAttrList (Handle = null)

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

    • @p Handle is an optional native handle or wrapper whose handle to adopt; when the native constructor is called.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • change (object attr)

    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.

    • @p attr is the attribute to insert.
    • @r None.
  • copy ()

    Copy @list and return an identical new list.

    • @r the newly allocated PangoAttrList, with a reference count of one, which should be freed with [method@Pango.AttrList.unref]. Returns %NULL if @list was %NULL..
  • equal (object other_list)

    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.

    • @p other_list is the other PangoAttrList.
    • @r %TRUE if the lists are equal, %FALSE if they aren't.
  • filter (data)

    Given a PangoAttrList and callback function, removes any elements of

    • @list for which @func returns %TRUE and inserts them into a new list.
    • @p func is callback function; returns %TRUE if an attribute should be filtered out.
    • @p data is Data to be passed to @func.
    • @r the new PangoAttrList or %NULL if no attributes of the given types were found.
  • get_attributes ()

    Gets a list of all attributes in @list.

    • @r a list of all attributes in @list. To free this value, call [method@Pango.Attribute.destroy] on each value and g_slist_free() on the list..
  • get_iterator ()

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

    • @r the newly allocated PangoAttrIterator, which should be freed with [method@Pango.AttrIterator.destroy].
  • insert (object attr)

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

    • @p attr is the attribute to insert.
    • @r None.
  • insert_before (object attr)

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

    • @p attr is the attribute to insert.
    • @r None.
  • ref ()

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

    • @r The attribute list passed in.
  • splice (object 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 [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 @list. This mode is useful for merging two lists of attributes together.
    • @p other is another PangoAttrList.
    • @p pos is the position in @list at which to insert @other.
    • @p len is 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).
    • @r None.
  • to_string ()

    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: 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 [method@Pango.FontDescription.to_string], quoted - PangoColor 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 weight bold To parse the returned value, use [func@Pango.AttrList.from_string]. Note that shape attributes can not be serialized.

    • @r a newly allocated string.
  • unref ()

    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.

    • @r None.
  • 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.

    • @p pos is the position of the change.
    • @p remove is the number of removed bytes.
    • @p add is the number of added bytes.
    • @r None.
  • attributes ()

    Returns get_attributes as an Aussom list of wrapper objects. This companion method materializes the full collection up front; use get_attributes() when lazy or change-notify access is required.

    • @r An Aussom list of elements.