final Spacer.OneWaySpacerComparator spacerFinder = new Spacer.OneWaySpacerComparator();
defaultMode.addShortcut(new EventShortcut(ModifierKeys.ACTION, 'i') {
@Override
public boolean event(InputScheme scheme, SignalEvent event) {
final Editor editor = scheme.getInputController().getEditor();
spacers.add(editor.getBuffer().addSpacer(
new LineInfo(editor.getSelection().getCursorLine(), editor.getSelection()
.getCursorLineNumber()), new Random().nextInt(500) + 1));
return true;
}
});
defaultMode.addShortcut(new EventShortcut(ModifierKeys.ACTION, 'd') {
@Override
public boolean event(InputScheme scheme, SignalEvent event) {
final Editor editor = scheme.getInputController().getEditor();
spacerFinder.setValue(editor.getSelection().getCursorLineNumber());
int spacerIndex = spacers.findInsertionIndex(spacerFinder, false);
if (spacerIndex >= 0) {
editor.getBuffer().removeSpacer(spacers.get(spacerIndex));
spacers.remove(spacerIndex);
}
return true;
}
});
defaultMode.addShortcut(new EventShortcut(ModifierKeys.ACTION, 'u') {
@Override
public boolean event(InputScheme scheme, SignalEvent event) {
final Editor editor = scheme.getInputController().getEditor();
spacerFinder.setValue(editor.getSelection().getCursorLineNumber());
int spacerIndex = spacers.findInsertionIndex(spacerFinder, false);
if (spacerIndex >= 0) {
// spacers.get(spacerIndex).setHeight(new Random().nextInt(500)+1);
}
return true;
}
});
}
if (ENABLE_ANIMATION_CONTROL_KEYS) {
defaultMode.addShortcut(new EventShortcut(ModifierKeys.ACTION, 'e') {
@Override
public boolean event(InputScheme scheme, SignalEvent event) {
final Editor editor = scheme.getInputController().getEditor();
editor.setAnimationEnabled(true);
return true;
}
});
defaultMode.addShortcut(new EventShortcut(ModifierKeys.ACTION, 'd') {
@Override
public boolean event(InputScheme scheme, SignalEvent event) {
final Editor editor = scheme.getInputController().getEditor();
editor.setAnimationEnabled(false);
return true;
}
});
}