The mutable Text class actually implements the full API, whereas
the superclasses are purely abstract (could be interfaces instead).
- struct Span [public] ¶#
-
Selection span
- uint begin ¶#
- uint length ¶#
-
length of selection
- this(uint space = 0) ¶#
-
Create an empty Text with the specified available
space
A character like 'a' will be implicitly converted to
uint and thus will be accepted for this constructor, making
it appear like you can initialize a Text instance with a
single character, something which is not supported.
- this(T[] content, bool copy = true) ¶#
-
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(TextViewT other, bool copy = true) ¶#
-
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
- Text set(T[] chars, bool copy = true) [final] ¶#
-
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
- Text set(TextViewT other, bool copy = true) [final] ¶#
-
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
- Text select(int start = 0, int length = int.max) [final] ¶#
-
Explicitly set the current selection
- T[] selection() [final] ¶#
-
Return the currently selected content
- Span span() [final] ¶#
-
Return the index and length of the current selection
- bool select(T c) [final] ¶#
-
Find and select the next occurrence of a BMP code point
in a string. Returns true if found, false otherwise
- bool select(TextViewT other) [final] ¶#
-
Find and select the next substring occurrence. Returns
true if found, false otherwise
- bool select(T[] chars) [final] ¶#
-
Find and select the next substring occurrence. Returns
true if found, false otherwise
- bool selectPrior(T c) [final] ¶#
-
Find and select a prior occurrence of a BMP code point
in a string. Returns true if found, false otherwise
- bool selectPrior(TextViewT other) [final] ¶#
-
Find and select a prior substring occurrence. Returns
true if found, false otherwise
- bool selectPrior(T[] chars) [final] ¶#
-
Find and select a prior substring occurrence. Returns
true if found, false otherwise
- Text format(T[] format, ...) [final] ¶#
-
Append formatted content to this Text
- Text append(TextViewT other) [final] ¶#
-
Append text to this Text
- Text append(T[] chars) [final] ¶#
-
Append text to this Text
- Text append(T chr, int count = 1) [final] ¶#
-
Append a count of characters to this Text
- Text append(int v, T[] fmt = null) [final] ¶#
-
Append an integer to this Text
- Text append(long v, T[] fmt = null) [final] ¶#
-
Append a long to this Text
- Text append(double v, uint decimals = 2, int e = 10) [final] ¶#
-
Append a double to this Text
- Text append(InputStream source) [final] ¶#
-
Append content from input stream at insertion point. Use
tango.io.stream.Utf as a wrapper to perform conversion as
necessary
- Text prepend(T chr, int count = 1) [final] ¶#
-
Insert characters into this Text
- Text prepend(T[] other) [final] ¶#
-
Insert text into this Text
- Text prepend(TextViewT other) [final] ¶#
-
Insert another Text into this Text
- Text encode(char[] s) [final] ¶#
- Text encode(wchar[] s) [final] ¶#
- Text encode(dchar[] s) [final] ¶#
- Text encode(Object o) [final] ¶#
-
Append encoded text at the current selection point. The text
is converted as necessary to the appropritate utf encoding.
- Text replace(T chr) [final] ¶#
-
Replace a section of this Text with the specified
character
- Text replace(T[] chars) [final] ¶#
-
Replace a section of this Text with the specified
array
- Text replace(TextViewT other) [final] ¶#
-
Replace a section of this Text with another
- Text remove() [final] ¶#
-
Remove the selection from this Text and reset the
selection to zero length (at the current position)
- Text remove(int start, int count) [private] ¶#
-
Remove the selection from this Text
- Text truncate(int index = int.max) [final] ¶#
-
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
- Text clear() [final] ¶#
-
Clear the string content
- Text trim() [final] ¶#
-
Remove leading and trailing whitespace from this Text,
and reset the selection to the trimmed content
- Text strip(T matches) [final] ¶#
-
Remove leading and trailing matches from this Text,
and reset the selection to the stripped content
- Text reserve(uint extra) [final] ¶#
-
Reserve some extra room
- Text write(OutputStream sink) ¶#
-
Write content to output stream
- TypeInfo encoding() [final] ¶#
-
Get the encoding type
- Comparator comparator(Comparator other) [final] ¶#
-
Set the comparator delegate. Where other is null, we behave
as a getter only
- hash_t toHash() [override] ¶#
-
Hash this Text
- uint length() [final] ¶#
-
Return the length of the valid content
- bool equals(TextViewT other) [final] ¶#
-
Is this Text equal to another?
- bool equals(T[] other) [final] ¶#
-
Is this Text equal to the provided text?
- bool ends(TextViewT other) [final] ¶#
-
Does this Text end with another?
- bool ends(T[] chars) [final] ¶#
-
Does this Text end with the specified string?
- bool starts(TextViewT other) [final] ¶#
-
Does this Text start with another?
- bool starts(T[] chars) [final] ¶#
-
Does this Text start with the specified string?
- int compare(TextViewT other) [final] ¶#
-
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".
- int compare(T[] chars) [final] ¶#
-
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".
- T[] copy(T[] dst) [final] ¶#
-
Return content from this Text
A slice of dst is returned, representing a copy of the
content. The slice is clipped to the minimum of either
the length of the provided array, or the length of the
content minus the stipulated start point
- T[] slice() [final] ¶#
-
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
- char[] toString(char[] dst = null) [final] ¶#
- wchar[] toString16(wchar[] dst = null) [final] ¶#
- dchar[] toString32(dchar[] dst = null) [final] ¶#
-
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:
1
2
3
4
5
6
7
| _Text string;
wchar[] buffer;
wchar[] result = string.utf16 (buffer);
if (result.length > buffer.length)
buffer = result;
|
You can also provide a buffer from the stack, but the output
will be moved to the heap if said buffer is not large enough
- int opCmp(Object o) [override] ¶#
-
Compare this Text to another. We compare against other
Strings only. Literals and other objects are not supported
- int opEquals(Object o) [override] ¶#
- int opEquals(T[] s) [final] ¶#
-
Is this Text equal to the text of something else?
- void pinIndex(inout int x) [private] ¶#
-
Pin the given index to a valid position.
- void pinIndices(inout int start, inout int length) [private] ¶#
-
Pin the given index and length to a valid position.
- int simpleComparator(T[] a, T[] b) [private] ¶#
-
Compare two arrays. Returns 0 if the content matches, less
than zero if A is "less" than B, or greater than zero where
A is "bigger". Where the substrings match, the shorter is
considered "less".
- void expand(uint index, uint count) [private] ¶#
-
Make room available to insert or append something
- Text set(T chr, uint start, uint count) [private] ¶#
-
Replace a section of this Text with the specified
character
- void realloc(uint count = 0) [private] ¶#
-
Allocate memory due to a change in the content. We handle
the distinction between mutable and immutable here.
- Text append(T* chars, uint count) [private] ¶#
-
Internal method to support Text appending