public interface StyledTextContent
Modifier and Type | Method and Description |
---|---|
void |
addTextChangeListener(TextChangeListener listener)
Called by StyledText to add itself as an Observer to content changes.
|
int |
getCharCount()
Return the number of characters in the content.
|
java.lang.String |
getLine(int lineIndex)
Return the line at the given line index without delimiters.
|
int |
getLineAtOffset(int offset)
Return the line index at the given character offset.
|
int |
getLineCount()
Return the number of lines.
|
java.lang.String |
getLineDelimiter()
Return the line delimiter that should be used by the StyledText
widget when inserting new lines.
|
int |
getOffsetAtLine(int lineIndex)
Return the character offset of the first character of the given line.
|
java.lang.String |
getTextRange(int start,
int length)
Returns a string representing the content at the given range.
|
void |
removeTextChangeListener(TextChangeListener listener)
Remove the specified text changed listener.
|
void |
replaceTextRange(int start,
int replaceLength,
java.lang.String text)
Replace the text with "newText" starting at position "start"
for a length of "replaceLength".
|
void |
setText(java.lang.String text)
Set text to "text".
|
void addTextChangeListener(TextChangeListener listener)
listener
- the listenerjava.lang.IllegalArgumentException
- int getCharCount()
java.lang.String getLine(int lineIndex)
lineIndex
- index of the line to return. Does not include
delimiters of preceding lines. Index 0 is the first line of the
content.int getLineAtOffset(int offset)
offset
- offset of the line to return. The first character of the
document is at offset 0. An offset of getLength() is valid and should
answer the number of lines.int getLineCount()
java.lang.String getLineDelimiter()
int getOffsetAtLine(int lineIndex)
NOTE: When there is no text (i.e., no lines), getOffsetAtLine(0) is a valid call that should return 0.
lineIndex
- index of the line. The first line is at index 0.java.lang.String getTextRange(int start, int length)
start
- the start offset of the text to return. Offset 0 is the
first character of the document.length
- the length of the text to returnvoid removeTextChangeListener(TextChangeListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- void replaceTextRange(int start, int replaceLength, java.lang.String text)
Implementors have to notify the TextChangeListeners that were added
using addTextChangeListener
before and after the content
is changed. A TextChangingEvent
has to be sent to the
textChanging method before the content is changed and a
TextChangedEvent
has to be sent to the textChanged method
after the content has changed.
The text change that occurs after the TextChangingEvent
has been sent has to be consistent with the data provided in the
TextChangingEvent
.
This data will be cached by the widget and will be used when the
TextChangedEvent
is received.
The TextChangingEvent
should be set as follows:
start
- start offset of text to replace, none of the offsets include
delimiters of preceding lines, offset 0 is the first character of the
documentreplaceLength
- length of text to replacetext
- text to replaceTextChangeListener
void setText(java.lang.String text)
TextChangedEvent
to the
textSet method of the TextChangeListeners that were added using
addTextChangeListener
.
text
- the new textTextChangeListener