use of com.googlecode.lanterna.terminal.swing.TerminalEmulatorPalette 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();
}
use of com.googlecode.lanterna.terminal.swing.TerminalEmulatorPalette in project security-lib by ncsa.
the class QDLGUIWorkspace method setupScreen.
protected void setupScreen() throws IOException {
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()
DefaultTerminalFactory factory = new DefaultTerminalFactory();
TerminalEmulatorColorConfiguration colorConfig = TerminalEmulatorColorConfiguration.newInstance(myPallette);
factory.setTerminalEmulatorColorConfiguration(colorConfig);
// DefaultTerminalFactory factory = new DefaultTerminalFactory();
terminal = factory.createTerminal();
screen = new VirtualScreen(new TerminalScreen(terminal));
textGraphics = screen.newTextGraphics();
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);
}
});
int x = terminal.getTerminalSize().getRows();
textGraphics.setForegroundColor(TextColor.RGB.Factory.fromString("#FFFF00"));
textGraphics.setBackgroundColor(TextColor.RGB.Factory.fromString("#0000FF"));
textGraphics.enableModifiers(SGR.BOLD);
ioInterface = new LanternaScreenIO(terminal, screen, textGraphics);
// screen.scrollLines(0, x, x); // scroll in units of 25 lines.
// screen.
screen.startScreen();
screen.refresh();
}
Aggregations