/** * Constructs a new <code>ConfigurableCaret</code>. * * @param style The style to use when painting the caret. If this is * invalid, then {@link CaretStyle#THICK_VERTICAL_LINE_STYLE} is * used. */ public ConfigurableCaret(CaretStyle style) { seg = new Segment(); setStyle(style); selectionPainter = new ChangeableHighlightPainter(); pasteOnMiddleMouseClick = true; }
/** * Sets the caret to use in this text area. It is strongly encouraged to * use {@link ConfigurableCaret}s (which is used by default), or a * subclass, since they know how to render themselves differently when the * user toggles between insert and overwrite modes. * * @param caret The caret to use. * @see #setCaretStyle(int, CaretStyle) */ @Override public void setCaret(Caret caret) { super.setCaret(caret); if (carets!=null && // Called by setUI() before carets is initialized caret instanceof ConfigurableCaret) { ((ConfigurableCaret)caret).setStyle(carets[getTextMode()]); } }
/** * Sets the style of caret used when in insert or overwrite mode. * * @param mode Either {@link #INSERT_MODE} or {@link #OVERWRITE_MODE}. * @param style The style for the caret. * @see ConfigurableCaret */ public void setCaretStyle(int mode, CaretStyle style) { if (style==null) { style = CaretStyle.THICK_VERTICAL_LINE_STYLE; } carets[mode] = style; if (mode==getTextMode() && getCaret() instanceof ConfigurableCaret) { // Will repaint the caret if necessary. ((ConfigurableCaret)getCaret()).setStyle(style); } }
/** * Sets the text mode for this editor pane. If the currently installed * caret is an instance of {@link ConfigurableCaret}, it will be * automatically updated to render itself appropriately for the new text * mode. * * @param mode Either {@link #INSERT_MODE} or {@link #OVERWRITE_MODE}. * @see #getTextMode() */ public void setTextMode(int mode) { if (mode!=INSERT_MODE && mode!=OVERWRITE_MODE) { mode = INSERT_MODE; } if (textMode != mode) { Caret caret = getCaret(); if (caret instanceof ConfigurableCaret) { ((ConfigurableCaret)caret).setStyle(carets[mode]); } textMode = mode; // Prevent the caret from blinking while e.g. holding down the // Insert key to toggle insert/overwrite modes caret.setVisible(false); caret.setVisible(true); } }
/** * Sets the text mode for this editor pane. * * @param mode Either {@link #INSERT_MODE} or {@link #OVERWRITE_MODE}. */ public void setTextMode(int mode) { if (mode!=INSERT_MODE && mode!=OVERWRITE_MODE) mode = INSERT_MODE; if (textMode != mode) { ConfigurableCaret cc = (ConfigurableCaret)getCaret(); cc.setStyle(carets[mode]); textMode = mode; } }
/** * Deserializes a caret. This is overridden to read the caret's style. * * @param s The stream to read from. * @throws ClassNotFoundException * @throws IOException */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); setStyle(s.readInt()); seg = new Segment(); }
/** * Sets the text mode for this editor pane. * * @param mode Either {@link #INSERT_MODE} or {@link #OVERWRITE_MODE}. */ public void setTextMode(int mode) { if (mode!=INSERT_MODE && mode!=OVERWRITE_MODE) mode = INSERT_MODE; if (textMode != mode) { ConfigurableCaret cc = (ConfigurableCaret)getCaret(); cc.setStyle(carets[mode]); textMode = mode; } }
/** * Deserializes a caret. This is overridden to read the caret's style. * * @param s The stream to read from. * @throws ClassNotFoundException * @throws IOException */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { s.defaultReadObject(); setStyle(s.readInt()); seg = new Segment(); }
/** * Constructs a new <code>ConfigurableCaret</code>. * * @param style The style to use when painting the caret. If this is * invalid, then {@link #VERTICAL_LINE_STYLE} is used. */ public ConfigurableCaret(int style) { seg = new Segment(); setStyle(style); selectionPainter = new ChangeableHighlightPainter(); }
/** * Constructs a new <code>ConfigurableCaret</code>. * * @param style The style to use when painting the caret. If this is * invalid, then {@link #VERTICAL_LINE_STYLE} is used. */ public ConfigurableCaret(int style) { seg = new Segment(); setStyle(style); selectionPainter = new ChangeableHighlightPainter(); }
/** * Constructs a new <code>ConfigurableCaret</code>. * * @param style The style to use when painting the caret. If this is * invalid, then {@link CaretStyle#THICK_VERTICAL_LINE_STYLE} is * used. */ public ConfigurableCaret(CaretStyle style) { seg = new Segment(); setStyle(style); selectionPainter = new ChangeableHighlightPainter(); pasteOnMiddleMouseClick = true; }
/** * This method is overridden to make sure that instances of * <code>RTextArea</code> only use {@link ConfigurableCaret}s. * To set the style of caret (vertical line, block, etc.) used for * insert or overwrite mode, use {@link #setCaretStyle(int, int)}. * * @param caret The caret to use. If this is not an instance of * <code>ConfigurableCaret</code>, an exception is thrown. * @throws IllegalArgumentException If the specified caret is not an * <code>ConfigurableCaret</code>. * @see #setCaretStyle(int, int) */ public void setCaret(Caret caret) { if (!(caret instanceof ConfigurableCaret)) { throw new IllegalArgumentException( "RTextArea needs ConfigurableCaret"); } super.setCaret(caret); if (carets!=null) { // Called by setUI() before carets is initialized ((ConfigurableCaret)caret).setStyle(carets[getTextMode()]); } }
/** * Sets the style of caret used when in insert or overwrite mode. * * @param mode Either {@link #INSERT_MODE} or {@link #OVERWRITE_MODE}. * @param style The style for the caret (such as * {@link ConfigurableCaret#VERTICAL_LINE_STYLE}). * @see org.fife.ui.rtextarea.ConfigurableCaret */ public void setCaretStyle(int mode, int style) { style = (style>=ConfigurableCaret.MIN_STYLE && style<=ConfigurableCaret.MAX_STYLE ? style : ConfigurableCaret.THICK_VERTICAL_LINE_STYLE); carets[mode] = style; if (mode==getTextMode()) { // Will repaint the caret if necessary. ((ConfigurableCaret)getCaret()).setStyle(style); } }
/** * This method is overridden to make sure that instances of * <code>RTextArea</code> only use {@link ConfigurableCaret}s. * To set the style of caret (vertical line, block, etc.) used for * insert or overwrite mode, use {@link #setCaretStyle(int, int)}. * * @param caret The caret to use. If this is not an instance of * <code>ConfigurableCaret</code>, an exception is thrown. * @throws IllegalArgumentException If the specified caret is not an * <code>ConfigurableCaret</code>. * @see #setCaretStyle(int, int) */ public void setCaret(Caret caret) { if (!(caret instanceof ConfigurableCaret)) { throw new IllegalArgumentException( "RTextArea needs ConfigurableCaret"); } super.setCaret(caret); if (carets!=null) { // Called by setUI() before carets is initialized ((ConfigurableCaret)caret).setStyle(carets[getTextMode()]); } }
/** * Sets the caret to use in this text area. It is strongly encouraged to * use {@link ConfigurableCaret}s (which is used by default), or a * subclass, since they know how to render themselves differently when the * user toggles between insert and overwrite modes. * * @param caret The caret to use. * @see #setCaretStyle(int, CaretStyle) */ @Override public void setCaret(Caret caret) { super.setCaret(caret); if (carets!=null && // Called by setUI() before carets is initialized caret instanceof ConfigurableCaret) { ((ConfigurableCaret)caret).setStyle(carets[getTextMode()]); } }
/** * Sets the style of caret used when in insert or overwrite mode. * * @param mode Either {@link #INSERT_MODE} or {@link #OVERWRITE_MODE}. * @param style The style for the caret (such as * {@link ConfigurableCaret#VERTICAL_LINE_STYLE}). * @see org.fife.ui.rtextarea.ConfigurableCaret */ public void setCaretStyle(int mode, int style) { style = (style>=ConfigurableCaret.MIN_STYLE && style<=ConfigurableCaret.MAX_STYLE ? style : ConfigurableCaret.THICK_VERTICAL_LINE_STYLE); carets[mode] = style; if (mode==getTextMode()) { // Will repaint the caret if necessary. ((ConfigurableCaret)getCaret()).setStyle(style); } }
/** * Sets the style of caret used when in insert or overwrite mode. * * @param mode Either {@link #INSERT_MODE} or {@link #OVERWRITE_MODE}. * @param style The style for the caret. * @see ConfigurableCaret */ public void setCaretStyle(int mode, CaretStyle style) { if (style==null) { style = CaretStyle.THICK_VERTICAL_LINE_STYLE; } carets[mode] = style; if (mode==getTextMode() && getCaret() instanceof ConfigurableCaret) { // Will repaint the caret if necessary. ((ConfigurableCaret)getCaret()).setStyle(style); } }
/** * Sets the text mode for this editor pane. If the currently installed * caret is an instance of {@link ConfigurableCaret}, it will be * automatically updated to render itself appropriately for the new text * mode. * * @param mode Either {@link #INSERT_MODE} or {@link #OVERWRITE_MODE}. * @see #getTextMode() */ public void setTextMode(int mode) { if (mode!=INSERT_MODE && mode!=OVERWRITE_MODE) { mode = INSERT_MODE; } if (textMode != mode) { Caret caret = getCaret(); if (caret instanceof ConfigurableCaret) { ((ConfigurableCaret)caret).setStyle(carets[mode]); } textMode = mode; // Prevent the caret from blinking while e.g. holding down the // Insert key to toggle insert/overwrite modes caret.setVisible(false); caret.setVisible(true); } }