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
.gui2
.Window
;
12 import com
.googlecode
.lanterna
.screen
.Screen
;
13 import com
.googlecode
.lanterna
.screen
.TerminalScreen
;
14 import com
.googlecode
.lanterna
.terminal
.DefaultTerminalFactory
;
15 import com
.googlecode
.lanterna
.terminal
.ResizeListener
;
16 import com
.googlecode
.lanterna
.terminal
.Terminal
;
24 public class TuiLauncher
{
25 static private Screen screen
= null;
28 * Start the TUI program.
31 * TRUE to force text mode, FALSE to force the Swing terminal
32 * emulator, null to automatically determine the best choice
34 * the files to show at startup
39 static public void start(Boolean textMode
, List
<String
> files
)
41 Window win
= new MainWindow(new FileList(files
));
42 TuiLauncher
.start(textMode
, win
);
46 * Return the used {@link Screen}.
48 * @return the {@link Screen}
50 static public Screen
getScreen() {
55 * Start the TUI program.
58 * TRUE to force text mode, FALSE to force the Swing terminal
59 * emulator, null to automatically determine the best choice
61 * the window to show at start
66 static public void start(Boolean textMode
, Window win
) throws IOException
{
67 Terminal terminal
= null;
69 DefaultTerminalFactory factory
= new DefaultTerminalFactory();
70 if (textMode
== null) {
71 terminal
= factory
.createTerminal();
72 } else if (textMode
) {
73 factory
.setForceTextTerminal(true);
74 terminal
= factory
.createTerminal();
76 terminal
= factory
.createTerminalEmulator();
79 if (win
instanceof MainWindow
) {
80 final MainWindow mwin
= (MainWindow
) win
;
81 mwin
.refresh(terminal
.getTerminalSize());
82 terminal
.addResizeListener(new ResizeListener() {
84 public void onResized(Terminal terminal
, TerminalSize newSize
) {
85 mwin
.refresh(newSize
);
90 screen
= new TerminalScreen(terminal
);
93 // Create gui and start gui
94 MultiWindowTextGUI gui
= new MultiWindowTextGUI(screen
,
97 gui
.setTheme(UiColors
.getCustomTheme());
99 gui
.addWindowAndWait(win
);