Package editor.util
Class TextComponentUtil
java.lang.Object
editor.util.TextComponentUtil
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intadjustForLineComment(JTextComponent editor, int iStart) static voiddeleteWordAtCaret(JTextComponent editor) static voidstatic intfindCharacterPositionOnLine(int startPosition, String string, char charToFind, TextComponentUtil.Direction d) static intfindNonWhitespacePositionAfter(String script, int position) static intfindNonWhitespacePositionBefore(String script, int position) protected static StringfindPreviousTextChunk(int startPosition, String text) static voidfixTextComponentKeyMap(JTextComponent editor) static intgetColumnAtPosition(JTextComponent editor, int caretPosition) static intgetDeepestWhiteSpaceLineStartAfter(String script, int offset) Eats whitespace lines after the given offset until it finds a non-whitespace line and returns the start of the last whitespace line found, or the initial value if none was.static Stringstatic intgetLineAtPosition(JTextComponent editor, int position) Gets the line at a given position in the editorstatic intgetLineEnd(String text, int initialCaretPosition) static intgetLineStart(String text, int initialCaretPosition) static int[]getLineStartAndEndPositions(String text, int initialCaretPosition) This will return a two element array, start line pos and end line pos.static StringgetMemberAtCaret(JTextComponent editor) static Dimensionstatic intgetNextWordPostition(int pos, String source, boolean consumeWhitespaceFirst) static Stringstatic StringgetPartialWordBeforePos(JTextComponent editor, int iPos) static intgetWhiteSpaceLineStartAfter(String script, int end) Returns the start of the next line if that line is only whitespace.static intgetWhiteSpaceLineStartBefore(String script, int start) Returns the start of the previous line if that line is only whitespace.static intgetWhiteSpaceOrCommentLineStartAfter(String script, int end) Returns the start of the next line if that line is only whitespace.static intgetWhiteSpaceOrCommentLineStartBefore(String script, int start) Returns the start of the previous line if that line is only whitespace.static StringgetWordAtCaret(JTextComponent editor) static Dimensionstatic Dimensionstatic intgetWordEnd(JTextComponent editor, int iOffset) static intgetWordStart(JTextComponent editor, int iOffset) static voidhandleHomeKey(JTextComponent editor) static booleanisNonWhitespaceBetween(JTextComponent editor, int iStart, int iEnd) static booleanisValidIdentifier(CharSequence seqId, boolean acceptDot) static voidjumpLeft(JTextComponent editor) static voidjumpRight(JTextComponent editor) static StringmakeValidIdentifier(String str, boolean acceptDot, boolean bAcceptUnderscore) static intreplaceWordAtCaret(JTextComponent editor, String strText) static voidreplaceWordAtCaretDynamic(JTextComponent editor, String strText, IReplaceWordCallback replaceWordCallback, boolean selectFirstArg, boolean replaceWholeWord) static voidreplaceWordAtCaretDynamicAndRemoveEmptyParens(JTextComponent editor, String strText, IReplaceWordCallback replaceWordCallback, boolean selectFirstArg, boolean replaceWholeWord) static voidreplaceWordAtCaretNice(JTextComponent editor, String strText) static voidreplaceWordAtClosestDot(JTextComponent editor, String strText) static intreplaceWordBeforeCaret(JTextComponent editor, String strText) static voidselectLeft(JTextComponent editor) static voidselectLineAtCaret(JTextComponent editor) static voidselectRight(JTextComponent editor) static voidselectWordAtCaret(JTextComponent editor) static voidshowPasteBufferDialogForComponent(JTextComponent component) static voidunindentLineAtCaret(JTextComponent editor)
-
Constructor Details
-
TextComponentUtil
public TextComponentUtil()
-
-
Method Details
-
findCharacterPositionOnLine
public static int findCharacterPositionOnLine(int startPosition, String string, char charToFind, TextComponentUtil.Direction d) -
getWordAtCaret
-
getPartialWordBeforeCaret
-
getPartialWordBeforePos
-
getWordDimensionAtCaret
-
getWordDimensionBeforeCaret
-
getMemberDimensionAtCaret
-
getMemberAtCaret
-
selectWordAtCaret
-
replaceWordAtClosestDot
-
replaceWordAtCaret
- Returns:
- offset of replaced word
-
replaceWordBeforeCaret
- Returns:
- offset of replaced word
-
replaceWordAtCaretNice
-
replaceWordAtCaretDynamic
public static void replaceWordAtCaretDynamic(JTextComponent editor, String strText, IReplaceWordCallback replaceWordCallback, boolean selectFirstArg, boolean replaceWholeWord) -
replaceWordAtCaretDynamicAndRemoveEmptyParens
public static void replaceWordAtCaretDynamicAndRemoveEmptyParens(JTextComponent editor, String strText, IReplaceWordCallback replaceWordCallback, boolean selectFirstArg, boolean replaceWholeWord) -
getWordStart
- Throws:
BadLocationException
-
getWordEnd
- Throws:
BadLocationException
-
adjustForLineComment
public static int adjustForLineComment(JTextComponent editor, int iStart) throws BadLocationException - Throws:
BadLocationException
-
isNonWhitespaceBetween
-
getLineStartAndEndPositions
This will return a two element array, start line pos and end line pos. The character from the document for the startPos will be the first character of the line The character from the document for the endPos will be the last character of the line, i.e. the char before the new line if one is present.- Returns:
- a two element array with the start and end positions of the given line
-
getLineStart
-
getLineEnd
-
deleteWordAtCaret
- Throws:
BadLocationException
-
findPreviousTextChunk
-
getLineAtPosition
Gets the line at a given position in the editor -
getColumnAtPosition
-
getWhiteSpaceLineStartBefore
Returns the start of the previous line if that line is only whitespace. Returns -1 otherwise. -
getWhiteSpaceLineStartAfter
Returns the start of the next line if that line is only whitespace. Returns -1 otherwise. -
getWhiteSpaceOrCommentLineStartBefore
Returns the start of the previous line if that line is only whitespace. Returns -1 otherwise. -
getWhiteSpaceOrCommentLineStartAfter
Returns the start of the next line if that line is only whitespace. Returns -1 otherwise. -
getDeepestWhiteSpaceLineStartAfter
Eats whitespace lines after the given offset until it finds a non-whitespace line and returns the start of the last whitespace line found, or the initial value if none was. -
findNonWhitespacePositionAfter
- Returns:
- the next non-whitespace position in the given script
-
findNonWhitespacePositionBefore
- Returns:
- the first non-whitespace position in the given script before the given position
-
getNextWordPostition
-
fixTextComponentKeyMap
-
expandSelectionIfNeeded
-
selectLineAtCaret
-
selectRight
-
jumpRight
-
jumpLeft
-
selectLeft
-
handleHomeKey
-
showPasteBufferDialogForComponent
-
unindentLineAtCaret
- Throws:
BadLocationException
-
getIdentifierAtCaret
-
isValidIdentifier
-
makeValidIdentifier
-