11 package net.sf.gridarta.textedit.textarea;
13 import javax.swing.text.BadLocationException;
14 import javax.swing.text.Document;
38 public static int findMatchingBracket(
final Document doc,
final int offset)
throws BadLocationException {
39 if (doc.getLength() == 0) {
42 final char c = doc.getText(offset, 1).charAt(0);
44 final boolean direction;
85 final CharSequence text = doc.getText(0, offset);
88 for (
int i = offset - 1; i >= 0; i--) {
93 final char x = text.charAt(i);
96 }
else if (x == cPrime) {
107 final int len = doc.getLength() - (offset + 1);
114 final CharSequence text = doc.getText(offset + 1, len);
117 for (
int i = 0; i < len; i++) {
122 final char x = text.charAt(i);
126 }
else if (x == cPrime) {
131 return i + offset + 1;
149 public static int findWordStart(
final CharSequence line,
final int pos,
final String noWordSep) {
150 char ch = line.charAt(pos - 1);
155 for (
int i = pos - 1; i >= 0; i--) {
174 public static int findWordEnd(
final CharSequence line,
final int pos,
final String noWordSep) {
175 char ch = line.charAt(pos);
179 int wordEnd = line.length();
180 for (
int i = pos; i < line.length(); i++) {
198 return !Character.isLetterOrDigit(ch) && (noWordSep == null || noWordSep.indexOf(ch) == -1);
static boolean selectNoLetter(final char ch, final String noWordSep)
Returns whether a character is not part of a word.
static int findMatchingBracket(final Document doc, final int offset)
Returns the offset of the bracket matching the one at the specified offset of the document...
static int findWordStart(final CharSequence line, final int pos, final String noWordSep)
Locates the start of the word at the specified position.
TextUtilities()
Prevent instantiation.
Class with several utility functions used by the text area component.
static int findWordEnd(final CharSequence line, final int pos, final String noWordSep)
Locates the end of the word at the specified position.