StyledTextDocument

class StyledTextDocument(initialText: String) : TextDocument

Constructors

Link copied to clipboard
constructor(initialText: String)

Properties

Link copied to clipboard
override val history: History
Link copied to clipboard

The text is held as an array of lines. This makes editing the text much more efficient than using one huge String (with new-line characters). New line characters are NOT included in the list elements.

Link copied to clipboard

The highlighted ranges. This is publicly mutable, which means you can add/remove highlights without going through the history mechanism. (e.g. to add highlights text which matches a search).

Link copied to clipboard
Link copied to clipboard

TextDocument does NOT store the document as a String, it is stored as a list of strings where each item in the list does NOT contain a new line character.

Functions

Link copied to clipboard
Link copied to clipboard

Returns a StyledTextChange which adds a range on redo, and removes it again on undo.

Link copied to clipboard
Link copied to clipboard
fun append(toAppend: String)
Link copied to clipboard
fun clear()
Link copied to clipboard

Returns a TextChange object, but does not apply that change. Useful for batching multiple changes together so that undo/redo treats them as a single step.

Link copied to clipboard
fun delete(from: TextPosition, to: TextPosition, allowMerge: Boolean = false)
Link copied to clipboard

Returns a TextChange object, but does not apply that change. Useful for batching multiple changes together so that undo/redo treats them as a single step.

Link copied to clipboard
Link copied to clipboard
open override fun fireChange(change: Change, isUndo: Boolean)
Link copied to clipboard
fun insert(from: TextPosition, toInsert: String, allowMerge: Boolean = false)
fun insert(from: TextPosition, toInsert: List<String>, allowMerge: Boolean = false)
Link copied to clipboard
fun insertChange(from: TextPosition, toInsert: String, allowMerge: Boolean): InsertText?
fun insertChange(from: TextPosition, toInsert: List<String>, allowMerge: Boolean): InsertText?

Returns a TextChange object, but does not apply that change. Useful for batching multiple changes together so that undo/redo treats them as a single step.

Link copied to clipboard
Link copied to clipboard
open override fun removeListener(listener: DocumentListener)
Link copied to clipboard

Returns a StyledTextChange which remove a range on redo, and adds it again on undo.

Link copied to clipboard
Link copied to clipboard
fun setText(text: String)
Link copied to clipboard
Link copied to clipboard

If pos is a valid TextPosition for this document, it is returned (unchanged). Otherwise, a new TextPosition is returned, which is valid. The row is in the range :