public class TextUtilities
extends java.lang.Object
Constructor and Description |
---|
TextUtilities() |
Modifier and Type | Method and Description |
---|---|
static int |
findMatchingBracket(javax.swing.text.Document doc,
int offset)
Returns the offset of the bracket matching the one at the
specified offset of the document, or -1 if the bracket is
unmatched (or if the character is not a bracket).
|
static int |
findWordEnd(java.lang.String line,
int pos,
java.lang.String noWordSep)
Locates the end of the word at the specified position.
|
static int |
findWordStart(java.lang.String line,
int pos,
java.lang.String noWordSep)
Locates the start of the word at the specified position.
|
static SyntaxDocument |
getSyntaxDocument(java.lang.String text,
java.lang.String syntax)
Return a SyntaxDocument from a text.
|
static Word |
getWord(SyntaxDocument document,
int offset)
Return the word corresponding to an offset in a SyntaxDocument.
|
public static int findMatchingBracket(javax.swing.text.Document doc, int offset) throws javax.swing.text.BadLocationException
doc
- The documentoffset
- The offsetjavax.swing.text.BadLocationException
- If an out-of-bounds access was attempted on the document textpublic static int findWordStart(java.lang.String line, int pos, java.lang.String noWordSep)
line
- The textpos
- The positionnoWordSep
- the String for elements which are not wordspublic static int findWordEnd(java.lang.String line, int pos, java.lang.String noWordSep)
line
- The textpos
- The positionnoWordSep
- the String for elements which are not wordspublic static SyntaxDocument getSyntaxDocument(java.lang.String text, java.lang.String syntax)
text
- the textsyntax
- the syntaxpublic static Word getWord(SyntaxDocument document, int offset)
document
- the documentoffset
- the offsetCopyright © 2016, 2017, 2018, 2019, 2023 Herve Girod. All Rights Reserved. Documentation and source under the MIT licence