/** * Returns the default caret for an <code>RTextArea</code>. This caret is * capable of displaying itself differently for insert/overwrite modes. * * @return The caret. */ @Override protected Caret createCaret() { Caret caret = new ConfigurableCaret(); caret.setBlinkRate(500); return caret; }
RTextArea textArea = getTextArea(); int nclicks = e.getClickCount(); switch (nclicks) { case 0: selectWord(e); selectedWordEvent = null; break; getPasteOnMiddleMouseClick()) { if (nclicks == 1 && textArea.isEditable() && textArea.isEnabled()) { adjustCaret(e); TransferHandler th = c.getTransferHandler(); if (th != null) { adjustFocus(true);
/** * Gets the text editor component that this caret is bound to. * * @return The <code>RTextArea</code>. */ protected RTextArea getTextArea() { return (RTextArea)getComponent(); }
/** * Adjusts the caret location based on the MouseEvent. */ private void adjustCaret(MouseEvent e) { if ((e.getModifiers()&ActionEvent.SHIFT_MASK)!=0 && getDot()!=-1) { moveCaret(e); } else { positionCaret(e); } }
/** * Toggles whether this caret should always be visible (as opposed to * blinking, or not visible when the editor's window is not focused). * This can be used by popup windows that want the caret's location * to still be visible for contextual purposes while they are displayed. * * @param alwaysVisible Whether this caret should always be visible. * @see #isAlwaysVisible() */ public void setAlwaysVisible(boolean alwaysVisible) { if (alwaysVisible != this.alwaysVisible) { this.alwaysVisible = alwaysVisible; if (!isVisible()) { // Force painting of caret since super class's "flasher" timer // won't fire when the window doesn't have focus repaint(); } } }
if (isVisible() || alwaysVisible) { RTextArea textArea = getTextArea(); g.setColor(textArea.getCaretColor()); TextUI mapper = textArea.getUI(); Rectangle r = mapper.modelToView(textArea, getDot()); validateWidth(r); !contains(r.x, r.y, r.width, r.height)) { Rectangle clip = g.getClipBounds(); if (clip != null && !clip.contains(this)) { repaint(); damage(r);
if (isVisible()) { RTextArea textArea = getTextArea(); g.setColor(textArea.getCaretColor()); TextUI mapper = textArea.getUI(); Rectangle r = mapper.modelToView(textArea, getDot()); validateWidth(r);
RTextArea textArea = getTextArea(); textArea.getDocument().getText(getDot(),1, seg); Font font = textArea.getFont(); FontMetrics fm = textArea.getFontMetrics(font);
/** * Sets whether the edges of selections are rounded in this text area. * This method fires a property change of type * {@link #ROUNDED_SELECTION_PROPERTY}. * * @param rounded Whether selection edges should be rounded. * @see #getRoundedSelectionEdges() */ public void setRoundedSelectionEdges(boolean rounded) { if (roundedSelectionEdges!=rounded) { roundedSelectionEdges = rounded; ConfigurableCaret cc = (ConfigurableCaret)getCaret(); cc.setRoundedSelectionEdges(rounded); if (cc.getDot()!=cc.getMark()) { // ie, if there is a selection repaint(); } firePropertyChange(ROUNDED_SELECTION_PROPERTY, !rounded, rounded); } }
/** * Returns whether this caret's selection uses rounded edges. * * @return Whether this caret's edges are rounded. * @see #setRoundedSelectionEdges */ public boolean getRoundedSelectionEdges() { return ((ChangeableHighlightPainter)getSelectionPainter()). getRoundedEdges(); }
/** * Selects word based on a mouse event. */ private void selectWord(MouseEvent e) { if (selectedWordEvent != null && selectedWordEvent.getX() == e.getX() && selectedWordEvent.getY() == e.getY()) { // We've already the done selection for this. return; } Action a = null; RTextArea textArea = getTextArea(); ActionMap map = textArea.getActionMap(); if (map != null) { a = map.get(RTextAreaEditorKit.selectWordAction); } if (a == null) { if (selectWord == null) { selectWord = new RTextAreaEditorKit.SelectWordAction(); } a = selectWord; } a.actionPerformed(new ActionEvent(textArea, ActionEvent.ACTION_PERFORMED, null, e.getWhen(), e.getModifiers())); selectedWordEvent = e; }
if (isVisible() || alwaysVisible) { RTextArea textArea = getTextArea(); g.setColor(textArea.getCaretColor()); TextUI mapper = textArea.getUI(); Rectangle r = mapper.modelToView(textArea, getDot()); validateWidth(r); !contains(r.x, r.y, r.width, r.height)) { Rectangle clip = g.getClipBounds(); if (clip != null && !clip.contains(this)) { repaint(); damage(r);
/** * Adjusts the caret location based on the MouseEvent. */ private void adjustCaret(MouseEvent e) { if ((e.getModifiers()&ActionEvent.SHIFT_MASK)!=0 && getDot()!=-1) moveCaret(e); else positionCaret(e); }
if (isVisible()) { RTextArea textArea = getTextArea(); g.setColor(textArea.getCaretColor()); TextUI mapper = textArea.getUI(); Rectangle r = mapper.modelToView(textArea, getDot()); validateWidth(r);
@Override public void setDot(FilterBypass fb, int dot, Position.Bias bias) { RTextArea textArea = getTextArea(); if (textArea instanceof RSyntaxTextArea) { RSyntaxTextArea rsta = (RSyntaxTextArea)getTextArea(); if (rsta.isCodeFoldingEnabled()) { int lastDot = getDot(); FoldManager fm = rsta.getFoldManager(); int line = 0;
/** * Sets whether the edges of selections are rounded in this text area. * This method fires a property change of type * {@link #ROUNDED_SELECTION_PROPERTY}. * * @param rounded Whether selection edges should be rounded. * @see #getRoundedSelectionEdges() */ public void setRoundedSelectionEdges(boolean rounded) { if (roundedSelectionEdges!=rounded) { roundedSelectionEdges = rounded; ConfigurableCaret cc = (ConfigurableCaret)getCaret(); cc.setRoundedSelectionEdges(rounded); if (cc.getDot()!=cc.getMark()) { // ie, if there is a selection repaint(); } firePropertyChange(ROUNDED_SELECTION_PROPERTY, !rounded, rounded); } }
/** * Sets whether this caret's selection should have rounded edges. * * @param rounded Whether it should have rounded edges. * @see #getRoundedSelectionEdges() */ public void setRoundedSelectionEdges(boolean rounded) { ((ChangeableHighlightPainter)getSelectionPainter()). setRoundedEdges(rounded); }
/** * Adjusts the focus, if necessary. * * @param inWindow if true indicates requestFocusInWindow should be used */ private void adjustFocus(boolean inWindow) { RTextArea textArea = getTextArea(); if ((textArea != null) && textArea.isEnabled() && textArea.isRequestFocusEnabled()) { if (inWindow) { textArea.requestFocusInWindow(); } else { textArea.requestFocus(); } } }
/** * Toggles whether this caret should always be visible (as opposed to * blinking, or not visible when the editor's window is not focused). * This can be used by popup windows that want the caret's location * to still be visible for contextual purposes while they are displayed. * * @param alwaysVisible Whether this caret should always be visible. * @see #isAlwaysVisible() */ public void setAlwaysVisible(boolean alwaysVisible) { if (alwaysVisible != this.alwaysVisible) { this.alwaysVisible = alwaysVisible; if (!isVisible()) { // Force painting of caret since super class's "flasher" timer // won't fire when the window doesn't have focus repaint(); } } }
RTextArea textArea = getTextArea(); int nclicks = e.getClickCount(); switch (nclicks) { case 0: selectWord(e); selectedWordEvent = null; break; getPasteOnMiddleMouseClick()) { if (nclicks == 1 && textArea.isEditable() && textArea.isEnabled()) { adjustCaret(e); TransferHandler th = c.getTransferHandler(); if (th != null) { adjustFocus(true);