/** * Returns the token at the specified index, or <code>null</code> if * the given offset isn't in this token list's range.<br> * Note that this method does NOT check to see if <code>tokenList</code> * is null; callers should check for themselves. * * @param tokenList The list of tokens in which to search. * @param offset The offset at which to get the token. * @return The token at <code>offset</code>, or <code>null</code> if * none of the tokens are at that offset. * @see #getTokenAtOffset(RSyntaxTextArea, int) * @see #getTokenAtOffset(RSyntaxDocument, int) */ public static Token getTokenAtOffset(Token tokenList, int offset) { for (Token t=tokenList; t!=null && t.isPaintable(); t=t.getNextToken()){ if (t.containsPosition(offset)) { return t; } } return null; }
float width = 0; for (Token t=tokenList; t!=null&&t.isPaintable(); t=t.getNextToken()) { if (t.containsPosition(upTo)) { return width + t.getWidthUpTo(upTo-t.getOffset(), textArea, e, x0+width);
if (t.getEndOffset()==dot || t.containsPosition(dot)) { return t; if (t.containsPosition(dot)) { break;
/** * Returns the last non-whitespace, non-comment token, before the * specified offset. * * @param doc The document. * @param offs The ending offset for the search. * @return The last non-whitespace, non-comment token, or <code>null</code> * if there isn't one. * @see #getPreviousImportantToken(RSyntaxDocument, int) * @see #getNextImportantToken(Token, RSyntaxTextArea, int) */ public static Token getPreviousImportantTokenFromOffs( RSyntaxDocument doc, int offs) { Element root = doc.getDefaultRootElement(); int line = root.getElementIndex(offs); Token t = doc.getTokenListForLine(line); // Check line containing offs Token target = null; while (t!=null && t.isPaintable() && !t.containsPosition(offs)) { if (!t.isCommentOrWhitespace()) { target = t; } t = t.getNextToken(); } // Check previous line(s) if (target==null) { target = RSyntaxUtilities.getPreviousImportantToken(doc, line-1); } return target; }
if (token.containsPosition(selStart)) { else if (token.containsPosition(selEnd)) { tempToken.copyFrom(token); tempToken.textCount = selEnd - tempToken.getOffset();
/** * Returns the token at the specified index, or <code>null</code> if * the given offset isn't in this token list's range.<br> * Note that this method does NOT check to see if <code>tokenList</code> * is null; callers should check for themselves. * * @param tokenList The list of tokens in which to search. * @param offset The offset at which to get the token. * @return The token at <code>offset</code>, or <code>null</code> if * none of the tokens are at that offset. */ public static final Token getTokenAtOffset(Token tokenList, int offset) { for (Token t=tokenList; t!=null; t=t.getNextToken()) { if (t.containsPosition(offset)) return t; } return null; }
/** * Returns the token at the specified index, or <code>null</code> if * the given offset isn't in this token list's range.<br> * Note that this method does NOT check to see if <code>tokenList</code> * is null; callers should check for themselves. * * @param tokenList The list of tokens in which to search. * @param offset The offset at which to get the token. * @return The token at <code>offset</code>, or <code>null</code> if * none of the tokens are at that offset. */ public static final Token getTokenAtOffset(Token tokenList, int offset) { for (Token t=tokenList; t!=null; t=t.getNextToken()) { if (t.containsPosition(offset)) return t; } return null; }
while (t!=null && t.isPaintable() && !t.containsPosition(pos)) { x0 += t.getWidth(textArea, e, x0); t = t.getNextToken();
if (token.containsPosition(selStart)) { else if (token.containsPosition(selEnd)) { tempToken.copyFrom(token); tempToken.textCount = selEnd - tempToken.getOffset(); if (token.containsPosition(selStart)) { else if (token.containsPosition(selEnd)) { tempToken.copyFrom(token); tempToken.textCount = selEnd - tempToken.getOffset();
/** * Returns the token at the specified index, or <code>null</code> if * the given offset isn't in this token list's range.<br> * Note that this method does NOT check to see if <code>tokenList</code> * is null; callers should check for themselves. * * @param tokenList The list of tokens in which to search. * @param offset The offset at which to get the token. * @return The token at <code>offset</code>, or <code>null</code> if * none of the tokens are at that offset. * @see #getTokenAtOffset(RSyntaxTextArea, int) * @see #getTokenAtOffset(RSyntaxDocument, int) */ public static Token getTokenAtOffset(Token tokenList, int offset) { for (Token t=tokenList; t!=null && t.isPaintable(); t=t.getNextToken()){ if (t.containsPosition(offset)) { return t; } } return null; }
/** * Returns the token before the specified offset. * * @param tokenList A list of tokens containing the offset. * @param offs The offset. * @return The token before the offset, or <code>null</code> if the * offset was the first offset in the token list (or not in the * token list at all, which would be an error). */ private static Token getTokenBeforeOffset(Token tokenList, int offs) { if (tokenList!=null) { Token prev = tokenList; for (Token t=tokenList.getNextToken(); t!=null; t=t.getNextToken()) { if (t.containsPosition(offs)) { return prev; } prev = t; } } return null; }
switch (t.getType()) { case TokenTypes.MARKUP_TAG_NAME: if (t.containsPosition(dot-1)) { return t.getType(); return t.getType(); case TokenTypes.MARKUP_TAG_ATTRIBUTE_VALUE: if (t.containsPosition(dot)) { return TokenTypes.NULL; // In the attribute itself
float width = 0; for (Token t=tokenList; t!=null&&t.isPaintable(); t=t.getNextToken()) { if (t.containsPosition(upTo)) { return width + t.getWidthUpTo(upTo-t.offset, textArea, e, x0+width);
float width = 0; for (Token t=tokenList; t!=null&&t.isPaintable(); t=t.getNextToken()) { if (t.containsPosition(upTo)) { return width + t.getWidthUpTo(upTo-t.offset, textArea, e, x0+width);
/** * Returns the token at the specified position in the model. * * @param offs The position in the model. * @return The token, or <code>null</code> if no token is at that * position. * @see #viewToToken(Point) */ private Token modelToToken(int offs) { if (offs>=0) { try { int line = getLineOfOffset(offs); Token t = getTokenListForLine(line); while (t!=null && t.isPaintable()) { if (t.containsPosition(offs)) { return t; } t = t.getNextToken(); } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } } return null; }
/** * Returns the token at the specified position in the model. * * @param offs The position in the model. * @return The token, or <code>null</code> if no token is at that * position. * @see #viewToToken(Point) */ private Token modelToToken(int offs) { if (offs>=0) { try { int line = getLineOfOffset(offs); Token t = getTokenListForLine(line); while (t!=null && t.isPaintable()) { if (t.containsPosition(offs)) { return t; } t = t.getNextToken(); } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } } return null; }
float width = 0; for (Token t=tokenList; t!=null&&t.isPaintable(); t=t.getNextToken()) { if (t.containsPosition(upTo)) { return width + t.getWidthUpTo(upTo-t.getOffset(), textArea, e, x0+width);
/** * Returns the last non-whitespace, non-comment token, before the * specified offset. * * @param doc The document. * @param offs The ending offset for the search. * @return The last non-whitespace, non-comment token, or <code>null</code> * if there isn't one. * @see #getPreviousImportantToken(RSyntaxDocument, int) * @see #getNextImportantToken(Token, RSyntaxTextArea, int) */ public static Token getPreviousImportantTokenFromOffs( RSyntaxDocument doc, int offs) { Element root = doc.getDefaultRootElement(); int line = root.getElementIndex(offs); Token t = doc.getTokenListForLine(line); // Check line containing offs Token target = null; while (t!=null && t.isPaintable() && !t.containsPosition(offs)) { if (!t.isCommentOrWhitespace()) { target = t; } t = t.getNextToken(); } // Check previous line(s) if (target==null) { target = RSyntaxUtilities.getPreviousImportantToken(doc, line-1); } return target; }
toMark = t; if (t.getEndOffset()==dot || t.containsPosition(dot)) { break;
if (t.containsPosition(offs)) {