field.getCaret().setDot( dot );
/** * Makes the caret's dot and mark the same location so that, for the * next search in the specified direction, a match will be found even * if it was within the original dot and mark's selection. * * @param textArea The text area. * @param forward Whether the search will be forward through the * document (<code>false</code> means backward). * @return The new dot and mark position. */ private static int makeMarkAndDotEqual(JTextArea textArea, boolean forward) { Caret c = textArea.getCaret(); int val = forward ? Math.min(c.getDot(), c.getMark()) : Math.max(c.getDot(), c.getMark()); c.setDot(val); return val; }
@Override public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { if (!textArea.isEditable() || !textArea.isEnabled()) { UIManager.getLookAndFeel().provideErrorFeedback(textArea); return; } try { Caret c = textArea.getCaret(); int caretPos = c.getDot(); Document doc = textArea.getDocument(); Element map = doc.getDefaultRootElement(); int lineCount = map.getElementCount(); int line = map.getElementIndex(caretPos); if (line==lineCount-1) { UIManager.getLookAndFeel(). provideErrorFeedback(textArea); return; } Element lineElem = map.getElement(line); caretPos = lineElem.getEndOffset() - 1; c.setDot(caretPos); // Gets rid of any selection. doc.remove(caretPos, 1); // Should be '\n'. } catch (BadLocationException ble) { /* Shouldn't ever happen. */ ble.printStackTrace(); } textArea.requestFocusInWindow(); }
/** * Sets the text no title. * * @param text the new text no title */ // Set the text. public void setTextNoTitle(String text) { this.textArea.setText(text); this.textArea.getCaret().setDot(0); this.isDirty = false; }
private void showUsage(Generator generator) { // Look up the Rails directory and read the USAGE file, then stick // it into the usageText. String usage = generator.getUsage(project); if (usage != null) { usageText.setText(usage); usageText.getCaret().setDot(0); } else { usageText.setText(""); } }
public void run() { // XXX #28191: some other piece of code should underline these, etc. StringWriter wr = new StringWriter(); current.printStackTrace(new PrintWriter(wr, true)); output.setText(wr.toString()); output.getCaret().setDot(0); output.requestFocus (); } });
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { Caret caret = target.getCaret(); int dot = 0; // begin of document if (select) { caret.moveDot(dot); } else { caret.setDot(dot); } } } }
public void actionPerformed(ActionEvent evt, JTextComponent target) { if (target != null) { Caret caret = target.getCaret(); int dot = 0; // begin of document if (select) { caret.moveDot(dot); } else { caret.setDot(dot); } } } }
public boolean substituteText(JTextComponent c, int a, int b, boolean shift) { replaceText(c, "<" + baseText + (shift ? " >" : ">")); // NOI18N if (shift) { Caret caret = c.getCaret(); caret.setDot(caret.getDot() - 1); } return !shift; // flag == false; }
public boolean substituteText( JTextComponent c, int a, int b, boolean shift ) { replaceText( c, baseText + "=\"\"" ); //NOI18N if( shift ) { Caret caret = c.getCaret(); caret.setDot( caret.getDot() - 1 ); } return false; // always refresh } }
@Override public void remove(int offs, int len) throws BadLocationException { super.remove(offs, len); dEditor.getTextField().getCaret().setDot(offs); } });
/** * called to restore the state of a component * because a drop was not performed. */ protected void restoreComponentState(JComponent comp) { JTextComponent c = (JTextComponent) comp; Caret caret = c.getCaret(); caret.setDot(mark); caret.moveDot(dot); caret.setVisible(visible); }
public static void selectLineAtCaret( JTextComponent editor ) { int lineStart = getLineStart( editor.getText(), editor.getCaretPosition() ); int lineEnd = getLineEnd( editor.getText(), editor.getCaretPosition() ); if( lineEnd < editor.getText().length() ) { lineEnd++; } editor.getCaret().setDot( lineEnd ); editor.getCaret().moveDot( lineStart ); }
@Override public void afterInsert(Context context) throws BadLocationException { if (postShift) { Caret caret = context.getComponent().getCaret(); caret.setDot(context.getCaretOffset() + 1); } }
@Override public void actionPerformed(ActionEvent e) { ParamInstance pi = paramListModel.getParamInstance(listValues.getSelectedIndex()); if (pi != null) { Caret caret = textAreaRequest.getCaret(); caret.setSelectionVisible(true); caret.setDot(pi.getValueStart()); caret.moveDot(pi.getValueEnd()); } } });
/** * Forces the scroll of text area. */ private void scrollDown() { int pos = textArea.getDocument().getEndPosition().getOffset(); textArea.getCaret().setDot(pos); textArea.requestFocus(); } }
private void select(SelectionInfo selectionInfo) { Caret caret = target.getCaret(); markIgnoreNextCaretUpdate(); caret.setDot(selectionInfo.getStartOffset()); markIgnoreNextCaretUpdate(); caret.moveDot(selectionInfo.getEndOffset()); }
private void select(SelectionInfo selectionInfo) { Caret caret = target.getCaret(); markIgnoreNextCaretUpdate(); caret.setDot(selectionInfo.getStartOffset()); markIgnoreNextCaretUpdate(); caret.moveDot(selectionInfo.getEndOffset()); }
private void setSelection( Point point ) { Rectangle visibleRect = _gsEditor.getEditor().getVisibleRect(); _gsEditor.getEditor().getCaret().setDot( point.x ); _gsEditor.getEditor().getCaret().moveDot( point.y ); _gsEditor.getEditor().scrollRectToVisible( visibleRect ); }