private static int getWordStartImpl(RSyntaxDocument doc, Element elem, int offs) throws BadLocationException { int start = elem.getStartOffset(); int wordStart = offs; while (wordStart >= start) { char ch = doc.charAt(wordStart); // Ignore newlines so we work when caret is at end of line if (!isIdentifierChar(ch) && ch != '\n') { break; } wordStart--; } return wordStart==offs ? offs : wordStart + 1; }
private int getPreviousWordStartInLine(RSyntaxDocument doc, Element elem, int offs) throws BadLocationException { int start = elem.getStartOffset(); int cur = offs; // Skip any whitespace or non-word chars while (cur >= start) { char ch = doc.charAt(cur); if (isIdentifierChar(ch)) { break; } cur--; } if (cur < start) { // Empty line or nothing but whitespace/non-word chars return -1; } return getWordStartImpl(doc, elem, cur); }
@Override protected int getWordEnd(RTextArea textArea, int offs) throws BadLocationException { RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument(); Element root = doc.getDefaultRootElement(); int line = root.getElementIndex(offs); Element elem = root.getElement(line); int end = elem.getEndOffset() - 1; int wordEnd = offs; while (wordEnd <= end) { if (!isIdentifierChar(doc.charAt(wordEnd))) { break; } wordEnd++; } return wordEnd; }
char ch = doc.charAt(dot-2); if (ch=='<' || ch=='[') {
char ch = doc.charAt(offs); if (isIdentifierChar(ch)) { offs--;
/** * {@inheritDoc} */ @Override public boolean isAutoActivateOkay(JTextComponent tc) { boolean ok = super.isAutoActivateOkay(tc); // In our constructor, we set up auto-activation of the completion // popup to occur on space chars. This extra check makes it a little // more sane, by only letting space auto-activate completion choices // for property values. if (ok) { RSyntaxDocument doc = (RSyntaxDocument)tc.getDocument(); int dot = tc.getCaretPosition(); try { if (dot>1 && doc.charAt(dot)==' ') { // Caret hasn't advanced (?) ok = doc.charAt(dot-1)==':'; } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } } return ok; }
private static int getWordStartImpl(RSyntaxDocument doc, Element elem, int offs) throws BadLocationException { int start = elem.getStartOffset(); int wordStart = offs; while (wordStart >= start) { char ch = doc.charAt(wordStart); // Ignore newlines so we work when caret is at end of line if (!isIdentifierChar(ch) && ch != '\n') { break; } wordStart--; } return wordStart==offs ? offs : wordStart + 1; }
private int getPreviousWordStartInLine(RSyntaxDocument doc, Element elem, int offs) throws BadLocationException { int start = elem.getStartOffset(); int cur = offs; // Skip any whitespace or non-word chars while (cur >= start) { char ch = doc.charAt(cur); if (isIdentifierChar(ch)) { break; } cur--; } if (cur < start) { // Empty line or nothing but whitespace/non-word chars return -1; } return getWordStartImpl(doc, elem, cur); }
@Override protected int getWordEnd(RTextArea textArea, int offs) throws BadLocationException { RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument(); Element root = doc.getDefaultRootElement(); int line = root.getElementIndex(offs); Element elem = root.getElement(line); int end = elem.getEndOffset() - 1; int wordEnd = offs; while (wordEnd <= end) { if (!isIdentifierChar(doc.charAt(wordEnd))) { break; } wordEnd++; } return wordEnd; }
char ch = doc.charAt(dot-2); if (ch=='<' || ch=='[') {
char ch = doc.charAt(dot-2); if (ch=='<' || ch=='[') {
char ch = doc.charAt(offs); if (isIdentifierChar(ch)) { offs--;
int start, end; RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument(); char bracket = doc.charAt(caretPosition);