public class TextAreaSelection
extends java.lang.Object
Constructor and Description |
---|
TextAreaSelection(SyntaxDocument document)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
disableSelectionIfEmpty() |
boolean |
getBiasLeft() |
int |
getCaretLine()
Returns the caret line.
|
int |
getCaretPosition()
Returns the caret position.
|
SyntaxDocument |
getDocument()
Returns the document this text area is editing.
|
int |
getDocumentLength()
Returns the length of the document.
|
int |
getLineCount()
Returns the number of lines in the document.
|
int |
getLineEndOffset(int line)
Returns the end offset of the specified line.
|
int |
getLineLength(int line)
Returns the length of the specified line.
|
int |
getLineOfOffset(int offset)
Returns the line containing the specified offset.
|
int |
getLineStartOffset(int line)
Returns the start offset of the specified line.
|
java.lang.CharSequence |
getLineText(int lineIndex)
Returns the text on the specified line.
|
void |
getLineText(int lineIndex,
javax.swing.text.Segment segment)
Copies the text on the specified line into a segment.
|
int |
getMarkPosition()
Returns the mark position.
|
java.lang.String |
getSelectedText()
Returns the selected text, or null if no selection is active.
|
int |
getSelectionEnd()
Returns the selection end offset.
|
int |
getSelectionEndLine()
Returns the selection end line.
|
int |
getSelectionStart()
Returns the selection start offset.
|
int |
getSelectionStartLine()
Returns the selection start line.
|
java.lang.String |
getText()
Returns the entire text of this text area.
|
java.lang.String |
getText(int start,
int len)
Returns the specified substring of the document.
|
void |
getText(int start,
int len,
javax.swing.text.Segment segment)
Copies the specified substring of the document into a segment.
|
TokenMarker |
getTokenMarker()
Returns the document's token marker.
|
boolean |
isSelectionRectangular()
Returns true if the selection is rectangular, false otherwise.
|
void |
setSelectedText(java.lang.String selectedText)
Replaces the selection with the specified text.
|
void |
setSelection(int newStart,
int newEnd,
int newStartLine,
int newEndLine,
boolean newBias) |
void |
setSelectionRectangular(boolean rectangleSelect)
Sets if the selection should be rectangular.
|
void |
setText(java.lang.String text)
Sets the entire text of this text area.
|
public TextAreaSelection(@NotNull SyntaxDocument document)
document
- the document to select inpublic int getSelectionStart()
public int getSelectionStartLine()
public int getSelectionEnd()
public int getSelectionEndLine()
public boolean getBiasLeft()
public int getCaretPosition()
public int getCaretLine()
public int getMarkPosition()
getCaretPosition()
public void setSelection(int newStart, int newEnd, int newStartLine, int newEndLine, boolean newBias)
@Nullable public java.lang.String getSelectedText()
public void disableSelectionIfEmpty()
@Nullable public java.lang.String getText(int start, int len)
start
- the start offsetlen
- the length of the substringpublic void getText(int start, int len, @NotNull javax.swing.text.Segment segment)
start
- the start offsetlen
- the length of the substringsegment
- the segmentpublic void setSelectedText(@NotNull java.lang.String selectedText)
selectedText
- the replacement text for the selectionpublic boolean isSelectionRectangular()
public void setSelectionRectangular(boolean rectangleSelect)
rectangleSelect
- true if the selection should be rectangular, false
otherwise@NotNull public SyntaxDocument getDocument()
@Nullable public TokenMarker getTokenMarker()
getDocument().getTokenMarker()
.public int getDocumentLength()
getDocument().getLength()
.public int getLineCount()
public int getLineOfOffset(int offset)
offset
- the offsetpublic int getLineStartOffset(int line)
line
- the linepublic int getLineEndOffset(int line)
line
- the linepublic int getLineLength(int line)
line
- the line@NotNull public java.lang.String getText()
public void setText(@NotNull java.lang.String text)
@NotNull public java.lang.CharSequence getLineText(int lineIndex)
lineIndex
- the linepublic void getLineText(int lineIndex, @NotNull javax.swing.text.Segment segment)
lineIndex
- the line