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
PangoAttrList
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
attr_list_ptr
Default implementationTyped 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)
-
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
list
and return an identical new list.Declaration
Swift
@inlinable func copy() -> Pango.AttrListRef!
-
equal(otherList:
Extension method) Checks whether
list
andother_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:
Extension methoddata: ) Given a
PangoAttrList
and callback function, removes any elements oflist
for whichfunc
returnstrue
and 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.
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 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 mergesother
on top of the hole.This operation is equivalent to stretching every attribute that applies at position
pos
inlist
by an amountlen
, and then calling [methodPango.AttrList.change
] with a copy of each attribute inother
in 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
len
is 0. In this case, the attributes fromother
are 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
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 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
list
for a change in the text they refer to.The change that this function applies is removing
remove
bytes at positionpos
and insertingadd
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)
-
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
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 overattrs
currently positioned at a range before or containingstart_index
;cached_iter
will 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
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 overattrs
currently positioned at a range before or containingstart_index
;cached_iter
will 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
-
attributes
Extension methodGets a list of all attributes in
list
.Declaration
Swift
@inlinable var attributes: GLib.SListRef! { get }
-
iterator
Extension methodCreate 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 }