use of com.googlecode.lanterna.screen.VirtualScreen 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