consoleOutputText.setBackground(color);
consoleInputText.setBackground(color);
}
}
});
consoleOutputText.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
if (e.stateMask == 0 && e.character != '\0') {
consoleInputText.setFocus();
consoleInputText.append("" + e.character);
consoleInputText.setCaretOffset(consoleInputText.getText().length());
}
e.doit = true;
}
});
final IPreferenceStore store = ErlideUIPlugin.getDefault().getPreferenceStore();
final IColorManager colorManager = new ColorManager();
consoleOutputViewer.setDocument(fDoc);
consoleOutputViewer.configure(new ErlangConsoleSourceViewerConfiguration(store,
colorManager, backend));
consoleInputViewer = new SourceViewer(sashForm, null, SWT.MULTI | SWT.WRAP
| SWT.V_SCROLL);
consoleInputText = consoleInputViewer.getTextWidget();
consoleInputViewer.setDocument(new Document());
consoleInputViewer.configure(new ErlangConsoleSourceViewerConfiguration(store,
colorManager, backend));
sashForm.setWeights(new int[] { 2, 1 });
final Label helpLabel = new Label(composite, SWT.NONE);
helpLabel
.setText("To send the input to the console: press Enter at the end of an expression."
+ "Ctrl/Cmd-arrows navigate the input history.");
helpLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final ModifyListener modifyListener = new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
final String consoleText = trimInput(consoleInputText.getText());
final boolean atEndOfInput = consoleText.endsWith(".")
&& consoleInputText.getCaretOffset() >= consoleText.length();
if (atEndOfInput) {
final boolean inputComplete = isInputComplete();
if (inputComplete) {
consoleInputText.setBackground(bgColor_Ok);
}
} else {
consoleInputText.setBackground(bgcolor);
}
}
};
// consoleInput.addModifyListener(modifyListener);
consoleInputText.addCaretListener(new CaretListener() {
@Override
public void caretMoved(final CaretEvent event) {
modifyListener.modifyText(null);
}
});
consoleInputText.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
final boolean ctrlOrCommandPressed = (e.stateMask & SWT.MOD1) == SWT.MOD1;
final String conText = trimInput(consoleInputText.getText());
final boolean atEndOfInput = consoleInputText.getCaretOffset() >= conText