Example #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();
  }
Example #2
0
  public static void main(String[] args) throws InterruptedException {
    Terminal terminal = TerminalFacade.createSwingTerminal();
    terminal.enterPrivateMode();
    terminal.clearScreen();
    terminal.moveCursor(10, 5);
    terminal.putCharacter('H');
    terminal.putCharacter('e');
    terminal.putCharacter('l');
    terminal.putCharacter('l');
    terminal.putCharacter('o');
    terminal.putCharacter('!');
    terminal.putCharacter(' ');
    terminal.putCharacter(ACS.HEART);
    terminal.putCharacter(ACS.SPADES);
    terminal.putCharacter(ACS.CLUB);
    terminal.putCharacter(ACS.DIAMOND);
    terminal.putCharacter(ACS.DOUBLE_LINE_CROSS);
    terminal.putCharacter(ACS.SINGLE_LINE_CROSS);
    terminal.putCharacter(ACS.DOUBLE_LINE_T_DOWN);
    terminal.putCharacter(ACS.SINGLE_LINE_VERTICAL);
    terminal.putCharacter(ACS.SINGLE_LINE_HORIZONTAL);
    terminal.moveCursor(10, 7);
    terminal.applySGR(Terminal.SGR.ENTER_BOLD);
    terminal.putCharacter('H');
    terminal.putCharacter('e');
    terminal.putCharacter('l');
    terminal.putCharacter('l');
    terminal.putCharacter('o');
    terminal.putCharacter('!');
    terminal.putCharacter(' ');
    terminal.putCharacter(ACS.HEART);
    terminal.putCharacter(ACS.SPADES);
    terminal.putCharacter(ACS.CLUB);
    terminal.putCharacter(ACS.DIAMOND);
    terminal.putCharacter(ACS.DOUBLE_LINE_CROSS);
    terminal.putCharacter(ACS.SINGLE_LINE_CROSS);
    terminal.putCharacter(ACS.DOUBLE_LINE_T_DOWN);
    terminal.putCharacter(ACS.SINGLE_LINE_VERTICAL);
    terminal.putCharacter(ACS.SINGLE_LINE_HORIZONTAL);
    terminal.moveCursor(10, 9);
    terminal.applySGR(Terminal.SGR.ENTER_UNDERLINE);
    terminal.putCharacter('H');
    terminal.putCharacter('e');
    terminal.applySGR(Terminal.SGR.EXIT_BOLD);
    terminal.putCharacter('l');
    terminal.applySGR(Terminal.SGR.EXIT_UNDERLINE);
    terminal.putCharacter('l');
    terminal.putCharacter('o');
    terminal.applySGR(Terminal.SGR.ENTER_UNDERLINE);
    terminal.putCharacter('!');
    terminal.putCharacter(' ');
    terminal.putCharacter(ACS.HEART);
    terminal.putCharacter(ACS.SPADES);
    terminal.putCharacter(ACS.CLUB);
    terminal.putCharacter(ACS.DIAMOND);
    terminal.putCharacter(ACS.DOUBLE_LINE_CROSS);
    terminal.putCharacter(ACS.SINGLE_LINE_CROSS);
    terminal.putCharacter(ACS.DOUBLE_LINE_T_DOWN);
    terminal.putCharacter(ACS.SINGLE_LINE_VERTICAL);
    terminal.putCharacter(ACS.SINGLE_LINE_HORIZONTAL);
    terminal.applySGR(Terminal.SGR.RESET_ALL);
    terminal.moveCursor(0, 0);

    Thread.sleep(5000);
    terminal.exitPrivateMode();
  }
Example #3
0
  /**
   * Calling this method will make the underlying terminal leave private mode, effectively going
   * back to whatever state the terminal was in before calling {@code startScreen()}
   *
   * @throws LanternaException
   */
  public void stopScreen() {
    if (!hasBeenActivated) return;

    terminal.exitPrivateMode();
    hasBeenActivated = false;
  }