DefaultContent

Constructors

this
this()

Creates a new DefaultContent and initializes it. A <code>StyledTextContent</> will always have at least one empty line.

Members

Functions

addLineIndex
void addLineIndex(int start, int length)

Adds a line to the end of the line indexes array. Increases the size of the array if necessary. <code>lineCount</code> is updated to reflect the new entry. <p>

addLineIndex
int[][] addLineIndex(int start, int length, int[][] linesArray, int count)

Adds a line index to the end of <code>linesArray</code>. Increases the size of the array if necessary and returns a new array. <p>

addTextChangeListener
void addTextChangeListener(TextChangeListener listener)

Adds a <code>TextChangeListener</code> listening for <code>TextChangingEvent</code> and <code>TextChangedEvent</code>. A <code>TextChangingEvent</code> is sent before changes to the text occur. A <code>TextChangedEvent</code> is sent after changes to the text occurred. <p>

adjustGap
void adjustGap(int position, int sizeHint, int line)

Adjusts the gap to accommodate a text change that is occurring. <p>

delete_
void delete_(int position, int length_, int numLines)

Deletes text. <p> @param position the position at which the text to delete starts @param length the length of the text to delete @param numLines the number of lines that are being deleted

error
void error(int code)

Reports an SWT error. <p>

expandLinesBy
void expandLinesBy(int numLines)

Increases the line indexes array to accommodate more lines. <p>

gapExists
bool gapExists()

Returns whether or not a gap exists in the text store. <p>

getCharCount
int getCharCount()

@return the logical length of the text store

getFullLine
String getFullLine(int index)

Returns the line at the given index with delimiters. <p> @param index the index of the line to return @return the logical line text (i.e., without the gap) with delimiters

getLine
String getLine(int index)

Returns the line at <code>index</code> without delimiters. <p>

getLineAtOffset
int getLineAtOffset(int charPosition)

Returns the line at the given offset. DWT: index can be an invalid UTF-8 index <p>

getLineAtPhysicalOffset
int getLineAtPhysicalOffset(int position)

Returns the line index at the given physical offset. <p>

getLineCount
int getLineCount()

@return the number of lines in the text store

getLineDelimiter
String getLineDelimiter()

Returns the line delimiter that should be used by the StyledText widget when inserting new lines. This delimiter may be different than the delimiter that is used by the <code>StyledTextContent</code> interface. <p>

getOffsetAtLine
int getOffsetAtLine(int lineIndex)

Returns the logical offset of the given line. <p>

getPhysicalLine
String getPhysicalLine(int index)

Returns the physical line at the given index (i.e., with delimiters and the gap). <p>

getPhysicalText
String getPhysicalText(int start, int length_)

Returns a string representing the continuous content of the text store. <p>

getTextRange
String getTextRange(int start, int length_)

Returns a string representing the logical content of the text store (i.e., gap stripped out). <p>

indexLines
void indexLines()

Calculates the indexes of each line in the text store. Assumes no gap exists. Optimized to do less checking.

indexLines
int[][] indexLines(int offset, int length, int numLines)

Calculates the indexes of each line of text in the given range. <p>

insert
void insert(int position, String text)

Inserts text. <p>

isDelimiter
bool isDelimiter(char ch)

Returns whether or not the given character is a line delimiter. Both CR and LF are valid line delimiters. <p>

isValidReplace
bool isValidReplace(int start, int replaceLength, String newText)

Determine whether or not the replace operation is valid. DefaultContent will not allow the /r/n line delimiter to be split or partially deleted. <p>

lineCount
int lineCount(int startOffset, int length)

Returns the number of lines that are in the specified text. <p>

lineCount
int lineCount(String text)

Returns the number of lines that are in the specified text. <p>

moveAndResizeGap
void moveAndResizeGap(int position, int size, int newGapLine)

Moves the gap and adjusts its size in anticipation of a text change. The gap is resized to actual size + the specified size and moved to the given position. <p>

removeTextChangeListener
void removeTextChangeListener(TextChangeListener listener)

Removes the specified <code>TextChangeListener</code>. <p>

replaceTextRange
void replaceTextRange(int start, int replaceLength, String newText)

Replaces the text with <code>newText</code> starting at position <code>start</code> for a length of <code>replaceLength</code>. Notifies the appropriate listeners. <p>

sendTextEvent
void sendTextEvent(StyledTextEvent event)

Sends the text listeners the TextChanged event.

setText
void setText(String text)

Sets the content to text and removes the gap since there are no sensible predictions about where the next change will occur. <p>

Inherited Members

From StyledTextContent

addTextChangeListener
void addTextChangeListener(TextChangeListener listener)

Called by StyledText to add itself as an Observer to content changes. See TextChangeListener for a description of the listener methods that are called when text changes occur. <p>

getCharCount
int getCharCount()

Return the number of characters in the content. <p>

getLine
String getLine(int lineIndex)

Return the line at the given line index without delimiters. <p>

getLineAtOffset
int getLineAtOffset(int offset)

Return the line index at the given character offset. <p>

getLineCount
int getLineCount()

Return the number of lines. Should answer 1 when no text is specified. The StyledText widget relies on this behavior for drawing the cursor. <p>

getLineDelimiter
String getLineDelimiter()

Return the line delimiter that should be used by the StyledText widget when inserting new lines. New lines entered using key strokes and paste operations use this line delimiter. Implementors may use System.getProperty("line.separator") to return the platform line delimiter. <p>

getOffsetAtLine
int getOffsetAtLine(int lineIndex)

Return the character offset of the first character of the given line. <p> <b>NOTE:</b> When there is no text (i.e., no lines), getOffsetAtLine(0) is a valid call that should return 0. </p>

getTextRange
String getTextRange(int start, int length)

Returns a string representing the content at the given range. <p>

removeTextChangeListener
void removeTextChangeListener(TextChangeListener listener)

Remove the specified text changed listener. <p>

replaceTextRange
void replaceTextRange(int start, int replaceLength, String text)

Replace the text with "newText" starting at position "start" for a length of "replaceLength". <p> Implementors have to notify the TextChangeListeners that were added using <code>addTextChangeListener</code> before and after the content is changed. A <code>TextChangingEvent</code> has to be sent to the textChanging method before the content is changed and a <code>TextChangedEvent</code> has to be sent to the textChanged method after the content has changed. The text change that occurs after the <code>TextChangingEvent</code> has been sent has to be consistent with the data provided in the <code>TextChangingEvent</code>. This data will be cached by the widget and will be used when the <code>TextChangedEvent</code> is received. <p> The <code>TextChangingEvent</code> should be set as follows: <ul> <li>event.start = start of the replaced text <li>event.newText = text that is going to be inserted or empty String if no text will be inserted <li>event.replaceCharCount = length of text that is going to be replaced <li>event.newCharCount = length of text that is going to be inserted <li>event.replaceLineCount = number of lines that are going to be replaced <li>event.newLineCount = number of new lines that are going to be inserted </ul> <b>NOTE:</b> newLineCount is the number of inserted lines and replaceLineCount is the number of deleted lines based on the change that occurs visually. For example: <ul> <li>(replaceText, newText) is> (replaceLineCount, newLineCount) <li>("", "\n") is> (0, 1) <li>("\n\n", "a") is> (2, 0) <li>("a", "\n\n") is> (0, 2) <li>("\n", "") is> (1, 0) </ul> </p>

setText
void setText(String text)

Set text to "text". Implementors have to send a <code>TextChangedEvent</code> to the textSet method of the TextChangeListeners that were added using <code>addTextChangeListener</code>. <p>

Meta