/** Gets the last non-blank and non-comment character on the given line. */ public int getRowLastValidChar(int offset) throws BadLocationException { return Utilities.getRowLastNonWhite(getDocument(), offset); }
/** * Gets the last non-blank and non-comment character on the given line. */ public int getRowLastValidChar(int offset) throws BadLocationException { return Utilities.getRowLastNonWhite(getDocument(), offset); }
private boolean isJustCommentOnLine(int rowStartOffset) throws BadLocationException { boolean result = false; int rowFirstNonWhite = Utilities.getRowFirstNonWhite(baseDocument, rowStartOffset); int rowLastNonWhite = Utilities.getRowLastNonWhite(baseDocument, rowStartOffset); for (OffsetRange commentRange : commentRanges) { if (commentRange.containsInclusive(rowFirstNonWhite) && commentRange.containsInclusive(rowLastNonWhite)) { result = true; break; } } return result; }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { Caret caret = target.getCaret(); try { int pos = Utilities.getRowLastNonWhite((BaseDocument)target.getDocument(), caret.getDot()); if (pos >= 0) { if (select) { caret.moveDot(pos); } else { caret.setDot(pos); } } } catch (BadLocationException e) { target.getToolkit().beep(); } } } }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { Caret caret = target.getCaret(); try { int pos = Utilities.getRowLastNonWhite((BaseDocument) target.getDocument(), caret.getDot()); if (pos >= 0) { if (select) { caret.moveDot(pos); } else { caret.setDot(pos); } } } catch (BadLocationException e) { target.getToolkit().beep(); } } } }
private boolean isUnclosedStringAtLineEnd(BaseDocument doc, int dotPos, FortranTokenId[] tokenIDs) { int lastNonWhiteOffset; try { lastNonWhiteOffset = Utilities.getRowLastNonWhite(doc, dotPos); } catch (BadLocationException e) { return false; } TokenSequence<FortranTokenId> cppTS = getTokenSequence(doc, lastNonWhiteOffset); if (cppTS != null) { return matchIDs(cppTS.token().id(), tokenIDs); } return false; }
static boolean isUnclosedStringAtLineEnd(BaseDocument doc, int dotPos, CppTokenId[] tokenIDs) { int lastNonWhiteOffset; try { lastNonWhiteOffset = Utilities.getRowLastNonWhite(doc, dotPos); } catch (BadLocationException e) { return false; } TokenSequence<TokenId> cppTS = cppTokenSequence(doc, lastNonWhiteOffset, false); if (cppTS != null) { return matchIDs(cppTS.token().id(), tokenIDs); } return false; }
public static String getContextLine(CsmFile csmFile, final int stToken, final int endToken) { CloneableEditorSupport ces = CsmUtilities.findCloneableEditorSupport(csmFile); StyledDocument stDoc = CsmUtilities.openDocument(ces); String displayText = null; if (stDoc instanceof BaseDocument) { BaseDocument doc = (BaseDocument) stDoc; try { int startLine = Utilities.getRowFirstNonWhite(doc, stToken); int endLine = Utilities.getRowLastNonWhite(doc, endToken) + 1; displayText = doc.getText(startLine, endLine - startLine); } catch (BadLocationException ex) { // skip } } return displayText; }
private boolean isScope(CsmReference ref) { CsmFile csmFile = ref.getContainingFile(); int stToken = ref.getStartOffset(); int endToken = ref.getEndOffset(); CloneableEditorSupport ces = CsmUtilities.findCloneableEditorSupport(csmFile); StyledDocument stDoc = CsmUtilities.openDocument(ces); if (stDoc instanceof BaseDocument) { BaseDocument doc = (BaseDocument) stDoc; try { int startLine = Utilities.getRowFirstNonWhite(doc, stToken); int endLine = Utilities.getRowLastNonWhite(doc, endToken) + 1; String restText = doc.getText(endToken, endLine - startLine).trim(); return restText.startsWith("::"); //NOI18N } catch (BadLocationException ex) { // skip } } return false; }
public static String getContextLineHtml(CsmFile csmFile, final int stToken, final int endToken, boolean tokenInBold) { CloneableEditorSupport ces = CsmUtilities.findCloneableEditorSupport(csmFile); StyledDocument stDoc = CsmUtilities.openDocument(ces); String displayText = null; if (stDoc instanceof BaseDocument) { BaseDocument doc = (BaseDocument) stDoc; try { int stOffset = stToken; int endOffset = endToken; int startLine = Utilities.getRowFirstNonWhite(doc, stOffset); int endLine = Utilities.getRowLastNonWhite(doc, endOffset) + 1; if (!tokenInBold) { stOffset = -1; endOffset = -1; } displayText = getLineHtml(startLine, endLine, stOffset, endOffset, doc); } catch (BadLocationException ex) { // skip } } return displayText; }
int textEnd = Utilities.getRowLastNonWhite(doc, textBegin)+1;
doc.insertString(Utilities.getRowLastNonWhite(doc, offset)+1, ERB_SUFFIX, null); // NOI18N doc.insertString(Utilities.getRowLastNonWhite(doc, offset)+1, ERB_SUFFIX, null); // NOI18N
private boolean isLineContinued(BaseDocument doc, int offset, int bracketBalance) throws BadLocationException { offset = Utilities.getRowLastNonWhite(doc, offset); if (offset == -1) { return false;
int lastNonWhitePos = Utilities.getRowLastNonWhite(doc, offset); if (lastNonWhitePos != -1) { int commentLen = suffix.length();
int lastNonWhitePos = Utilities.getRowLastNonWhite(doc, offset); if (lastNonWhitePos != -1) { int commentLen = suffix.length();
int lastNonWhitePos = Utilities.getRowLastNonWhite(doc, offset); if (lastNonWhitePos != -1) { int commentLen = suffix.length();
start = Utilities.getRowLastNonWhite(doc, start); if (start >= 0 && doc.getChars(start, 1)[0] != '{') { start++;
int endLine = org.netbeans.editor.Utilities.getRowLastNonWhite(doc, endOffset) + endLineOffset; displayText = CsmDisplayUtilities.getLineHtml(startLine, endLine, -1, -1, doc); } catch (BadLocationException ex) {
end = Utilities.getRowLastNonWhite(doc, end) + 1; break;
end = Utilities.getRowLastNonWhite(doc, end)+1; break;