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.
-
Untyped pointer to the underlying
PangoAttrListinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
attr_list_ptrDefault implementationTyped pointer to the underlying
PangoAttrListinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
PangoAttrListinstance.Declaration
Swift
var attr_list_ptr: UnsafeMutablePointer<PangoAttrList>! { get } -
Required Initialiser for types conforming to
AttrListProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
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 [method
Pango.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 methodCopy
listand return an identical new list.Declaration
Swift
@inlinable func copy() -> Pango.AttrListRef! -
equal(otherList:Extension method) Checks whether
listandother_listcontain 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:Extension methoddata: ) Given a
PangoAttrListand callback function, removes any elements oflistfor whichfuncreturnstrueand inserts them into a new list.Declaration
Swift
@inlinable func filter(func: PangoAttrFilterFunc?, data: gpointer? = nil) -> Pango.AttrListRef! -
getAttributes()Extension methodGets a list of all attributes in
list.Declaration
Swift
@inlinable func getAttributes() -> GLib.SListRef! -
getIterator()Extension methodCreate a iterator initialized to the beginning of the list.
listmust 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 methodIncrease the reference count of the given attribute list by one.
Declaration
Swift
@discardableResult @inlinable func ref() -> Pango.AttrListRef! -
splice(other:Extension methodpos: len: ) This function opens up a hole in
list, fills it in with attributes from the left, and then mergesotheron top of the hole.This operation is equivalent to stretching every attribute that applies at position
posinlistby an amountlen, and then calling [methodPango.AttrList.change] with a copy of each attribute inotherin sequence (offset in position bypos, and limited in length tolen).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
lenis 0. In this case, the attributes fromotherare not imited tolen, and are just overlayed on top oflist.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 methodSerializes a
PangoAttrListto 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 methodDecrease 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:Extension methodremove: add: ) Update indices of attributes in
listfor a change in the text they refer to.The change that this function applies is removing
removebytes at positionposand insertingaddbytes 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) -
attrBreak(text:Extension methodlength: offset: attrs: attrsLen: ) Apply customization from attributes to the breaks in
attrs.The line breaks are assumed to have been produced by [func
Pango.default_break] and [funcPango.tailor_break].Declaration
Swift
@inlinable func attrBreak(text: UnsafePointer<CChar>!, length: Int, offset: Int, attrs: UnsafeMutablePointer<PangoLogAttr>!, attrsLen: Int) -
itemize(context:Extension methodtext: startIndex: length: cachedIter: ) Breaks a piece of text into segments with consistent directional level and font.
Each byte of
textwill 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_itershould be an iterator overattrscurrently positioned at a range before or containingstart_index;cached_iterwill be advanced to the range covering the position just afterstart_index+length. (i.e. if itemizing in a loop, just keep passing in the samecached_iter).Declaration
Swift
@inlinable func itemize<ContextT>(context: ContextT, text: UnsafePointer<CChar>!, startIndex: Int, length: Int, cachedIter: AttrIteratorRef? = nil) -> GLib.ListRef! where ContextT : ContextProtocol -
itemize(context:Extension methodtext: startIndex: length: cachedIter: ) Breaks a piece of text into segments with consistent directional level and font.
Each byte of
textwill 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_itershould be an iterator overattrscurrently positioned at a range before or containingstart_index;cached_iterwill be advanced to the range covering the position just afterstart_index+length. (i.e. if itemizing in a loop, just keep passing in the samecached_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. [func
itemize] gets the base direction from thePangoContext(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. [func
itemize] gets the base direction from thePangoContext(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 -
attributesExtension methodGets a list of all attributes in
list.Declaration
Swift
@inlinable var attributes: GLib.SListRef! { get } -
iteratorExtension methodCreate a iterator initialized to the beginning of the list.
listmust not be modified until this iterator is freed.Declaration
Swift
@inlinable var iterator: Pango.AttrIteratorRef! { get }
View on GitHub
Install in Dash
AttrListProtocol Protocol Reference