Exemplo n.º 1
0
  public static void main(String[] args) throws InterruptedException {
    final Terminal rawTerminal = new TestTerminalFactory(args).createTerminal();
    rawTerminal.enterPrivateMode();

    int currentRow = 0;
    rawTerminal.moveCursor(0, 0);
    while (true) {
      Key key = rawTerminal.readInput();
      if (key == null) {
        Thread.sleep(1);
        continue;
      }

      if (key.getKind() == Key.Kind.Escape) break;

      if (currentRow == 0) rawTerminal.clearScreen();

      rawTerminal.moveCursor(0, currentRow++);
      putString(rawTerminal, key.toString());

      if (currentRow >= rawTerminal.getTerminalSize().getRows()) currentRow = 0;
    }

    rawTerminal.exitPrivateMode();
  }
Exemplo n.º 2
0
 /**
  * Reads the next {@code Key} from the input queue, or returns null if there is nothing on the
  * queue.
  */
 public Key readInput() {
   return terminal.readInput();
 }