Esempio n. 1
0
 /**
  * Draws a string on the screen at a particular position
  *
  * @param x 0-indexed column number of where to put the first character in the string
  * @param y 0-indexed row number of where to put the first character in the string
  * @param string Text to put on the screen
  * @param foregroundColor What color to use for the text
  * @param backgroundColor What color to use for the background
  * @param styles Additional styles to apply to the text
  */
 public void putString(
     int x,
     int y,
     String string,
     Terminal.Color foregroundColor,
     Terminal.Color backgroundColor,
     ScreenCharacterStyle... styles) {
   Set<ScreenCharacterStyle> drawStyle = EnumSet.noneOf(ScreenCharacterStyle.class);
   drawStyle.addAll(Arrays.asList(styles));
   putString(x, y, string, foregroundColor, backgroundColor, drawStyle);
 }
Esempio 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();
 }