TypingContext

struct TypingContext

Type that contains the context of text. It contains the text as well as the position of the cursor.

Summary

Constructors
TypingContext(context: String)
TypingContext(context: String, cursor: UInt)
TypingContext(context: String, cursorStart: UInt, cursorEnd: UInt)
Properties
String context
The text context.
UInt cursorEnd
The position of the end of the cursor with respect to the context.
UInt cursorStart
The position of the start of the cursor with respect to the context.

Constructor

TypingContext

init(context: String)
Parameters
context: String The text context.

TypingContext

init(context: String, cursor: UInt)

Initializes the TypingContext with the cursor position.
Example: “Hello |wrld” => context=“Hello wrld”, cursor=6.

Parameters
context: String The text context.
cursor: Int The position of the cursor with respect to the ‘context’.

TypingContext

init(context: String, cursorStart: UInt, cursorEnd: UInt)

Initializes the ‘TypingContext’ allowing a selection of a substring in the text context.
Example: “Hello |wrld|” => context=“Hello wrld”, cursorStart=6, cursorEnd=10. This means that “wrld” is selected.

Parameters
context: String The text context.
cursorStart: Int The position of the start of the cursor with respect to the context.
cursorEnd: Int The position of the end of the cursor with respect to the context.

Properties

context

let context: String

The text context.

cursorEnd

let cursorEnd: UInt

The position of the end of the cursor with respect to the context. cursorEnd should always be greater than or equal to cursorStart.

cursorStart

let cursorStart: UInt

The position of the start of the cursor with respect to the context.


If something needs to be added or if you find an error in our documentation, please let us know either on our GitHub or Discord.

Last updated on August 8, 2022