TextProtocol
public protocol TextProtocol
AtkText should be implemented by AtkObjects on behalf of widgets
that have text content which is either attributed or otherwise
non-trivial. AtkObjects whose text content is simple,
unattributed, and very brief may expose that content via
atk_object_get_name instead; however if the text is editable,
multi-line, typically longer than three or four words, attributed,
selectable, or if the object already uses the ‘name’ ATK property
for other information, the AtkText interface should be used to
expose the text content. In the case of editable text content,
AtkEditableText (a subtype of the AtkText interface) should be
implemented instead.
AtkText provides not only traversal facilities and change
notification for text content, but also caret tracking and glyph
bounding box calculations. Note that the text strings are exposed
as UTF-8, and are therefore potentially multi-byte, and
caret-to-byte offset mapping makes no assumptions about the
character length; also bounding box glyph-to-offset mapping may be
complex for languages which use ligatures.
The TextProtocol protocol exposes the methods and properties of an underlying AtkText 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 Text.
Alternatively, use TextRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
AtkTextinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
text_ptrDefault implementationTyped pointer to the underlying
AtkTextinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
AtkTextinstance.Declaration
Swift
var text_ptr: UnsafeMutablePointer<AtkText>! { get } -
Required Initialiser for types conforming to
TextProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
TextSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: TextSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
TextSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: TextSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onTextAttributesChanged(flags:Extension methodhandler: ) The “text-attributes-changed” signal is emitted when the text attributes of the text of an object which implements AtkText changes.
Note
This represents the underlyingtext-attributes-changedsignalDeclaration
Swift
@discardableResult @inlinable func onTextAttributesChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TextRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
textAttributesChangedsignal is emitted -
textAttributesChangedSignalExtension methodTyped
text-attributes-changedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var textAttributesChangedSignal: TextSignalName { get } -
onTextCaretMoved(flags:Extension methodhandler: ) The “text-caret-moved” signal is emitted when the caret position of the text of an object which implements AtkText changes.
Note
This represents the underlyingtext-caret-movedsignalDeclaration
Swift
@discardableResult @inlinable func onTextCaretMoved(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TextRef, _ arg1: Int) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
arg1The new position of the text caret.
handlerThe signal handler to call Run the given callback whenever the
textCaretMovedsignal is emitted -
textCaretMovedSignalExtension methodTyped
text-caret-movedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var textCaretMovedSignal: TextSignalName { get } -
onTextChanged(flags:Extension methodhandler: ) The “text-changed” signal is emitted when the text of the object which implements the AtkText interface changes, This signal will have a detail which is either “insert” or “delete” which identifies whether the text change was an insertion or a deletion.
Note
This represents the underlyingtext-changedsignalDeclaration
Swift
@discardableResult @inlinable func onTextChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TextRef, _ arg1: Int, _ arg2: Int) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
arg1The position (character offset) of the insertion or deletion.
arg2The length (in characters) of text inserted or deleted.
handlerThe signal handler to call Run the given callback whenever the
textChangedsignal is emitted -
textChangedSignalExtension methodTyped
text-changedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var textChangedSignal: TextSignalName { get } -
onTextInsert(flags:Extension methodhandler: ) The “text-insert” signal is emitted when a new text is inserted. If the signal was not triggered by the user (e.g. typing or pasting text), the “system” detail should be included.
Note
This represents the underlyingtext-insertsignalDeclaration
Swift
@discardableResult @inlinable func onTextInsert(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TextRef, _ arg1: Int, _ arg2: Int, _ arg3: String) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
arg1The position (character offset) of the insertion.
arg2The length (in characters) of text inserted.
arg3The new text inserted
handlerThe signal handler to call Run the given callback whenever the
textInsertsignal is emitted -
textInsertSignalExtension methodTyped
text-insertsignal for using theconnect(signal:)methodsDeclaration
Swift
static var textInsertSignal: TextSignalName { get } -
onTextRemove(flags:Extension methodhandler: ) The “text-remove” signal is emitted when a new text is removed. If the signal was not triggered by the user (e.g. typing or pasting text), the “system” detail should be included.
Note
This represents the underlyingtext-removesignalDeclaration
Swift
@discardableResult @inlinable func onTextRemove(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TextRef, _ arg1: Int, _ arg2: Int, _ arg3: String) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
arg1The position (character offset) of the removal.
arg2The length (in characters) of text removed.
arg3The old text removed
handlerThe signal handler to call Run the given callback whenever the
textRemovesignal is emitted -
textRemoveSignalExtension methodTyped
text-removesignal for using theconnect(signal:)methodsDeclaration
Swift
static var textRemoveSignal: TextSignalName { get } -
onTextSelectionChanged(flags:Extension methodhandler: ) The “text-selection-changed” signal is emitted when the selected text of an object which implements AtkText changes.
Note
This represents the underlyingtext-selection-changedsignalDeclaration
Swift
@discardableResult @inlinable func onTextSelectionChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: TextRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
textSelectionChangedsignal is emitted -
textSelectionChangedSignalExtension methodTyped
text-selection-changedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var textSelectionChangedSignal: TextSignalName { get }
-
addSelection(startOffset:Extension methodendOffset: ) Adds a selection bounded by the specified offsets.
Declaration
Swift
@inlinable func addSelection(startOffset: Int, endOffset: Int) -> Bool -
getBoundedRanges(rect:Extension methodcoordType: xClipType: yClipType: ) Get the ranges of text in the specified bounding box.
Declaration
Swift
@inlinable func getBoundedRanges<TextRectangleT>(rect: TextRectangleT, coordType: AtkCoordType, xClipType: AtkTextClipType, yClipType: AtkTextClipType) -> UnsafeMutablePointer<UnsafeMutablePointer<AtkTextRange>?>! where TextRectangleT : TextRectangleProtocol -
getCaretOffset()Extension methodGets the offset of the position of the caret (cursor).
Declaration
Swift
@inlinable func getCaretOffset() -> Int -
getCharacterAt(offset:Extension method) Gets the specified text.
Declaration
Swift
@inlinable func getCharacterAt(offset: Int) -> gunichar -
getCharacterCount()Extension methodGets the character count.
Declaration
Swift
@inlinable func getCharacterCount() -> Int -
getCharacterExtents(offset:Extension methodx: y: width: height: coords: ) If the extent can not be obtained (e.g. missing support), all of x, y, width, height are set to -1.
Get the bounding box containing the glyph representing the character at a particular text offset.
Declaration
Swift
@inlinable func getCharacterExtents(offset: Int, x: UnsafeMutablePointer<gint>! = nil, y: UnsafeMutablePointer<gint>! = nil, width: UnsafeMutablePointer<gint>! = nil, height: UnsafeMutablePointer<gint>! = nil, coords: AtkCoordType) -
getDefaultAttributes()Extension methodCreates an
AtkAttributeSetwhich consists of the default values of attributes for the text. See the enum AtkTextAttribute for types of text attributes that can be returned. Note that other attributes may also be returned.Declaration
Swift
@inlinable func getDefaultAttributes() -> UnsafeMutablePointer<AtkAttributeSet>! -
getNSelections()Extension methodGets the number of selected regions.
Declaration
Swift
@inlinable func getNSelections() -> Int -
getOffsetAtPoint(x:Extension methody: coords: ) Gets the offset of the character located at coordinates
xandy.xandyare interpreted as being relative to the screen or this widget’s window depending oncoords.Declaration
Swift
@inlinable func getOffsetAtPoint(x: Int, y: Int, coords: AtkCoordType) -> Int -
getRangeExtents(startOffset:Extension methodendOffset: coordType: rect: ) Get the bounding box for text within the specified range.
If the extents can not be obtained (e.g. or missing support), the rectangle fields are set to -1.
Declaration
Swift
@inlinable func getRangeExtents<TextRectangleT>(startOffset: Int, endOffset: Int, coordType: AtkCoordType, rect: TextRectangleT) where TextRectangleT : TextRectangleProtocol -
getRunAttributes(offset:Extension methodstartOffset: endOffset: ) Creates an
AtkAttributeSetwhich consists of the attributes explicitly set at the positionoffsetin the text.start_offsetandend_offsetare set to the start and end of the range aroundoffsetwhere the attributes are invariant. Note thatend_offsetis the offset of the first character after the range. See the enum AtkTextAttribute for types of text attributes that can be returned. Note that other attributes may also be returned.Declaration
Swift
@inlinable func getRunAttributes(offset: Int, startOffset: UnsafeMutablePointer<gint>!, endOffset: UnsafeMutablePointer<gint>!) -> UnsafeMutablePointer<AtkAttributeSet>! -
getSelection(selectionNum:Extension methodstartOffset: endOffset: ) Gets the text from the specified selection.
Declaration
Swift
@inlinable func getSelection(selectionNum: Int, startOffset: UnsafeMutablePointer<gint>!, endOffset: UnsafeMutablePointer<gint>!) -> String! -
getStringAt(offset:Extension methodgranularity: startOffset: endOffset: ) Gets a portion of the text exposed through an
AtkTextaccording to a givenoffsetand a specificgranularity, along with the start and end offsets defining the boundaries of such a portion of text.If
granularityis ATK_TEXT_GRANULARITY_CHAR the character at the offset is returned.If
granularityis ATK_TEXT_GRANULARITY_WORD the returned string is from the word start at or before the offset to the word start after the offset.The returned string will contain the word at the offset if the offset is inside a word and will contain the word before the offset if the offset is not inside a word.
If
granularityis ATK_TEXT_GRANULARITY_SENTENCE the returned string is from the sentence start at or before the offset to the sentence start after the offset.The returned string will contain the sentence at the offset if the offset is inside a sentence and will contain the sentence before the offset if the offset is not inside a sentence.
If
granularityis ATK_TEXT_GRANULARITY_LINE the returned string is from the line start at or before the offset to the line start after the offset.If
granularityis ATK_TEXT_GRANULARITY_PARAGRAPH the returned string is from the start of the paragraph at or before the offset to the start of the following paragraph after the offset.Declaration
Swift
@inlinable func getStringAt(offset: Int, granularity: AtkTextGranularity, startOffset: UnsafeMutablePointer<gint>!, endOffset: UnsafeMutablePointer<gint>!) -> String! -
getText(startOffset:Extension methodendOffset: ) Gets the specified text.
Declaration
Swift
@inlinable func getText(startOffset: Int, endOffset: Int) -> String! -
getTextAfter(offset:Extension methodboundaryType: startOffset: endOffset: ) Gets the specified text.
get_text_after_offset is deprecated: Please use atk_text_get_string_at_offset() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getTextAfter(offset: Int, boundaryType: AtkTextBoundary, startOffset: UnsafeMutablePointer<gint>!, endOffset: UnsafeMutablePointer<gint>!) -> String! -
getTextAt(offset:Extension methodboundaryType: startOffset: endOffset: ) Gets the specified text.
If the boundary_type if ATK_TEXT_BOUNDARY_CHAR the character at the offset is returned.
If the boundary_type is ATK_TEXT_BOUNDARY_WORD_START the returned string is from the word start at or before the offset to the word start after the offset.
The returned string will contain the word at the offset if the offset is inside a word and will contain the word before the offset if the offset is not inside a word.
If the boundary type is ATK_TEXT_BOUNDARY_SENTENCE_START the returned string is from the sentence start at or before the offset to the sentence start after the offset.
The returned string will contain the sentence at the offset if the offset is inside a sentence and will contain the sentence before the offset if the offset is not inside a sentence.
If the boundary type is ATK_TEXT_BOUNDARY_LINE_START the returned string is from the line start at or before the offset to the line start after the offset.
get_text_at_offset is deprecated: This method is deprecated since ATK version 2.9.4. Please use atk_text_get_string_at_offset() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getTextAt(offset: Int, boundaryType: AtkTextBoundary, startOffset: UnsafeMutablePointer<gint>!, endOffset: UnsafeMutablePointer<gint>!) -> String! -
getTextBefore(offset:Extension methodboundaryType: startOffset: endOffset: ) Gets the specified text.
get_text_before_offset is deprecated: Please use atk_text_get_string_at_offset() instead.
Declaration
Swift
@available(*, deprecated) @inlinable func getTextBefore(offset: Int, boundaryType: AtkTextBoundary, startOffset: UnsafeMutablePointer<gint>!, endOffset: UnsafeMutablePointer<gint>!) -> String! -
removeSelection(selectionNum:Extension method) Removes the specified selection.
Declaration
Swift
@inlinable func removeSelection(selectionNum: Int) -> Bool -
scrollSubstringTo(startOffset:Extension methodendOffset: type: ) Makes a substring of
textvisible on the screen by scrolling all necessary parents.Declaration
Swift
@inlinable func scrollSubstringTo(startOffset: Int, endOffset: Int, type: AtkScrollType) -> Bool -
scrollSubstringToPoint(startOffset:Extension methodendOffset: coords: x: y: ) Move the top-left of a substring of
textto a given position of the screen by scrolling all necessary parents.Declaration
Swift
@inlinable func scrollSubstringToPoint(startOffset: Int, endOffset: Int, coords: AtkCoordType, x: Int, y: Int) -> Bool -
setCaret(offset:Extension method) Sets the caret (cursor) position to the specified
offset.In the case of rich-text content, this method should either grab focus or move the sequential focus navigation starting point (if the application supports this concept) as if the user had clicked on the new caret position. Typically, this means that the target of this operation is the node containing the new caret position or one of its ancestors. In other words, after this method is called, if the user advances focus, it should move to the first focusable node following the new caret position.
Calling this method should also scroll the application viewport in a way that matches the behavior of the application’s typical caret motion or tab navigation as closely as possible. This also means that if the application’s caret motion or focus navigation does not trigger a scroll operation, this method should not trigger one either. If the application does not have a caret motion or focus navigation operation, this method should try to scroll the new caret position into view while minimizing unnecessary scroll motion.
Declaration
Swift
@inlinable func setCaret(offset: Int) -> Bool -
setSelection(selectionNum:Extension methodstartOffset: endOffset: ) Changes the start and end offset of the specified selection.
Declaration
Swift
@inlinable func setSelection(selectionNum: Int, startOffset: Int, endOffset: Int) -> Bool -
caretOffsetExtension methodGets the offset of the position of the caret (cursor).
Declaration
Swift
@inlinable var caretOffset: Int { get nonmutating set } -
characterCountExtension methodGets the character count.
Declaration
Swift
@inlinable var characterCount: Int { get } -
defaultAttributesExtension methodCreates an
AtkAttributeSetwhich consists of the default values of attributes for the text. See the enum AtkTextAttribute for types of text attributes that can be returned. Note that other attributes may also be returned.Declaration
Swift
@inlinable var defaultAttributes: UnsafeMutablePointer<AtkAttributeSet>! { get } -
nSelectionsExtension methodGets the number of selected regions.
Declaration
Swift
@inlinable var nSelections: Int { get }
View on GitHub
Install in Dash
TextProtocol Protocol Reference