public void caretUpdate(CaretEvent e) { // when the cursor moves on _textView // this method will be called. Then, we // must determine what the line number is // and update the line number view Element root = textView.getDocument().getDefaultRootElement(); int line = root.getElementIndex(e.getDot()); root = root.getElement(line); int col = root.getElementIndex(e.getDot()); lineNumberView.setText(line + ":" + col); // if text is selected then enable copy and cut boolean isSelection = e.getDot() != e.getMark(); copyAction.setEnabled(isSelection); cutAction.setEnabled(isSelection); }
public void caretUpdate(CaretEvent e) { try { setLineCount(textArea.getLineOfOffset(e.getDot()) + 1); } catch (BadLocationException blx) { logger.warn("BadLocationException: " + blx.getMessage()); } }
public void caretUpdate(CaretEvent e) { int dot = e.getDot(); int mark = e.getMark(); if (dot == mark) { // no selection if (caretValue != dot) { caretValue = dot; } if (debug && caretCmd != null) System.out.println("caret @: " + caretValue); if (hasFocus()) { // Update widget and vnmr variables every time something // happens in the widget sendTextCmd(); sendCaretCmd(); } return; } }
@Override public void caretUpdate(CaretEvent event) { doCaretUpdate(event.getDot(), event.getMark()); }
/** * Caret Listener * * @param e event */ public void caretUpdate(CaretEvent e) { log.finest("Dot=" + e.getDot() + ",Last=" + m_lastDot + ", Mark=" + e.getMark()); // Selection if (e.getDot() != e.getMark()) { m_lastDot = e.getDot(); return; } // // Is the current position a fixed character? if (e.getDot() + 1 > m_mask.length() || m_mask.charAt(e.getDot()) != DELIMITER) { m_lastDot = e.getDot(); return; } // Direction? int newDot = -1; if (m_lastDot > e.getDot()) // <- newDot = e.getDot() - 1; else // -> (or same) newDot = e.getDot() + 1; if (e.getDot() == 0) // first newDot = 1; else if (e.getDot() == m_mask.length() - 1) // last newDot = e.getDot() - 1; // log.fine( "OnFixedChar=" + m_mask.charAt(e.getDot()) + ", newDot=" + newDot + ", last=" + m_lastDot); // m_lastDot = e.getDot(); if (newDot >= 0 && newDot < getText().length()) m_tc.setCaretPosition(newDot); } // caretUpdate