1 package be
.nikiroo
.jvcard
.tui
;
3 import java
.io
.UnsupportedEncodingException
;
7 import jexer
.TApplication
;
8 import be
.nikiroo
.jvcard
.tui
.windows
.TuiBrowserWindow
;
9 import be
.nikiroo
.jvcard
.tui
.windows
.TuiFileListWindow
;
16 public class TuiLauncherJexer
extends TApplication
{
18 * Application is in fullscreen mode, no windows.
20 * TODO: make it an option
22 static public final boolean FULLSCREEN
= true;
26 * TRUE to force text mode, FALSE to force the Swing terminal
27 * emulator, null to automatically determine the best choice
29 * the files to show at startup
31 * @throws UnsupportedEncodingException
32 * if an exception is thrown when creating the InputStreamReader
34 public TuiLauncherJexer(final Boolean textMode
, final List
<String
> files
)
35 throws UnsupportedEncodingException
{
36 super(backend(textMode
));
41 int width
= getBackend().getScreen().getWidth();
42 int height
= getBackend().getScreen().getHeight() - 2;
44 if (backend(textMode
) == BackendType
.SWING
) {
45 // TODO: why does the size change after the FIRST window has been
46 // created (SWING mode only?) ?
47 // A problem with the graphical size not an exact number of
53 width
= Math
.max(1, width
);
54 height
= Math
.max(1, height
);
56 TuiBrowserWindow main
= new TuiFileListWindow(TuiLauncherJexer
.this,
57 width
, height
, files
);
59 main
.addCloseListener(new TAction() {
62 TuiLauncherJexer
.this.exit(false);
68 * Start the TUI program.
71 (new Thread(this)).start();
75 * Select the most appropriate backend.
78 * NULL for auto-detection
79 * @return the backend type to use
81 private static BackendType
backend(Boolean textMode
) {
82 if (textMode
== null) {
83 boolean isMsWindows
= System
.getProperty("os.name", "")
84 .toLowerCase().startsWith("windows");
85 boolean forceSwing
= System
.getProperty("jexer.Swing", "false")
87 boolean noConsole
= System
.console() == null;
88 if (isMsWindows
|| forceSwing
|| noConsole
) {
89 return BackendType
.SWING
;
92 return BackendType
.XTERM
;
96 return BackendType
.XTERM
;
99 return BackendType
.SWING
;