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
.DefaultWindowManager
;
11 import com
.googlecode
.lanterna
.gui2
.EmptySpace
;
12 import com
.googlecode
.lanterna
.gui2
.MultiWindowTextGUI
;
13 import com
.googlecode
.lanterna
.gui2
.Window
;
14 import com
.googlecode
.lanterna
.screen
.Screen
;
15 import com
.googlecode
.lanterna
.screen
.TerminalScreen
;
16 import com
.googlecode
.lanterna
.terminal
.DefaultTerminalFactory
;
17 import com
.googlecode
.lanterna
.terminal
.ResizeListener
;
18 import com
.googlecode
.lanterna
.terminal
.Terminal
;
26 public class TuiLauncher
{
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 * Start the TUI program.
49 * TRUE to force text mode, FALSE to force the Swing terminal
50 * emulator, null to automatically determine the best choice
52 * the window to show at start
57 static public void start(Boolean textMode
, Window win
) throws IOException
{
58 Terminal terminal
= null;
60 DefaultTerminalFactory factory
= new DefaultTerminalFactory();
61 if (textMode
== null) {
62 terminal
= factory
.createTerminal();
63 } else if (textMode
) {
64 factory
.setForceTextTerminal(true);
65 terminal
= factory
.createTerminal();
67 terminal
= factory
.createTerminalEmulator();
70 if (win
instanceof MainWindow
) {
71 final MainWindow mwin
= (MainWindow
) win
;
72 mwin
.refresh(terminal
.getTerminalSize());
73 terminal
.addResizeListener(new ResizeListener() {
75 public void onResized(Terminal terminal
, TerminalSize newSize
) {
76 mwin
.refresh(newSize
);
81 Screen screen
= new TerminalScreen(terminal
);
84 // Create gui and start gui
85 MultiWindowTextGUI gui
= new MultiWindowTextGUI(screen
,
86 new DefaultWindowManager(), new EmptySpace(TextColor
.ANSI
.BLUE
));
87 gui
.addWindowAndWait(win
);