public void mouseMoved(MouseEvent e) { int k = html.viewToModel(e.getPoint()); if (html.hasFocus() && html.getSelectionStart() <= k && k < html.getSelectionEnd()) { setMessage("(on selection)", MOVE); return; } String s = text.getText(); // ""; int m = s.length(); // html.getDocument().getLength(); /*try { s = html.getText(0, m); } catch (BadLocationException x) { setMessage("BadLocation "+m, TEXT); return; } */ if (!Character.isLetter(s.charAt(k))) { setMessage("(not a letter)", TEXT); return; } selB = k; selE = k + 1; while (!Character.isWhitespace(s.charAt(selB - 1))) selB--; while (!Character.isWhitespace(s.charAt(selE))) selE++; setMessage(selB + "-" + selE, HAND); word = ""; for (int i = selB; i < selE; i++) if (Character.isLetter(s.charAt(i))) word += s.charAt(i); html.setToolTipText(word); }
public void delete() { try { editor .getDocument() .remove( editor.getSelectionStart(), editor.getSelectionEnd() - editor.getSelectionStart()); } catch (BadLocationException ex) { // GUIPrism.getGUI().getMultiLogger().logMessage(PrismLogLevel.PRISM_ERROR, ex.getMessage()); } }
public void findNext() { EditWindow currentWindow = editor.getActiveWindow(); if (currentWindow == null || getFindTextField().getText().length() == 0) { // launch error dialog? return; } Pattern p = getCurrentPattern(); JEditorPane editorPane = currentWindow.getEditorPane(); // for some reason, getText() trims off \r but the indexes in // the editor pane don't. String text = editorPane.getText().replaceAll("\\r", ""); Matcher m = p.matcher(text); int index = editorPane.getSelectionEnd(); if (!(m.find(index) || m.find())) { return; } editorPane.setSelectionStart(m.start()); editorPane.setSelectionEnd(m.end()); }