protected Fold getClosestFold(RSyntaxTextArea textArea) { int offs = textArea.getCaretPosition(); int line = textArea.getCaretLineNumber(); FoldManager fm = textArea.getFoldManager(); Fold fold = fm.getFoldForLine(line); if (fold==null) { fold = fm.getDeepestOpenFoldContaining(offs); } return fold; }
int line = textArea.getCaretLineNumber(); Token t = doc.getTokenListForLine(line-1); t = t.getLastNonCommentNonWhitespaceToken();
@Override public void caretUpdate(CaretEvent e) { if (getFollowCaret()) { int line = textArea.getCaretLineNumber(); float percent = line / (float)(textArea.getLineCount()-1); textArea.computeVisibleRect(visibleRect); caretLineY = (int)(visibleRect.height*percent); if (caretLineY!=lastLineY) { repaint(0,lastLineY, getWidth(), 2); // Erase old position repaint(0,caretLineY, getWidth(), 2); lastLineY = caretLineY; } } }
/** * {@inheritDoc} */ @Override public Token getTokenToMark(RSyntaxTextArea textArea) { // Get the token at the caret position. int line = textArea.getCaretLineNumber(); Token tokenList = textArea.getTokenListForLine(line); Caret c = textArea.getCaret(); int dot = c.getDot(); Token t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot); if (t==null /* EOL */ || !isValidType(textArea, t) || RSyntaxUtilities.isNonWordChar(t)) { // Try to the "left" of the caret. dot--; try { if (dot>=textArea.getLineStartOffset(line)) { t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot); } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } } return t; }
rsta.getCaretLineNumber()); t = RSyntaxUtilities.getTokenAtOffset(t, dot-1); if (t!=null && t.getType()==Token.MARKUP_TAG_DELIMITER) {
public Point getPosicaoCursor() { return new Point(textArea.getCaretOffsetFromLineStart() + 1, textArea.getCaretLineNumber() + 1); }
Token t = textArea.getTokenListForLine(textArea.getCaretLineNumber()); Token toMark = null;
/** * Update the row:column label */ public void onScriptPanelCaretUpdate() { line = scriptPanel.getCaretLineNumber() + 1; character = scriptPanel.getCaretOffsetFromLineStart(); setStatusMessage(message); } /**
protected Fold getClosestFold(RSyntaxTextArea textArea) { int offs = textArea.getCaretPosition(); int line = textArea.getCaretLineNumber(); FoldManager fm = textArea.getFoldManager(); Fold fold = fm.getFoldForLine(line); if (fold==null) { fold = fm.getDeepestOpenFoldContaining(offs); } return fold; }
doc.getCurlyBracesDenoteCodeBlocks()) { int line = textArea.getCaretLineNumber(); Token t = doc.getTokenListForLine(line-1); t = t.getLastNonCommentNonWhitespaceToken();
int line = textArea.getCaretLineNumber(); Token t = doc.getTokenListForLine(line-1); t = t.getLastNonCommentNonWhitespaceToken();
public void caretUpdate(CaretEvent e) { if (getFollowCaret()) { int line = textArea.getCaretLineNumber(); float percent = line / ((float)textArea.getLineCount()); textArea.computeVisibleRect(visibleRect); caretLineY = (int)(visibleRect.height*percent); if (caretLineY!=lastLineY) { repaint(0,lastLineY, getWidth(), 2); // Erase old position repaint(0,caretLineY, getWidth(), 2); lastLineY = caretLineY; } } }
@Override public void caretUpdate(CaretEvent e) { if (getFollowCaret()) { int line = textArea.getCaretLineNumber(); float percent = line / (float)(textArea.getLineCount()-1); textArea.computeVisibleRect(visibleRect); caretLineY = (int)(visibleRect.height*percent); if (caretLineY!=lastLineY) { repaint(0,lastLineY, getWidth(), 2); // Erase old position repaint(0,caretLineY, getWidth(), 2); lastLineY = caretLineY; } } }
public static EscopoCursor localizar(RSyntaxTextArea textArea) { int linha = textArea.getCaretLineNumber() + 1; int coluna = textArea.getCaretOffsetFromLineStart(); try { String text = textArea.getText(0, textArea.getCaretPosition()); int nivel = getNivelEscopo(text); String nome = getNomeEscopo(text, nivel); return new EscopoCursor(nome, nivel, linha, coluna); } catch (BadLocationException ex) { ex.printStackTrace(System.out); } return new EscopoCursor("indefinido", 0, linha, coluna); }
/** * {@inheritDoc} */ @Override public Token getTokenToMark(RSyntaxTextArea textArea) { // Get the token at the caret position. int line = textArea.getCaretLineNumber(); Token tokenList = textArea.getTokenListForLine(line); Caret c = textArea.getCaret(); int dot = c.getDot(); Token t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot); if (t==null /* EOL */ || !isValidType(textArea, t) || RSyntaxUtilities.isNonWordChar(t)) { // Try to the "left" of the caret. dot--; try { if (dot>=textArea.getLineStartOffset(line)) { t = RSyntaxUtilities.getTokenAtOffset(tokenList, dot); } } catch (BadLocationException ble) { ble.printStackTrace(); // Never happens } } return t; }
int line = textArea.getCaretLineNumber(); Token toMark = null;
rsta.getCaretLineNumber()); t = RSyntaxUtilities.getTokenAtOffset(t, dot-1); if (t!=null && t.getType()==Token.MARKUP_TAG_DELIMITER) {
rsta.getCaretLineNumber()); t = RSyntaxUtilities.getTokenAtOffset(t, dot-1); if (t!=null && t.type==Token.MARKUP_TAG_DELIMITER) {
@Override public void actionPerformed(ActionEvent e) { RSyntaxTextArea textArea = (RSyntaxTextArea)getTextComponent(e); RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument(); Caret c = textArea.getCaret(); int dot = c.getDot(); // Get before "<" insertion boolean selection = dot!=c.getMark(); // Me too textArea.replaceSelection(">"); // Don't automatically complete a tag if there was a selection if (!selection && getAutoAddClosingTags()) { Token t = doc.getTokenListForLine(textArea.getCaretLineNumber()); t = RSyntaxUtilities.getTokenAtOffset(t, dot); if (t!=null && t.isSingleChar(Token.MARKUP_TAG_DELIMITER, '>')) { String tagName = discoverTagName(doc, dot); if (tagName!=null) { textArea.replaceSelection("</" + tagName + ">"); textArea.setCaretPosition(dot+1); } } } }
int linha = textArea.getCaretLineNumber(); int coluna = textArea.getCaretOffsetFromLineStart();