/** DoAction */ public void doAction() { ScilabDocument doc = (ScilabDocument) getEditor().getTextPane().getDocument(); doc.mergeEditsBegin(); if (!getEditor().getTextPane().removeColumnSelection()) { getEditor() .getTextPane() .getActionMap() .get(DefaultEditorKit.deleteNextCharAction) .actionPerformed(null); } doc.mergeEditsEnd(); }
/** * actionPerformed * * @param ev ActionEvent */ public void actionPerformed(ActionEvent ev) { ScilabEditorPane sep = (ScilabEditorPane) ev.getSource(); ScilabDocument doc = (ScilabDocument) sep.getDocument(); int pos = sep.getCaretPosition(); Element root = doc.getDefaultRootElement(); int end = root.getElement(root.getElementIndex(pos)).getEndOffset() - 1; String str = ""; try { str = doc.getText(pos, end - pos); } catch (BadLocationException e) { System.err.println(e); } if (str.matches("[ \\t]+(then|do)")) { sep.setCaretPosition(end); } super.actionPerformed(ev); sep.getIndentManager().indentDoc(sep.getCaretPosition() - 1); }