remove jar files from sources, should not be there
[jvcard.git] / src / be / nikiroo / jvcard / tui / TuiLauncher.java
... / ...
CommitLineData
1package be.nikiroo.jvcard.tui;
2
3import java.io.IOException;
4
5import com.googlecode.lanterna.TerminalSize;
6import com.googlecode.lanterna.TextColor;
7import com.googlecode.lanterna.gui2.DefaultWindowManager;
8import com.googlecode.lanterna.gui2.EmptySpace;
9import com.googlecode.lanterna.gui2.MultiWindowTextGUI;
10import com.googlecode.lanterna.gui2.Window;
11import com.googlecode.lanterna.screen.Screen;
12import com.googlecode.lanterna.screen.TerminalScreen;
13import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
14import com.googlecode.lanterna.terminal.ResizeListener;
15import com.googlecode.lanterna.terminal.Terminal;
16
17/**
18 * Starting the TUI.
19 *
20 * @author niki
21 *
22 */
23public class TuiLauncher {
24
25 static public void start(Boolean textMode, Window win) throws IOException {
26 Terminal terminal = null;
27
28 DefaultTerminalFactory factory = new DefaultTerminalFactory();
29 if (textMode == null) {
30 terminal = factory.createTerminal();
31 } else if (textMode) {
32 factory.setForceTextTerminal(true);
33 terminal = factory.createTerminal();
34 } else {
35 terminal = factory.createTerminalEmulator();
36 }
37
38 if (win instanceof MainWindow) {
39 MainWindow mwin = (MainWindow) win;
40 mwin.refresh(terminal.getTerminalSize());
41 terminal.addResizeListener(new ResizeListener() {
42 @Override
43 public void onResized(Terminal terminal, TerminalSize newSize) {
44 mwin.refresh(newSize);
45 }
46 });
47 }
48
49 Screen screen = new TerminalScreen(terminal);
50 screen.startScreen();
51
52 // Create gui and start gui
53 MultiWindowTextGUI gui = new MultiWindowTextGUI(screen,
54 new DefaultWindowManager(), new EmptySpace(TextColor.ANSI.BLUE));
55 gui.addWindowAndWait(win);
56
57 screen.stopScreen();
58 }
59}