Text

The mutable Text class actually implements the full API, whereas the superclasses are purely abstract (could be interfaces instead).

class Text : TextView!(T)(
T
) {}

Constructors

this
this(size_t space)

Create an empty Text with the specified available space

this
this(T[] content, bool copy)

Create a Text upon the provided content. If said content is immutable (read-only) then you might consider setting the 'copy' parameter to false. Doing so will avoid allocating heap-space for the content until it is modified via Text methods. This can be useful when wrapping an array "temporarily" with a stack-based Text

this
this(const(T)[] content)
Undocumented in source.
this
this(TextViewT other, bool copy)

Create a Text via the content of another. If said content is immutable (read-only) then you might consider setting the 'copy' parameter to false. Doing so will avoid allocating heap-space for the content until it is modified via Text methods. This can be useful when wrapping an array temporarily with a stack-based Text

this
this(const(TextViewT) other, bool copy)
Undocumented in source.

Members

Aliases

opAssign
alias opAssign = set
Undocumented in source.
opCatAssign
alias opCatAssign = append
Undocumented in source.

Functions

append
Text append(const(TextViewT) other)

Append text to this Text

append
Text append(const(T)[] chars)

Append text to this Text

append
Text append(T chr, size_t count)

Append a count of characters to this Text

append
deprecated Text append(int v, const(T)[] fmt)

Append an integer to this Text

append
deprecated Text append(long v, const(T)[] fmt)

Append a long to this Text

append
deprecated Text append(double v, int decimals, int e)

Append a double to this Text

append
Text append(InputStream source)

Append content from input stream at insertion point. Use tango.io.stream.Utf as a wrapper to perform conversion as necessary

clear
Text clear()

Clear the string content

comparator
Comparator comparator(Comparator other)

Set the comparator delegate. Where other is null, we behave as a getter only

compare
int compare(const(TextViewT) other)

Compare this Text start with another. Returns 0 if the content matches, less than zero if this Text is "less" than the other, or greater than zero where this Text is "bigger".

compare
int compare(const(T)[] chars)

Compare this Text start with an array. Returns 0 if the content matches, less than zero if this Text is "less" than the other, or greater than zero where this Text is "bigger".

copy
T[] copy(T[] dst)

Return content from this Text

encode
Text encode(const(char)[] s)
Text encode(const(wchar)[] s)
Text encode(const(dchar)[] s)
Text encode(Object o)

Append encoded text at the current selection point. The text is converted as necessary to the appropritate utf encoding.

encoding
TypeInfo encoding()

Get the encoding type

ends
bool ends(const(TextViewT) other)

Does this Text end with another?

ends
bool ends(const(T)[] chars)

Does this Text end with the specified string?

equals
bool equals(const(TextViewT) other)

Is this Text equal to another?

equals
bool equals(const(T)[] other)

Is this Text equal to the provided text?

format
Text format(const(T)[] format, ...)

Append formatted content to this Text

mslice
T[] mslice()
Undocumented in source. Be warned that the author may not have intended to support it.
opCmp
int opCmp(Object o)

Compare this Text to another. We compare against other Strings only. Literals and other objects are not supported

opEquals
bool opEquals(Object o)
bool opEquals(const(T)[] s)

Is this Text equal to the text of something else?

prepend
Text prepend(T chr, int count)

Insert characters into this Text

prepend
Text prepend(const(T)[] other)

Insert text into this Text

prepend
Text prepend(const(TextViewT) other)

Insert another Text into this Text

remove
Text remove()

Remove the selection from this Text and reset the selection to zero length (at the current position)

replace
Text replace(T chr)

Replace a section of this Text with the specified character

replace
Text replace(const(T)[] chars)

Replace a section of this Text with the specified array

replace
Text replace(const(TextViewT) other)

Replace a section of this Text with another

reserve
Text reserve(size_t extra)

Reserve some extra room

search
Search!(T) search(const(T)[] match)

Return a search iterator for a given pattern. The iterator sets the current text selection as appropriate. For example:

search
Search!(T) search(T match)
Undocumented in source. Be warned that the author may not have intended to support it.
select
Text select(size_t start, size_t length)

Explicitly set the current selection to the given start and length. values are pinned to the content extents

select
deprecated bool select(T c)

Find and select the next occurrence of a BMP code point in a string. Returns true if found, false otherwise

select
deprecated bool select(const(TextViewT) other)

Find and select the next substring occurrence. Returns true if found, false otherwise

select
deprecated bool select(const(T)[] chars)

Find and select the next substring occurrence. Returns true if found, false otherwise

selectPrior
deprecated bool selectPrior(T c)

Find and select a prior occurrence of a BMP code point in a string. Returns true if found, false otherwise

selectPrior
deprecated bool selectPrior(const(TextViewT) other)

Find and select a prior substring occurrence. Returns true if found, false otherwise

selectPrior
deprecated bool selectPrior(const(T)[] chars)

Find and select a prior substring occurrence. Returns true if found, false otherwise

selection
const(T)[] selection()

Return the currently selected content

set
Text set(T[] chars, bool copy)

Set the content to the provided array. Parameter 'copy' specifies whether the given array is likely to change. If not, the array is aliased until such time it is altered via this class. This can be useful when wrapping an array "temporarily" with a stack-based Text.

set
Text set(const(T)[] chars)
Undocumented in source. Be warned that the author may not have intended to support it.
set
Text set(TextViewT other, bool copy)

Replace the content of this Text. If the new content is immutable (read-only) then you might consider setting the 'copy' parameter to false. Doing so will avoid allocating heap-space for the content until it is modified via one of these methods. This can be useful when wrapping an array "temporarily" with a stack-based Text.

slice
const(T)[] slice()

Return an alias to the content of this TextView. Note that you are bound by honour to leave this content wholly unmolested. D surely needs some way to enforce immutability upon array references

span
deprecated Span span()

Return the index and length of the current selection

starts
bool starts(const(TextViewT) other)

Does this Text start with another?

starts
bool starts(const(T)[] chars)

Does this Text start with the specified string?

strip
Text strip(T matches)

Remove leading and trailing matches from this Text, and reset the selection to the stripped content

toHash
hash_t toHash()

Hash this Text

toString
string toString()

Convert to the UniText types. The optional argument dst will be resized as required to house the conversion. To minimize heap allocation during subsequent conversions, apply the following pattern:

toString
char[] toString(char[] dst)
Undocumented in source. Be warned that the author may not have intended to support it.
toString16
wchar[] toString16(wchar[] dst)
toString32
dchar[] toString32(dchar[] dst)

Convert to the UniText types. The optional argument dst will be resized as required to house the conversion. To minimize heap allocation during subsequent conversions, apply the following pattern:

trim
Text trim()

Remove leading and trailing whitespace from this Text, and reset the selection to the trimmed content

truncate
Text truncate(size_t index)

Truncate this string at an optional index. Default behaviour is to truncate at the current append point. Current selection is moved to the truncation point, with length 0

write
Text write(OutputStream sink)

Write content to output stream

Properties

length
size_t length [@property getter]

Return the length of the valid content

point
size_t point [@property getter]

Return the current selection point

point
size_t point [@property setter]

Set the current selection point, and resets selection length

Structs

Span
deprecated struct Span

Selection span

Meta