AttrListProtocol

public protocol AttrListProtocol

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 [methodPango.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.

The AttrListProtocol protocol exposes the methods and properties of an underlying PangoAttrList instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see AttrList. Alternatively, use AttrListRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying PangoAttrList instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • attr_list_ptr Default implementation

    Typed pointer to the underlying PangoAttrList instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the PangoAttrList instance.

    Declaration

    Swift

    var attr_list_ptr: UnsafeMutablePointer<PangoAttrList>! { get }
  • Required Initialiser for types conforming to AttrListProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

AttrList Record: AttrListProtocol extension (methods and fields)

  • change(attr:) Extension method

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

    Declaration

    Swift

    @inlinable
    func change<AttributeT>(attr: AttributeT) where AttributeT : AttributeProtocol
  • copy() Extension method

    Copy list and return an identical new list.

    Declaration

    Swift

    @inlinable
    func copy() -> Pango.AttrListRef!
  • equal(otherList:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func equal<AttrListT>(otherList: AttrListT) -> Bool where AttrListT : AttrListProtocol
  • filter(func:data:) Extension method

    Given a PangoAttrList and callback function, removes any elements of list for which func returns true and inserts them into a new list.

    Declaration

    Swift

    @inlinable
    func filter(func: PangoAttrFilterFunc?, data: gpointer? = nil) -> Pango.AttrListRef!
  • getAttributes() Extension method

    Gets a list of all attributes in list.

    Declaration

    Swift

    @inlinable
    func getAttributes() -> GLib.SListRef!
  • getIterator() Extension method

    Create a iterator initialized to the beginning of the list.

    list must not be modified until this iterator is freed.

    Declaration

    Swift

    @inlinable
    func getIterator() -> Pango.AttrIteratorRef!
  • insert(attr:) Extension method

    Insert the given attribute into the PangoAttrList.

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

    Declaration

    Swift

    @inlinable
    func insert<AttributeT>(attr: AttributeT) where AttributeT : AttributeProtocol
  • insertBefore(attr:) Extension method

    Insert the given attribute into the PangoAttrList.

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

    Declaration

    Swift

    @inlinable
    func insertBefore<AttributeT>(attr: AttributeT) where AttributeT : AttributeProtocol
  • ref() Extension method

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

    Declaration

    Swift

    @discardableResult
    @inlinable
    func ref() -> Pango.AttrListRef!
  • splice(other:pos:len:) Extension method

    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 [methodPango.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.

    Declaration

    Swift

    @inlinable
    func splice<AttrListT>(other: AttrListT, pos: Int, len: Int) where AttrListT : AttrListProtocol
  • toString() Extension method

    Serializes a PangoAttrList to a string.

    No guarantees are made about the format of the string, it may change between Pango versions.

    The intended use of this function is testing and debugging. The format is not meant as a permanent storage format.

    Declaration

    Swift

    @inlinable
    func toString() -> String!
  • unref() Extension method

    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.

    Declaration

    Swift

    @inlinable
    func unref()
  • update(pos:remove:add:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func update(pos: Int, remove: Int, add: Int)
  • Apply customization from attributes to the breaks in attrs.

    The line breaks are assumed to have been produced by [funcPango.default_break] and [funcPango.tailor_break].

    Declaration

    Swift

    @inlinable
    func attrBreak(text: UnsafePointer<CChar>!, length: Int, offset: Int, attrs: UnsafeMutablePointer<PangoLogAttr>!, attrsLen: Int)
  • Breaks a piece of text into segments with consistent directional level and font.

    Each byte of text will be contained in exactly one of the items in the returned list; the generated list of items will be in logical order (the start offsets of the items are ascending).

    cached_iter should be an iterator over attrs currently positioned at a range before or containing start_index; cached_iter will be advanced to the range covering the position just after start_index + length. (i.e. if itemizing in a loop, just keep passing in the same cached_iter).

    Declaration

    Swift

    @inlinable
    func itemize<ContextT>(context: ContextT, text: UnsafePointer<CChar>!, startIndex: Int, length: Int, cachedIter: AttrIteratorRef? = nil) -> GLib.ListRef! where ContextT : ContextProtocol
  • Breaks a piece of text into segments with consistent directional level and font.

    Each byte of text will be contained in exactly one of the items in the returned list; the generated list of items will be in logical order (the start offsets of the items are ascending).

    cached_iter should be an iterator over attrs currently positioned at a range before or containing start_index; cached_iter will be advanced to the range covering the position just after start_index + length. (i.e. if itemizing in a loop, just keep passing in the same cached_iter).

    Declaration

    Swift

    @inlinable
    func itemize<AttrIteratorT, ContextT>(context: ContextT, text: UnsafePointer<CChar>!, startIndex: Int, length: Int, cachedIter: AttrIteratorT?) -> GLib.ListRef! where AttrIteratorT : AttrIteratorProtocol, ContextT : ContextProtocol
  • Like pango_itemize(), but with an explicitly specified base direction.

    The base direction is used when computing bidirectional levels. [funcitemize] gets the base direction from the PangoContext (see [methodPango.Context.set_base_dir]).

    Declaration

    Swift

    @inlinable
    func itemizeWithBaseDir<ContextT>(context: ContextT, baseDir: PangoDirection, text: UnsafePointer<CChar>!, startIndex: Int, length: Int, cachedIter: AttrIteratorRef? = nil) -> GLib.ListRef! where ContextT : ContextProtocol
  • Like pango_itemize(), but with an explicitly specified base direction.

    The base direction is used when computing bidirectional levels. [funcitemize] gets the base direction from the PangoContext (see [methodPango.Context.set_base_dir]).

    Declaration

    Swift

    @inlinable
    func itemizeWithBaseDir<AttrIteratorT, ContextT>(context: ContextT, baseDir: PangoDirection, text: UnsafePointer<CChar>!, startIndex: Int, length: Int, cachedIter: AttrIteratorT?) -> GLib.ListRef! where AttrIteratorT : AttrIteratorProtocol, ContextT : ContextProtocol
  • attributes Extension method

    Gets a list of all attributes in list.

    Declaration

    Swift

    @inlinable
    var attributes: GLib.SListRef! { get }
  • iterator Extension method

    Create a iterator initialized to the beginning of the list.

    list must not be modified until this iterator is freed.

    Declaration

    Swift

    @inlinable
    var iterator: Pango.AttrIteratorRef! { get }