Libraries.Containers.MultipleLineText Documentation

The MultipleLineText class is used to distribute text across multiple lines. This is done for both efficiency and to make certain kinds of operations easier. For example, inserting or deleting characters into very large strings of text will be much more efficient in a MultipleLineText than in the base text type.

Example Code

use Libraries.Containers.MultipleLineText

MultipleLineText multiLineText
multiLineText:Initialize("Hello world! ")

text extraText = "This is extra text."
multiLineText = multiLineText:Concatenate(extraText)

extraText = multiLineText:GetLineSeparator() + "This text is on a second line."
multiLineText = multiLineText:Concatenate(extraText)

output multiLineText:GetText()
output "The text contains " + multiLineText:GetLineCount() + " lines."

Inherits from: Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
Balance()This action will create a new MultipleLineText containing the balanced contents of this tree.
CharacterIndexFromLineIndex(integer index)This action gets the index of the first character in the line at the given line index.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Concatenate(text value)The Concatenate action creates a new MultipleLineText where the provided text is appended to the end of this tree's text.
Concatenate(Libraries.Containers.MultipleLineText textTree)The Concatenate action creates a new MultipleLineText where the provided tree is appended to the end of this tree.
Delete(integer startIndex, integer endIndex)The Delete action creates a new MultipleLineText which is a copy of this tree, then deletes all characters between the two given indices.
DisableTextWrapping()it 1 past where we want it (the last index checked
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetCharacter(integer index)This action retrieves a character at the given index from the tree.
GetDefaultLineSeparator()The GetDefaultLineSeparator action returns the default character(s) used by the MultipleLineText to signify the end of a line of text.
GetHashCode()This action gets the hash code for an object.
GetLeafSize()This action returns how many characters can be stored in each leaf of the MultipleLineText.
GetLine(integer index)
GetLineCount()
GetLineSeparator()The GetLineSeparator action returns the text which is used to designate the end of a line in the MultipleLineText.
GetLines()
GetLines(Libraries.Containers.Array<Libraries.Containers.MultipleLineText> array)
GetSize()This action returns the length of the text stored in the MultipleLineText.
GetText(integer startIndex, integer endIndex)This action returns the text between the two indices.
GetText()This action returns all of the text stored in the MultipleLineText.
GetWidth()
Initialize(text value, number leafSize)The Initialize action constructs the MultipleLineText from a starting text value.
Initialize(text value)The Initialize action constructs the MultipleLineText from a starting text value.
Insert(integer index, text value)The Insert action creates a new MultipleLineText and inserts the given text value into the tree at the provided index.
LineIndexFromCharacterIndex(integer index)This action gets the index of the line which contains the character at the given character index position in the text.
NeedsBalancing()This action returns true is the tree is imbalanced, or false if it is considered balanced.
SetLeafSize(integer size)This action sets how many characters should be stored in each leaf of the MultipleLineText.
SetLineSeparator(text separator)The SetLineSeparator action sets which character(s) should be used to signify the end of a line.

Actions Documentation

Balance()

This action will create a new MultipleLineText containing the balanced contents of this tree. This is typically handled automatically by the tree itself during other operations which return new MultipleLineTexts.

Return

Libraries.Containers.MultipleLineText: A new MultipleLineText which is balanced and contains the same text as this MultipleLineText. use Libraries.Containers.MultipleLineText MultipleLineText tree tree:Initialize("Hello world!") boolean shouldRebalance = tree:NeedsBalancing() output "shouldRebalance is " + shouldRebalance if shouldRebalance tree:Balance() end

CharacterIndexFromLineIndex(integer index)

This action gets the index of the first character in the line at the given line index.

Parameters

Return

integer:

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Example Code

Object o
        Object t
        integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Concatenate(text value)

The Concatenate action creates a new MultipleLineText where the provided text is appended to the end of this tree's text. This tree will not change as a result of this action.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree
    tree:Initialize("Hello ")

    MultipleLineText result = tree:Concatenate("world!")
    output result:GetText()

Parameters

Return

Libraries.Containers.MultipleLineText: A new MultipleLineText which contains the concatenation of this tree's text and the parameter text.

Concatenate(Libraries.Containers.MultipleLineText textTree)

The Concatenate action creates a new MultipleLineText where the provided tree is appended to the end of this tree. All text in the parameter tree will appear after the text from this tree inside the returned value. This tree will not change as a result of this action.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree1
    tree1:Initialize("Hello ")

    MultipleLineText tree2
    tree2:Initialize("world!")

    MultipleLineText result = tree1:Concatenate(tree2)
    output result:GetText()

Parameters

Return

Libraries.Containers.MultipleLineText: A new MultipleLineText which contains the concatenation of the two trees.

Delete(integer startIndex, integer endIndex)

The Delete action creates a new MultipleLineText which is a copy of this tree, then deletes all characters between the two given indices. The first index is inclusive (the character at the first index will be deleted) and the second index is exclusive (the character at the second index is not deleted). This action creates a new MultipleLineText, and has no effect on this tree.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree
    tree:Initialize("Hello world!")

    MultipleLineText deleteTree = tree:Delete(5, tree:GetSize() - 1)
    output deleteTree:GetText()

Parameters

Return

Libraries.Containers.MultipleLineText: A new MultipleLineText containing this tree's text, minus the deleted portion.

DisableTextWrapping()

it 1 past where we want it (the last index checked

Return

Libraries.Containers.MultipleLineText:

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

GetCharacter(integer index)

This action retrieves a character at the given index from the tree.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree
    tree:Initialize("Hello world!")
    text character = tree:GetCharacter(1)
    output "The character at index 1 is '" + character + "'."

Parameters

Return

text: A single character located at the given index.

GetDefaultLineSeparator()

The GetDefaultLineSeparator action returns the default character(s) used by the MultipleLineText to signify the end of a line of text. This is the same line separating characters that are used by the running operating system.

Return

text: The default characters used to indicate the end of a line of text.

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetLeafSize()

This action returns how many characters can be stored in each leaf of the MultipleLineText.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText defaultTree
    defaultTree:Initialize("Hello world! What a lovely day!")
    output "The default tree stores text in " + defaultTree:GetLeafSize() + " character chunks."

    MultipleLineText newTree
    newTree:SetLeafSize(10)
    newTree:Initialize("Hello world! What a lovely day!")
    output "The new tree stores text in " + newTree:GetLeafSize() + " character chunks."

Return

number: How many characters can be stored in each leaf.

GetLine(integer index)

Parameters

Return

Libraries.Containers.MultipleLineText:

GetLineCount()

Return

integer:

GetLineSeparator()

The GetLineSeparator action returns the text which is used to designate the end of a line in the MultipleLineText. By default, this is the same as the value used by the operating system.

Return

text: The character(s) used to designate the end of a line.

GetLines()

Return

Libraries.Containers.Array:

GetLines(Libraries.Containers.Array<Libraries.Containers.MultipleLineText> array)

Parameters

Return

Libraries.Containers.Array:

GetSize()

This action returns the length of the text stored in the MultipleLineText.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree
    tree:Initialize("Hello world!")
    output "The length of the text in the tree is " + tree:GetSize()

Return

integer: The length of text in this MultipleLineText.

GetText(integer startIndex, integer endIndex)

This action returns the text between the two indices. The first index is inclusive (the character at the first index is part of the returned text) and the second index is exclusive (the character at the second index is not part of the returned text).

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree
    tree:Initialize("Hello world!")
    output tree:GetText(1, 10)

Parameters

Return

text: The text between the two indices.

GetText()

This action returns all of the text stored in the MultipleLineText.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree
    tree:Initialize("Hello world!")
    output tree:GetText()

Return

text: The text stored in this MultipleLineText.

GetWidth()

Return

number:

Initialize(text value, number leafSize)

The Initialize action constructs the MultipleLineText from a starting text value. The MultipleLineText will store the given value, which may be retrieved or modified using the MultipleLineText's other actions. The provided integer parameter will be used to set the maximum size of each leaf, in characters.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText defaultTree
    defaultTree:Initialize("Hello world! What a lovely day!")
    output "The default tree stores text in " + defaultTree:GetLeafSize() + " character chunks."

    MultipleLineText newTree
    newTree:Initialize("Hello world! What a lovely day!", 10)
    output "The new tree stores text in " + newTree:GetLeafSize() + " character chunks."

Parameters

Initialize(text value)

The Initialize action constructs the MultipleLineText from a starting text value. The MultipleLineText will store the given value, which may be retrieved or modified using the MultipleLineText's other actions.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree
    tree:Initialize("Hello world! What a lovely day!")
    output tree:GetText()

Parameters

Insert(integer index, text value)

The Insert action creates a new MultipleLineText and inserts the given text value into the tree at the provided index. The character that was previously located at that index will be positioned behind the newly inserted text. This action creates a new MultipleLineText, and has no effect on this tree.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree
    tree:Initialize("Hello world!")

    MultipleLineText insertTree = tree:Insert(11, " of tomorrow")
    output insertTree:GetText()

Parameters

Return

Libraries.Containers.MultipleLineText: A new MultipleLineText containing the inserted text.

LineIndexFromCharacterIndex(integer index)

This action gets the index of the line which contains the character at the given character index position in the text.

Parameters

Return

integer:

NeedsBalancing()

This action returns true is the tree is imbalanced, or false if it is considered balanced. This is typically handled automatically by the tree itself.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText tree
    tree:Initialize("Hello world!")
    boolean shouldRebalance = tree:NeedsBalancing()
    output "shouldRebalance is " + shouldRebalance

    if shouldRebalance
        tree:Balance()
    end

Return

boolean: Whether or not the tree is currently imbalanced.

SetLeafSize(integer size)

This action sets how many characters should be stored in each leaf of the MultipleLineText.

Example Code

use Libraries.Containers.MultipleLineText

    MultipleLineText defaultTree
    defaultTree:Initialize("Hello world! What a lovely day!")
    output "The default tree stores text in " + defaultTree:GetLeafSize() + " character chunks."

    MultipleLineText newTree
    newTree:SetLeafSize(10)
    newTree:Initialize("Hello world! What a lovely day!")
    output "The new tree stores text in " + newTree:GetLeafSize() + " character chunks."

Parameters

SetLineSeparator(text separator)

The SetLineSeparator action sets which character(s) should be used to signify the end of a line.

Parameters