/** * Determines the position in the model that is closest to the given view location in the row * below. The component given must have a size to compute the result. If the component doesn't * have a size a value of -1 will be returned. * * @param c the editor * @param offs the offset in the document >= 0 * @param x the X coordinate >= 0 * @return the position >= 0 if the request can be computed, otherwise a value of -1 will be * returned. * @exception BadLocationException if the offset is out of range */ public static final int getPositionBelow(RSyntaxTextArea c, int offs, float x, TabExpander e) throws BadLocationException { TokenOrientedView tov = (TokenOrientedView) e; Token token = tov.getTokenListForPhysicalLineBelow(offs); if (token == null) return -1; // A line containing only Token.NULL is an empty line. else if (token.type == Token.NULL) { int line = c.getLineOfOffset(offs); // Sure to be > c.getLineCount()-1 ?? return c.getLineStartOffset(line + 1); } else { return token.getListOffset(c, e, 0, x); } }
/** {@inheritDoc} */ public int yForLineContaining(Rectangle alloc, int offs) throws BadLocationException { if (isAllocationValid()) { // TODO: make cached Y_AXIS offsets valid even with folding enabled // to speed this back up! Rectangle r = (Rectangle) modelToView(offs, alloc, Bias.Forward); if (r != null) { if (host.isCodeFoldingEnabled()) { int line = host.getLineOfOffset(offs); FoldManager fm = host.getFoldManager(); if (fm.isLineHidden(line)) { return -1; } } return r.y; } } return -1; }