1 package be
.nikiroo
.jvcard
.tui
;
3 import java
.io
.IOException
;
4 import java
.io
.UnsupportedEncodingException
;
8 import jexer
.TApplication
;
9 import be
.nikiroo
.jvcard
.tui
.windows
.TuiBrowserWindow
;
10 import be
.nikiroo
.jvcard
.tui
.windows
.TuiFileListWindow
;
17 public class TuiLauncherJexer
extends TApplication
{
19 * Application is in fullscreen mode, no windows.
21 static public final boolean FULLSCREEN
= true;
25 * TRUE to force text mode, FALSE to force the Swing terminal
26 * emulator, null to automatically determine the best choice
28 * the files to show at startup
29 * @throws UnsupportedEncodingException
31 public TuiLauncherJexer(final Boolean textMode
, final List
<String
> files
)
32 throws UnsupportedEncodingException
{
33 super(backend(textMode
));
38 // TODO investigate why that is
39 if (backend(textMode
) == BackendType
.SWING
) {
40 new Thread(new Runnable() {
43 showMainWindow(files
);
47 showMainWindow(files
);
51 private void showMainWindow(final List
<String
> files
) {
52 TuiBrowserWindow main
= new TuiFileListWindow(TuiLauncherJexer
.this,
54 main
.addCloseListener(new TAction() {
57 TuiLauncherJexer
.this.exit(false);
63 * Start the TUI program.
68 public void start() throws IOException
{
69 (new Thread(this)).start();
73 * Select the most appropriate backend.
76 * NULL for auto-dection
77 * @return the backend type to use
79 private static BackendType
backend(Boolean textMode
) {
80 if (textMode
== null) {
81 boolean isMsWindows
= System
.getProperty("os.name", "")
82 .toLowerCase().startsWith("windows");
83 boolean forceSwing
= System
.getProperty("jexer.Swing", "false")
85 boolean noConsole
= System
.console() == null;
86 if (isMsWindows
|| forceSwing
|| noConsole
) {
87 return BackendType
.SWING
;
90 return BackendType
.XTERM
;
94 return BackendType
.XTERM
;
97 return BackendType
.SWING
;