topLevelResultsList = new JList(matches);
detailHelpAdapter = new autoCompleteListHandler();
topLevelResultsList.addKeyListener(detailHelpAdapter);
topLevelResultsList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent lse) {
String selValue = topLevelResultsList.getSelectedValue().toString();
selValue = selValue.substring(selValue.indexOf(GlobalValues.smallNameFullPackageSeparator)+3, selValue.length());
GlobalValues.selectedStringForAutoCompletion = selValue;
}
}
);
GlobalValues.autoCompletionFrame = new AutoCompletionFrame("scalalabConsole AutoCompletion ( F1 for detailed help on the selected entry)");
GlobalValues.autoCompletionFrame.displayMatches(topLevelResultsList);
break;
case KeyEvent.VK_ESCAPE:
int i,j, lc;
// Erase the current editing line
e.consume();
if (GlobalValues.commandLineModeOn)
((scalalabConsole)inputCons).clearCommandLine();
break;
case KeyEvent.VK_F5:
GlobalValues.consoleOutputWindow.output.setText("");
break;
case KeyEvent.VK_F10:
inputConsole = (Console)e.getSource();
e.consume();
// get the text on the current line
text = inputConsole.getSelectedText();
if (text != null) {
String inspectCommand = "scalaSciCommands.BasicCommands.inspectg("+text+") ";
GlobalValues.globalInterpreter.interpret(inspectCommand);
}
break;
case KeyEvent.VK_F6:
scalaExec.Interpreter.GlobalValues.autoCompletionWorkspace = new scalaExec.gui.AutoCompletionWorkspace();
inputConsole = (Console)e.getSource();
e.consume();
// get the text on the current line
text = inputConsole.getText();
// get the starting point of the current command start
lastNewLineCommandStartIdx = text.lastIndexOf(GlobalValues.scalalabPromptChar)+1;
endCommandChar = ';'; // character denoting the end of the previous command
previousSemicolonCommandStartIdx = text.lastIndexOf(endCommandChar)+1;
if (previousSemicolonCommandStartIdx > lastNewLineCommandStartIdx) { // multiple commands per line separated by ';''
lastNewLineCommandStartIdx = previousSemicolonCommandStartIdx;
}
eqIndex = text.lastIndexOf('=')+1; // index of equality (in order to match the text after it
posAutoCompletion = lastNewLineCommandStartIdx;
if (eqIndex > lastNewLineCommandStartIdx)
posAutoCompletion = eqIndex;
text = text.substring(posAutoCompletion, text.length());
String iString = text; //= text.substring(startPos, text.length());
iString = iString.trim();
matches = null;
matches = scalaExec.Interpreter.GlobalValues.autoCompletionWorkspace.getMatched(iString);
topLevelResultsList = new JList(matches);
topLevelResultsList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent lse) {
String selValue = topLevelResultsList.getSelectedValue().toString();
String currentText = inputConsole.getText();