Search in sources :

Example 6 with Screen

use of com.googlecode.lanterna.screen.Screen in project security-lib by ncsa.

the class GUIDemo method mytest.

protected static void mytest() throws IOException {
    // Note UnixTerminal is supported BUT will freee the IDE because of
    // how it uses standard out. Write everything letting Lanterna decide
    // what works then switch when running in xterm.
    // Next three are required to start pretty much anything
    DefaultTerminalFactory factory = new DefaultTerminalFactory();
    // All this to set the background color of the terminal...
    TerminalEmulatorPalette myPallette = new TerminalEmulatorPalette(// sets default
    Color.WHITE, // sets default Bright
    Color.RED, // sets background. This is the only reason for this constructor
    Color.BLUE, Color.black, Color.BLACK, Color.red, Color.RED, Color.green, Color.GREEN, Color.yellow, Color.YELLOW, Color.blue, Color.BLUE, Color.magenta, Color.MAGENTA, Color.cyan, Color.CYAN, Color.white, Color.WHITE);
    // TerminalEmulatorPalette palette = new TerminalEmulatorPalette()
    TerminalEmulatorColorConfiguration colorConfig = TerminalEmulatorColorConfiguration.newInstance(myPallette);
    factory.setTerminalEmulatorColorConfiguration(colorConfig);
    Terminal terminal = factory.createTerminal();
    System.out.println("terminal is " + terminal.getClass().getSimpleName());
    Screen screen = new TerminalScreen(terminal);
    // sets up a resize listener in case the user changes the size.
    /*      terminal.addResizeListener((terminal1, newSize) -> {
                  // Be careful here though, this is likely running on a separate thread. Lanterna is threadsafe in
                  // a best-effort way so while it shouldn't blow up if you call terminal methods on multiple threads,
                  // it might have unexpected behavior if you don't do any external synchronization
                  textGraphics.drawLine(5, 3, newSize.getColumns() - 1, 3, ' ');
                  textGraphics.putString(5, 3, "Terminal Size: ", SGR.BOLD);
                  textGraphics.putString(5 + "Terminal Size: ".length(), 3, newSize.toString());
                  try {
                      terminal1.flush();
                  } catch (IOException e) {
                      // Not much we can do here
                      throw new RuntimeException(e);
                  }
              });*/
    TextGraphics textGraphics = screen.newTextGraphics();
    // textGraphics.setForegroundColor(TextColor.ANSI.YELLOW);
    screen.startScreen();
    // clear out any cruft in object properly.
    screen.refresh();
    // textGraphics.
    // Only one of these should be uncommented at any time since they are separate demos.
    // showStuff(textGraphics);
    // terminal.flush();
    // helloWorld(screen);
    // userInput2(terminal, screen, textGraphics);
    // testBox(screen);
    terminalInput(terminal, screen, textGraphics);
    screen.stopScreen();
}
Also used : TerminalScreen(com.googlecode.lanterna.screen.TerminalScreen) DefaultTerminalFactory(com.googlecode.lanterna.terminal.DefaultTerminalFactory) TerminalEmulatorColorConfiguration(com.googlecode.lanterna.terminal.swing.TerminalEmulatorColorConfiguration) Screen(com.googlecode.lanterna.screen.Screen) TerminalScreen(com.googlecode.lanterna.screen.TerminalScreen) TextGraphics(com.googlecode.lanterna.graphics.TextGraphics) TerminalEmulatorPalette(com.googlecode.lanterna.terminal.swing.TerminalEmulatorPalette) Terminal(com.googlecode.lanterna.terminal.Terminal)

Aggregations

Screen (com.googlecode.lanterna.screen.Screen)6 DefaultTerminalFactory (com.googlecode.lanterna.terminal.DefaultTerminalFactory)6 TerminalScreen (com.googlecode.lanterna.screen.TerminalScreen)5 Terminal (com.googlecode.lanterna.terminal.Terminal)5 TerminalSize (com.googlecode.lanterna.TerminalSize)2 IOException (java.io.IOException)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 TextColor (com.googlecode.lanterna.TextColor)1 TextGraphics (com.googlecode.lanterna.graphics.TextGraphics)1 MessageDialogButton (com.googlecode.lanterna.gui2.dialogs.MessageDialogButton)1 KeyStroke (com.googlecode.lanterna.input.KeyStroke)1 TerminalEmulatorColorConfiguration (com.googlecode.lanterna.terminal.swing.TerminalEmulatorColorConfiguration)1 TerminalEmulatorPalette (com.googlecode.lanterna.terminal.swing.TerminalEmulatorPalette)1 EOFException (java.io.EOFException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 MqttClient (org.eclipse.paho.client.mqttv3.MqttClient)1 MqttConnectOptions (org.eclipse.paho.client.mqttv3.MqttConnectOptions)1 MqttException (org.eclipse.paho.client.mqttv3.MqttException)1 MemoryPersistence (org.eclipse.paho.client.mqttv3.persist.MemoryPersistence)1