|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.swt.custom.DefaultContent
Field Summary | |
(package private) int |
expandExp
|
(package private) int |
gapEnd
|
(package private) int |
gapLine
|
(package private) int |
gapStart
|
(package private) int |
highWatermark
|
(package private) int |
lineCount
|
private static String |
LineDelimiter
|
(package private) int[][] |
lines
|
(package private) int |
lowWatermark
|
(package private) int |
replaceExpandExp
|
(package private) Vector |
textListeners
|
(package private) char[] |
textStore
|
Constructor Summary | |
(package private) |
DefaultContent()
Creates a new DefaultContent and initializes it. |
Method Summary | |
(package private) void |
addLineIndex(int start,
int length)
Adds a line to the end of the line indexes array. |
(package private) int[][] |
addLineIndex(int start,
int length,
int[][] linesArray,
int count)
Adds a line index to the end of linesArray . |
void |
addTextChangeListener(TextChangeListener listener)
Adds a TextChangeListener listening for
TextChangingEvent and TextChangedEvent . |
(package private) void |
adjustGap(int position,
int sizeHint,
int line)
Adjusts the gap to accomodate a text change that is occurring. |
(package private) void |
delete(int position,
int length,
int numLines)
Deletes text. |
(package private) void |
error(int code)
Reports an SWT error. |
(package private) void |
expandLinesBy(int numLines)
Increases the line indexes array to accomodate more lines. |
(package private) boolean |
gapExists()
Returns whether or not a gap exists in the text store. |
int |
getCharCount()
Enabled: Return the number of characters in the content. |
(package private) String |
getFullLine(int index)
Returns the line at the given index with delimiters. |
String |
getLine(int index)
Returns the line at index without delimiters. |
int |
getLineAtOffset(int charPosition)
Returns the line at the given offset. |
(package private) int |
getLineAtPhysicalOffset(int position)
Returns the line index at the given physical offset. |
int |
getLineCount()
Enabled: Return the number of lines. |
String |
getLineDelimiter()
Returns the line delimiter that should be used by the StyledText widget when inserting new lines. |
int |
getOffsetAtLine(int lineIndex)
Returns the logical offset of the given line. |
(package private) String |
getPhysicalLine(int index)
Returns the physical line at the given index (i.e., with delimiters and the gap). |
(package private) String |
getPhysicalText(int start,
int length)
Returns a string representing the continous content of the text store. |
String |
getTextRange(int start,
int length)
Returns a string representing the logical content of the text store (i.e., gap stripped out). |
(package private) void |
indexLines()
Calculates the indexes of each line in the text store. |
(package private) int[][] |
indexLines(int offset,
int length,
int numLines)
Calculates the indexes of each line of text in the given range. |
(package private) void |
insert(int position,
String text)
Inserts text. |
(package private) boolean |
isDelimiter(char ch)
Returns whether or not the given character is a line delimiter. |
protected boolean |
isValidReplace(int start,
int replaceLength,
String newText)
Determine whether or not the replace operation is valid. |
(package private) int |
lineCount(int startOffset,
int length)
Returns the number of lines that are in the specified text. |
(package private) int |
lineCount(String text)
Returns the number of lines that are in the specified text. |
(package private) void |
moveAndResizeGap(int position,
int size,
int newGapLine)
Moves the gap and adjusts its size in anticipation of a text change. |
void |
removeTextChangeListener(TextChangeListener listener)
Removes the specified TextChangeListener . |
void |
replaceTextRange(int start,
int replaceLength,
String newText)
Replaces the text with newText starting at position start
for a length of replaceLength . |
(package private) void |
sendTextEvent(StyledTextEvent event)
Sends the text listeners the TextChanged event. |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final String LineDelimiter
Vector textListeners
char[] textStore
int gapStart
int gapEnd
int gapLine
int highWatermark
int lowWatermark
int[][] lines
int lineCount
int expandExp
int replaceExpandExp
Constructor Detail |
DefaultContent()
StyledTextContent> will always have
at least one empty line.
Method Detail |
void addLineIndex(int start, int length)
lineCount
is updated to reflect the new entry.
start
- the start of the linelength
- the length of the lineint[][] addLineIndex(int start, int length, int[][] linesArray, int count)
linesArray
. Increases the
size of the array if necessary and returns a new array.
start
- the start of the linelength
- the length of the linelinesArray
- the array to which to add the line indexcount
- the position at which to add the line
public void addTextChangeListener(TextChangeListener listener)
TextChangeListener
listening for
TextChangingEvent
and TextChangedEvent
. A
TextChangingEvent
is sent before changes to the text occur.
A TextChangedEvent
is sent after changes to the text
occured.
addTextChangeListener
in interface StyledTextContent
listener
- the listenervoid adjustGap(int position, int sizeHint, int line)
position
- the position at which a change is occurringsizeHint
- the size of the changeline
- the line where the gap will govoid indexLines()
boolean isDelimiter(char ch)
ch
- the character to test
protected boolean isValidReplace(int start, int replaceLength, String newText)
start
- start offset of text to replacereplaceLength
- start offset of text to replacenewText
- start offset of text to replaceint[][] indexLines(int offset, int length, int numLines)
offset
- the logical start offset of the text lineatelength
- the length of the text to lineate, includes gapnumLines
- the number of lines to initially allocate for the line index array,
passed in for efficiency (the exact number of lines may be known)
void insert(int position, String text)
position
- the position at which to insert the textvoid moveAndResizeGap(int position, int size, int newGapLine)
position
- the position at which a change is occurringint lineCount(int startOffset, int length)
startOffset
- the start of the text to lineatelength
- the length of the text to lineate
int lineCount(String text)
text
- the text to lineate
public int getCharCount()
StyledTextContent
getCharCount
in interface StyledTextContent
public String getLine(int index)
index
without delimiters.
getLine
in interface StyledTextContent
index
- the index of the line to return
public String getLineDelimiter()
StyledTextContent
interface.
getLineDelimiter
in interface StyledTextContent
String getFullLine(int index)
index
- the index of the line to return
String getPhysicalLine(int index)
index
- the line index
public int getLineCount()
StyledTextContent
getLineCount
in interface StyledTextContent
public int getLineAtOffset(int charPosition)
getLineAtOffset
in interface StyledTextContent
charPosition
- logical character offset (i.e., does not include gap)
int getLineAtPhysicalOffset(int position)
position
- physical character offset (i.e., includes gap)
public int getOffsetAtLine(int lineIndex)
getOffsetAtLine
in interface StyledTextContent
lineIndex
- index of line
void expandLinesBy(int numLines)
numLines
- the number to increase the array byvoid error(int code)
code
- the error codeboolean gapExists()
String getPhysicalText(int start, int length)
start
- the physical start offset of the text to returnlength
- the physical length of the text to return
public String getTextRange(int start, int length)
getTextRange
in interface StyledTextContent
start
- the logical start offset of the text to returnlength
- the logical length of the text to return
public void removeTextChangeListener(TextChangeListener listener)
TextChangeListener
.
removeTextChangeListener
in interface StyledTextContent
listener
- the listenerpublic void replaceTextRange(int start, int replaceLength, String newText)
newText
starting at position start
for a length of replaceLength
. Notifies the appropriate listeners.
When sending the TextChangingEvent, newLineCount
is the number of
lines that are going to be inserted and replaceLineCount
is
the number of lines that are going to be deleted, based on the change
that occurs visually. For example:
replaceTextRange
in interface StyledTextContent
start
- start offset of text to replacereplaceLength
- start offset of text to replacenewText
- start offset of text to replaceTextChangeListener
void sendTextEvent(StyledTextEvent event)
public void setText(String text)
setText
in interface StyledTextContent
text
- the textTextChangeListener
void delete(int position, int length, int numLines)
position
- the position at which the text to delete startslength
- the length of the text to deletenumLines
- the number of lines that are being deleted
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |