Exemplo n.º 1
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();
  }
Exemplo n.º 2
0
 public static void main(String[] argv) {
   //		Terminal terminal = TerminalFacade.createTerminal();
   //		terminal.enterPrivateMode();
   //
   //		terminal.exitPrivateMode();
   Screen screen = TerminalFacade.createScreen();
   screen.startScreen();
   screen.putString(
       10, 5, "Press \u2191 q to exit...", Terminal.Color.WHITE, Terminal.Color.BLACK);
   screen.refresh();
   boolean done = false;
   try {
     while (!done) {
       Key key = screen.readInput();
       if (key != null) {
         if (key.getCharacter() == 'q') {
           screen.putString(
               10, 6, "That is q!!!           ", Terminal.Color.GREEN, Terminal.Color.BLACK);
           screen.refresh();
           done = true;
           Thread.sleep(2000);
         } else {
           screen.putString(
               10,
               6,
               "That is " + key.getCharacter() + ", not q",
               Terminal.Color.RED,
               Terminal.Color.BLACK);
           screen.refresh();
         }
       } else {
         Thread.sleep(20);
       }
     }
   } catch (InterruptedException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   screen.stopScreen();
 }
Exemplo n.º 3
0
  public static void main(String[] args) {
    Screen screen = new TestTerminalFactory(args).createScreen();
    screen.startScreen();

    ScreenWriter writer = new ScreenWriter(screen);
    writer.setForegroundColor(Terminal.Color.DEFAULT);
    writer.setBackgroundColor(Terminal.Color.DEFAULT);
    writer.drawString(10, 1, "Hello World");

    writer.setForegroundColor(Terminal.Color.BLACK);
    writer.setBackgroundColor(Terminal.Color.WHITE);
    writer.drawString(11, 2, "Hello World");
    writer.setForegroundColor(Terminal.Color.WHITE);
    writer.setBackgroundColor(Terminal.Color.BLACK);
    writer.drawString(12, 3, "Hello World");
    writer.setForegroundColor(Terminal.Color.BLACK);
    writer.setBackgroundColor(Terminal.Color.WHITE);
    writer.drawString(13, 4, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.WHITE);
    writer.setBackgroundColor(Terminal.Color.BLACK);
    writer.drawString(14, 5, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.DEFAULT);
    writer.setBackgroundColor(Terminal.Color.DEFAULT);
    writer.drawString(15, 6, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.DEFAULT);
    writer.setBackgroundColor(Terminal.Color.DEFAULT);
    writer.drawString(16, 7, "Hello World");

    writer.setForegroundColor(Terminal.Color.BLUE);
    writer.setBackgroundColor(Terminal.Color.DEFAULT);
    writer.drawString(10, 10, "Hello World");
    writer.setForegroundColor(Terminal.Color.BLUE);
    writer.setBackgroundColor(Terminal.Color.WHITE);
    writer.drawString(11, 11, "Hello World");
    writer.setForegroundColor(Terminal.Color.BLUE);
    writer.setBackgroundColor(Terminal.Color.BLACK);
    writer.drawString(12, 12, "Hello World");
    writer.setForegroundColor(Terminal.Color.BLUE);
    writer.setBackgroundColor(Terminal.Color.MAGENTA);
    writer.drawString(13, 13, "Hello World");
    writer.setForegroundColor(Terminal.Color.GREEN);
    writer.setBackgroundColor(Terminal.Color.DEFAULT);
    writer.drawString(14, 14, "Hello World");
    writer.setForegroundColor(Terminal.Color.GREEN);
    writer.setBackgroundColor(Terminal.Color.WHITE);
    writer.drawString(15, 15, "Hello World");
    writer.setForegroundColor(Terminal.Color.GREEN);
    writer.setBackgroundColor(Terminal.Color.BLACK);
    writer.drawString(16, 16, "Hello World");
    writer.setForegroundColor(Terminal.Color.GREEN);
    writer.setBackgroundColor(Terminal.Color.MAGENTA);
    writer.drawString(17, 17, "Hello World");

    writer.setForegroundColor(Terminal.Color.BLUE);
    writer.setBackgroundColor(Terminal.Color.DEFAULT);
    writer.drawString(10, 20, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.BLUE);
    writer.setBackgroundColor(Terminal.Color.WHITE);
    writer.drawString(11, 21, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.BLUE);
    writer.setBackgroundColor(Terminal.Color.BLACK);
    writer.drawString(12, 22, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.BLUE);
    writer.setBackgroundColor(Terminal.Color.MAGENTA);
    writer.drawString(13, 23, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.GREEN);
    writer.setBackgroundColor(Terminal.Color.DEFAULT);
    writer.drawString(14, 24, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.GREEN);
    writer.setBackgroundColor(Terminal.Color.WHITE);
    writer.drawString(15, 25, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.GREEN);
    writer.setBackgroundColor(Terminal.Color.BLACK);
    writer.drawString(16, 26, "Hello World", ScreenCharacterStyle.Bold);
    writer.setForegroundColor(Terminal.Color.CYAN);
    writer.setBackgroundColor(Terminal.Color.BLUE);
    writer.drawString(17, 27, "Hello World", ScreenCharacterStyle.Bold);
    screen.refresh();

    try {
      Thread.sleep(5000);
    } catch (InterruptedException e) {
    }
    screen.stopScreen();
  }