X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Ftui%2FTuiLauncherJexer.java;h=3f54633122c445066192cc2c04b420a34e02faea;hb=5c5abfd29edd67f4c16932dd8aaf16ac4ccec4f2;hp=445fc787895543a3ec9485436f35dc513181e847;hpb=10dd1e387d6a1834596ae70f48cf905d7b302131;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/tui/TuiLauncherJexer.java b/src/be/nikiroo/jvcard/tui/TuiLauncherJexer.java index 445fc78..3f54633 100644 --- a/src/be/nikiroo/jvcard/tui/TuiLauncherJexer.java +++ b/src/be/nikiroo/jvcard/tui/TuiLauncherJexer.java @@ -1,11 +1,11 @@ package be.nikiroo.jvcard.tui; -import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.List; +import jexer.TAction; import jexer.TApplication; -import jexer.TWindow; +import be.nikiroo.jvcard.tui.windows.TuiBrowserWindow; import be.nikiroo.jvcard.tui.windows.TuiFileListWindow; /** @@ -14,6 +14,12 @@ import be.nikiroo.jvcard.tui.windows.TuiFileListWindow; * @author niki */ public class TuiLauncherJexer extends TApplication { + /** + * Application is in fullscreen mode, no windows. + * + * TODO: make it an option + */ + static public final boolean FULLSCREEN = true; /** * @param textMode @@ -21,7 +27,9 @@ public class TuiLauncherJexer extends TApplication { * emulator, null to automatically determine the best choice * @param files * the files to show at startup + * * @throws UnsupportedEncodingException + * if an exception is thrown when creating the InputStreamReader */ public TuiLauncherJexer(final Boolean textMode, final List files) throws UnsupportedEncodingException { @@ -30,17 +38,36 @@ public class TuiLauncherJexer extends TApplication { addFileMenu(); addWindowMenu(); - @SuppressWarnings("unused") - TWindow w = new TuiFileListWindow(this, files); + int width = getBackend().getScreen().getWidth(); + int height = getBackend().getScreen().getHeight() - 2; + + if (backend(textMode) == BackendType.SWING) { + // TODO: why does the size change after the FIRST window has been + // created (SWING mode only?) ? + // A problem with the graphical size not an exact number of + // cols/lines? + width--; + height--; + } + + width = Math.max(1, width); + height = Math.max(1, height); + + TuiBrowserWindow main = new TuiFileListWindow(TuiLauncherJexer.this, + width, height, files); + + main.addCloseListener(new TAction() { + @Override + public void DO() { + TuiLauncherJexer.this.exit(false); + } + }); } /** * Start the TUI program. - * - * @throws IOException - * in case of IO error */ - public void start() throws IOException { + public void start() { (new Thread(this)).start(); } @@ -48,7 +75,7 @@ public class TuiLauncherJexer extends TApplication { * Select the most appropriate backend. * * @param textMode - * NULL for auto-dection + * NULL for auto-detection * @return the backend type to use */ private static BackendType backend(Boolean textMode) {