/** * Forces the current line highlight to be repainted. This hack is * necessary for those situations when the view (appearance) changes * but the caret's location hasn't (and thus the current line highlight * coordinates won't get changed). Examples of this are when * word wrap is toggled and when syntax styles are changed in an * <code>RSyntaxTextArea</code>. */ protected void forceCurrentLineHighlightRepaint() { // Check isShowing() to prevent BadLocationException // in constructor if linewrap is set to true. if (isShowing()) { // Changing previousCaretY makes us sure to get a repaint. previousCaretY = -1; // Trick it into checking for the need to repaint by firing // a false caret event. fireCaretUpdate(mouseListener); } }
/** * Overridden so we can tell when the text area is resized and update the * current-line highlight, if necessary (i.e., if it is enabled and if * lineWrap is enabled. * * @param e The component event about to be sent to all registered * <code>ComponentListener</code>s. */ @Override protected void processComponentEvent(ComponentEvent e) { // In line wrap mode, resizing the text area means that the caret's // "line" could change - not to a different logical line, but a // different physical one. So, here we force a repaint of the current // line's highlight if necessary. if (e.getID()==ComponentEvent.COMPONENT_RESIZED && getLineWrap() && getHighlightCurrentLine()) { previousCaretY = -1; // So we are sure to repaint. fireCaretUpdate(mouseListener); } super.processComponentEvent(e); }
/** * Notifies all listeners that a caret change has occurred. * * @param e The caret event. */ @Override protected void fireCaretUpdate(CaretEvent e) { // Decide whether we need to repaint the current line background. possiblyUpdateCurrentLineHighlightLocation(); // Now, if there is a highlighted region of text, allow them to cut // and copy. if (e!=null && e.getDot()!=e.getMark()) {// && !cutAction.isEnabled()) { cutAction.setEnabled(true); copyAction.setEnabled(true); } // Otherwise, if there is no highlighted region, don't let them cut // or copy. The condition here should speed things up, because this // way, we will only enable the actions the first time the selection // becomes nothing. else if (cutAction.isEnabled()) { cutAction.setEnabled(false); copyAction.setEnabled(false); } super.fireCaretUpdate(e); }
/** * Forces the current line highlight to be repainted. This hack is * necessary for those situations when the view (appearance) changes * but the caret's location hasn't (and thus the current line highlight * coordinates won't get changed). Examples of this are when * word wrap is toggled and when syntax styles are changed in an * <code>RSyntaxTextArea</code>. */ protected void forceCurrentLineHighlightRepaint() { // Check isShowing() to prevent BadLocationException // in constructor if linewrap is set to true. if (isShowing()) { // Changing previousCaretY makes us sure to get a repaint. previousCaretY = -1; // Trick it into checking for the need to repaint by firing // a false caret event. fireCaretUpdate(mouseListener); } }
/** * Forces the current line highlight to be repainted. This hack is * necessary for those situations when the view (appearance) changes * but the caret's location hasn't (and thus the current line highlight * coordinates won't get changed). Examples of this are when * word wrap is toggled and when syntax styles are changed in an * <code>RSyntaxTextArea</code>. */ protected void forceCurrentLineHighlightRepaint() { // Check isShowing() to prevent BadLocationException // in constructor if linewrap is set to true. if (isShowing()) { // Changing previousCaretY makes us sure to get a repaint. previousCaretY = -1; // Trick it into checking for the need to repaint by firing // a false caret event. fireCaretUpdate(mouseListener); } }
/** * Forces the current line highlight to be repainted. This hack is * necessary for those situations when the view (appearance) changes * but the caret's location hasn't (and thus the current line highlight * coordinates won't get changed). Examples of this are when * word wrap is toggled and when syntax styles are changed in an * <code>RSyntaxTextArea</code>. */ protected void forceCurrentLineHighlightRepaint() { // Check isShowing() to prevent BadLocationException // in constructor if linewrap is set to true. if (isShowing()) { // Changing previousCaretY makes us sure to get a repaint. previousCaretY = -1; // Trick it into checking for the need to repaint by firing // a false caret event. fireCaretUpdate(mouseListener); } }
/** * Overridden so we can tell when the text area is resized and update the * current-line highlight, if necessary (i.e., if it is enabled and if * lineWrap is enabled. * * @param e The component event about to be sent to all registered * <code>ComponentListener</code>s. */ protected void processComponentEvent(ComponentEvent e) { // In line wrap mode, resizing the text area means that the caret's // "line" could change - not to a different logical line, but a // different physical one. So, here we force a repaint of the current // line's highlight if necessary. if (e.getID()==ComponentEvent.COMPONENT_RESIZED && getLineWrap()==true && getHighlightCurrentLine()) { previousCaretY = -1; // So we are sure to repaint. fireCaretUpdate(mouseListener); } super.processComponentEvent(e); }
/** * Overridden so we can tell when the text area is resized and update the * current-line highlight, if necessary (i.e., if it is enabled and if * lineWrap is enabled. * * @param e The component event about to be sent to all registered * <code>ComponentListener</code>s. */ protected void processComponentEvent(ComponentEvent e) { // In line wrap mode, resizing the text area means that the caret's // "line" could change - not to a different logical line, but a // different physical one. So, here we force a repaint of the current // line's highlight if necessary. if (e.getID()==ComponentEvent.COMPONENT_RESIZED && getLineWrap()==true && getHighlightCurrentLine()) { previousCaretY = -1; // So we are sure to repaint. fireCaretUpdate(mouseListener); } super.processComponentEvent(e); }
/** * Overridden so we can tell when the text area is resized and update the * current-line highlight, if necessary (i.e., if it is enabled and if * lineWrap is enabled. * * @param e The component event about to be sent to all registered * <code>ComponentListener</code>s. */ @Override protected void processComponentEvent(ComponentEvent e) { // In line wrap mode, resizing the text area means that the caret's // "line" could change - not to a different logical line, but a // different physical one. So, here we force a repaint of the current // line's highlight if necessary. if (e.getID()==ComponentEvent.COMPONENT_RESIZED && getLineWrap() && getHighlightCurrentLine()) { previousCaretY = -1; // So we are sure to repaint. fireCaretUpdate(mouseListener); } super.processComponentEvent(e); }
/** * Notifies all listeners that a caret change has occurred. * * @param e The caret event. */ protected void fireCaretUpdate(CaretEvent e) { // Decide whether we need to repaint the current line background. possiblyUpdateCurrentLineHighlightLocation(); // Now, if there is a highlighted region of text, allow them to cut // and copy. if (e!=null && e.getDot()!=e.getMark()) {// && !cutAction.isEnabled()) { cutAction.setEnabled(true); copyAction.setEnabled(true); } // Otherwise, if there is no highlighted region, don't let them cut // or copy. The condition here should speed things up, because this // way, we will only enable the actions the first time the selection // becomes nothing. else if (cutAction.isEnabled()==true) { cutAction.setEnabled(false); copyAction.setEnabled(false); } super.fireCaretUpdate(e); }
/** * Notifies all listeners that a caret change has occurred. * * @param e The caret event. */ protected void fireCaretUpdate(CaretEvent e) { // Decide whether we need to repaint the current line background. possiblyUpdateCurrentLineHighlightLocation(); // Now, if there is a highlighted region of text, allow them to cut // and copy. if (e!=null && e.getDot()!=e.getMark()) {// && !cutAction.isEnabled()) { cutAction.setEnabled(true); copyAction.setEnabled(true); } // Otherwise, if there is no highlighted region, don't let them cut // or copy. The condition here should speed things up, because this // way, we will only enable the actions the first time the selection // becomes nothing. else if (cutAction.isEnabled()) { cutAction.setEnabled(false); copyAction.setEnabled(false); } super.fireCaretUpdate(e); }
/** * Notifies all listeners that a caret change has occurred. * * @param e The caret event. */ @Override protected void fireCaretUpdate(CaretEvent e) { // Decide whether we need to repaint the current line background. possiblyUpdateCurrentLineHighlightLocation(); // Now, if there is a highlighted region of text, allow them to cut // and copy. if (e!=null && e.getDot()!=e.getMark()) {// && !cutAction.isEnabled()) { cutAction.setEnabled(true); copyAction.setEnabled(true); } // Otherwise, if there is no highlighted region, don't let them cut // or copy. The condition here should speed things up, because this // way, we will only enable the actions the first time the selection // becomes nothing. else if (cutAction.isEnabled()) { cutAction.setEnabled(false); copyAction.setEnabled(false); } super.fireCaretUpdate(e); }