1 package be
.nikiroo
.jvcard
.tui
;
3 import java
.io
.IOException
;
6 import be
.nikiroo
.jvcard
.tui
.panes
.FileList
;
8 import com
.googlecode
.lanterna
.TerminalSize
;
9 import com
.googlecode
.lanterna
.TextColor
;
10 import com
.googlecode
.lanterna
.gui2
.MultiWindowTextGUI
;
11 import com
.googlecode
.lanterna
.screen
.Screen
;
12 import com
.googlecode
.lanterna
.screen
.TerminalScreen
;
13 import com
.googlecode
.lanterna
.terminal
.DefaultTerminalFactory
;
14 import com
.googlecode
.lanterna
.terminal
.ResizeListener
;
15 import com
.googlecode
.lanterna
.terminal
.Terminal
;
23 public class TuiLauncher
{
24 static private Screen screen
;
26 private Boolean textMode
;
27 private List
<String
> files
;
32 * TRUE to force text mode, FALSE to force the Swing terminal
33 * emulator, null to automatically determine the best choice
35 * the files to show at startup
38 public TuiLauncher(Boolean textMode
, List
<String
> files
) {
39 this.textMode
= textMode
;
44 * Start the TUI program.
51 public void start() throws IOException
{
52 Terminal terminal
= null;
54 DefaultTerminalFactory factory
= new DefaultTerminalFactory();
55 if (textMode
== null) {
56 terminal
= factory
.createTerminal();
57 } else if (textMode
) {
58 factory
.setForceTextTerminal(true);
59 terminal
= factory
.createTerminal();
61 terminal
= factory
.createTerminalEmulator();
64 final MainWindow win
= new MainWindow(new FileList(files
));
65 win
.refresh(terminal
.getTerminalSize());
66 terminal
.addResizeListener(new ResizeListener() {
68 public void onResized(Terminal terminal
, TerminalSize newSize
) {
73 screen
= new TerminalScreen(terminal
);
76 // Create gui and start gui
77 MultiWindowTextGUI gui
= new MultiWindowTextGUI(screen
,
80 gui
.setTheme(UiColors
.getCustomTheme());
82 gui
.addWindowAndWait(win
);
87 * Return the used {@link Screen}.
89 * @return the {@link Screen}
91 static public Screen
getScreen() {