getVerticalScrollBar().setUnitIncrement(10);
initActions();
DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new GroovyFilter(doc));
textEditor.setDocument(doc);
// add a document listener, to hint whether the line number gutter has to be repainted
// when the number of lines changes
doc.addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent documentEvent) {
documentChangedSinceLastRepaint = true;
}
public void removeUpdate(DocumentEvent documentEvent) {
documentChangedSinceLastRepaint = true;
}
public void changedUpdate(DocumentEvent documentEvent) {
documentChangedSinceLastRepaint = true;
int width = 3 * Preferences.userNodeForPackage(Console.class).getInt("fontSize", 12);
numbersPanel.setPreferredSize(new Dimension(width, width));
}
});
// create and add the undo/redo manager
this.undoManager = new TextUndoManager();
doc.addUndoableEditListener(undoManager);
// add the undo actions
undoManager.addPropertyChangeListener(undoAction);
undoManager.addPropertyChangeListener(redoAction);
doc.addDocumentListener(undoAction);
doc.addDocumentListener(redoAction);
InputMap im = textEditor.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK, false);
im.put(ks, StructuredSyntaxResources.UNDO);
ActionMap am = textEditor.getActionMap();