use of com.googlecode.lanterna.terminal.DefaultTerminalFactory in project nzyme by lennartkoopmann.
the class TextGUIHID method initializeGUI.
private void initializeGUI() throws IOException {
Terminal terminal = new DefaultTerminalFactory().setInitialTerminalSize(new TerminalSize(COLS, ROWS)).createTerminal();
Screen screen = new TerminalScreen(terminal);
screen.startScreen();
BasicWindow window = new BasicWindow();
Panel mainPanel = new Panel();
// Top status.
Panel statusPanel = new Panel(new GridLayout(8));
statusPanel.addComponent(labelConnection.withBorder(Borders.singleLine("CONN")));
statusPanel.addComponent(labelSignal.withBorder(Borders.singleLine("SIG")));
statusPanel.addComponent(labelTrackerStatus.withBorder(Borders.singleLine("LINK DVC")));
statusPanel.addComponent(labelWiFiStatus.withBorder(Borders.singleLine("802.11")));
statusPanel.addComponent(labelWiFiChannels.withBorder(Borders.singleLine("CHANNEL")));
statusPanel.addComponent(labelDesignator.withBorder(Borders.singleLine("DSGNTR")));
statusPanel.addComponent(new EmptySpace(new TerminalSize(3, 3)));
statusPanel.addComponent(labelTime.withBorder(Borders.singleLine("CLOCK")));
mainPanel.addComponent(statusPanel);
// Task.
Panel taskPanel = new Panel(new GridLayout(6));
taskPanel.addComponent(labelTask.withBorder(Borders.singleLine("TASK")));
taskPanel.addComponent(labelBandit.withBorder(Borders.singleLine("BANDIT TARGET")));
taskPanel.addComponent(labelTrack.withBorder(Borders.singleLine("TRACK")));
taskPanel.addComponent(labelTrackSignal.withBorder(Borders.singleLine("TRACK SIG")));
taskPanel.addComponent(labelTrackFrames.withBorder(Borders.singleLine("FRAMES")));
taskPanel.addComponent(labelTrackContact.withBorder(Borders.singleLine("LAST CONTACT")));
mainPanel.addComponent(taskPanel);
// Events
Panel eventsPanel = new Panel(new GridLayout(1));
eventsPanel.addComponent(eventsTable.withBorder(Borders.singleLine("EVENTS")));
eventsTable.setCellSelection(false);
eventsTable.setSelectedRow(-1);
eventsTable.setVisibleRows(5);
eventsTable.setSize(new TerminalSize(COLS, 8));
event(nzyme.getNodeID(), "Initialized tracker.");
mainPanel.addComponent(eventsPanel);
window.setComponent(mainPanel);
window.setTheme(SimpleTheme.makeTheme(true, TextColor.ANSI.WHITE, TextColor.ANSI.BLACK, TextColor.ANSI.BLACK, TextColor.ANSI.BLUE, TextColor.ANSI.WHITE, TextColor.ANSI.RED, TextColor.ANSI.RED));
window.setHints(Arrays.asList(Window.Hint.CENTERED, Window.Hint.NO_DECORATIONS));
MultiWindowTextGUI gui = new MultiWindowTextGUI(screen, new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLACK));
gui.addWindowAndWait(window);
}
use of com.googlecode.lanterna.terminal.DefaultTerminalFactory in project security-lib by ncsa.
the class FullScreenTextGUITest method main.
public static void main(String[] args) throws IOException, InterruptedException {
DefaultTerminalFactory factory = new DefaultTerminalFactory();
Terminal terminal = factory.createTerminal();
// Screen screen = new TestTerminalFactory(args).setInitialTerminalSize(new TerminalSize(80, 25)).createScreen();
Screen screen = new TerminalScreen(terminal);
screen.startScreen();
final AtomicBoolean stop = new AtomicBoolean(false);
MultiWindowTextGUI textGUI = new MultiWindowTextGUI(screen);
textGUI.addListener((textGUI1, key) -> {
if (key.getKeyType() == KeyType.Escape) {
stop.set(true);
return true;
}
return false;
});
try {
textGUI.getBackgroundPane().setComponent(new BIOS());
while (!stop.get()) {
if (!textGUI.getGUIThread().processEventsAndUpdate()) {
Thread.sleep(1);
}
}
} catch (EOFException ignore) {
// Terminal closed Left
} finally {
screen.stopScreen();
}
}
use of com.googlecode.lanterna.terminal.DefaultTerminalFactory 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.DefaultTerminalFactory 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