// Show the command from the command history, pointed to by the index. // Note that the index runs in reverse. private void showHistory() { String lShowLine; if (commandHistoryIndex == 0) lShowLine = currentCommand; else lShowLine = commandHistory.get(commandHistory.size() - commandHistoryIndex); replaceConsoleText(lShowLine, commandPos, textLength()); text.setCaretPosition(textLength()); text.repaint(); }
private void processCommand() { String lCommandRepr = getCmd(); if (lCommandRepr.length() != 0) commandHistory.add(lCommandRepr); lCommandRepr = lCommandRepr + "\n"; appendConsoleText("\n"); commandHistoryIndex = 0; acceptLine(lCommandRepr); text.repaint(); }
/** * The user of the component can write a command in the console as if the user typed the command * himself. The application using the console can simnulate user actions in this way. * * @param aCommand */ public void setCommand(String aCommand) { String lCommandRepr = aCommand; if (lCommandRepr.length() != 0) commandHistory.add(lCommandRepr); lCommandRepr = lCommandRepr + "\n"; appendConsoleText(lCommandRepr); commandHistoryIndex = 0; acceptLine(lCommandRepr); text.repaint(); }
/** Clear the console. */ public void clear() { text.setText(""); text.repaint(); }
private void moveCaret() { if (text.getCaretPosition() < commandPos) { text.setCaretPosition(textLength()); } text.repaint(); }