Example #1
0
  // 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();
  }
Example #2
0
  private void processCommand() {
    String lCommandRepr = getCmd();
    if (lCommandRepr.length() != 0) commandHistory.add(lCommandRepr);
    lCommandRepr = lCommandRepr + "\n";

    appendConsoleText("\n");
    commandHistoryIndex = 0;
    acceptLine(lCommandRepr);
    text.repaint();
  }
Example #3
0
  /**
   * 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();
  }
Example #4
0
 /** Clear the console. */
 public void clear() {
   text.setText("");
   text.repaint();
 }
Example #5
0
 private void moveCaret() {
   if (text.getCaretPosition() < commandPos) {
     text.setCaretPosition(textLength());
   }
   text.repaint();
 }