Esempio 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();
  }
Esempio n. 2
0
  /**
   * Calling this method will put the underlying terminal in private mode, clear the screen, move
   * the cursor and refresh.
   *
   * @throws LanternaException
   */
  public void startScreen() {
    if (hasBeenActivated) return;

    hasBeenActivated = true;
    terminal.enterPrivateMode();
    terminal.clearScreen();
    terminal.moveCursor(cursorPosition.getColumn(), cursorPosition.getRow());
    refresh();
  }
Esempio n. 3
0
  // test de methode d'affichage avec google.lanterna
  public void affichageGraphique(Terminal terminal) {

    terminal.enterPrivateMode(); // mode d'edition du terminal
    terminal.clearScreen(); // on efface l'ecran

    for (Integer i = 1; i <= 8; i++) {
      // affichage des coordonnees au bord de l'ecran
      terminal.applyBackgroundColor(Terminal.Color.DEFAULT);
      terminal.applyForegroundColor(Terminal.Color.DEFAULT);
      terminal.moveCursor(i, 10);
      terminal.putCharacter(i.toString().charAt(0));
      terminal.moveCursor(10, i);
      terminal.putCharacter(i.toString().charAt(0));

      // changement de la couleur de fond de maniere alternative
      for (int j = 1; j <= 8; j++) {
        terminal.moveCursor(i, j);
        terminal.applyBackgroundColor(Terminal.Color.BLUE);
        if ((i + j) % 2 == 0) terminal.applyBackgroundColor(Terminal.Color.YELLOW);

        terminal.putCharacter(' ');
      }
    }
    Iterator<Piece> it = this.get_pieces().iterator();

    // affichage de chacune des pieces
    while (it.hasNext()) {
      Piece p = it.next();
      if (!p
          .get_estMange()) { // on n'affiche que les pièces qui ne sont pas mangées (i.e encore sur
                             // le plateau)
        terminal.moveCursor(p.get_coordonnees().get_x(), p.get_coordonnees().get_y());

        terminal.applyBackgroundColor(Terminal.Color.BLUE);
        if ((p.get_coordonnees().get_x() + p.get_coordonnees().get_y()) % 2 == 0)
          terminal.applyBackgroundColor(Terminal.Color.YELLOW);

        terminal.applyForegroundColor(Terminal.Color.BLACK);
        if (p.get_couleur().get_couleur() == "blanc")
          terminal.applyForegroundColor(Terminal.Color.WHITE);

        terminal.putCharacter(p.get_symbole().charAt(0));
      }
    }

    terminal.moveCursor(0, 0);
  }
Esempio n. 4
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();
  }