X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Ftui%2FTuiLauncher.java;h=066ba315c4be651db64e51a181850ec3d36d98b8;hb=7da41ecd30228908bf2afcd07ff7943ab59d4c01;hp=efaa68939421e8f24e89a4d5aa02672a34fdf310;hpb=a3b510ab4bf89a7a2a05f3851ffe0f030b8a78f4;p=jvcard.git diff --git a/src/be/nikiroo/jvcard/tui/TuiLauncher.java b/src/be/nikiroo/jvcard/tui/TuiLauncher.java index efaa689..066ba31 100644 --- a/src/be/nikiroo/jvcard/tui/TuiLauncher.java +++ b/src/be/nikiroo/jvcard/tui/TuiLauncher.java @@ -1,7 +1,11 @@ package be.nikiroo.jvcard.tui; import java.io.IOException; +import java.util.List; +import be.nikiroo.jvcard.tui.panes.FileList; + +import com.googlecode.lanterna.TerminalSize; import com.googlecode.lanterna.TextColor; import com.googlecode.lanterna.gui2.DefaultWindowManager; import com.googlecode.lanterna.gui2.EmptySpace; @@ -10,22 +14,47 @@ import com.googlecode.lanterna.gui2.Window; import com.googlecode.lanterna.screen.Screen; import com.googlecode.lanterna.screen.TerminalScreen; import com.googlecode.lanterna.terminal.DefaultTerminalFactory; +import com.googlecode.lanterna.terminal.ResizeListener; import com.googlecode.lanterna.terminal.Terminal; -/* - * - * Change in Lanterna3 (issue and fix reported to GitHub): - * - * java.lang.StringIndexOutOfBoundsException: String index out of range: 83 - * at java.lang.String.charAt(String.java:686) - * at com.googlecode.lanterna.TerminalTextUtils.getWordWrappedText(TerminalTextUtils.java:237) - * +/** + * Starting the TUI. * + * @author niki + * */ - public class TuiLauncher { - public static void start(Boolean textMode, Window win) + /** + * Start the TUI program. + * + * @param textMode + * TRUE to force text mode, FALSE to force the Swing terminal + * emulator, null to automatically determine the best choice + * @param files + * the files to show at startup + * + * @throws IOException + * in case of IO error + */ + static public void start(Boolean textMode, List files) throws IOException { + Window win = new MainWindow(new FileList(files)); + TuiLauncher.start(textMode, win); + } + + /** + * Start the TUI program. + * + * @param textMode + * TRUE to force text mode, FALSE to force the Swing terminal + * emulator, null to automatically determine the best choice + * @param win + * the window to show at start + * + * @throws IOException + * in case of IO error + */ + static public void start(Boolean textMode, Window win) throws IOException { Terminal terminal = null; DefaultTerminalFactory factory = new DefaultTerminalFactory(); @@ -38,6 +67,17 @@ public class TuiLauncher { terminal = factory.createTerminalEmulator(); } + if (win instanceof MainWindow) { + final MainWindow mwin = (MainWindow) win; + mwin.refresh(terminal.getTerminalSize()); + terminal.addResizeListener(new ResizeListener() { + @Override + public void onResized(Terminal terminal, TerminalSize newSize) { + mwin.refresh(newSize); + } + }); + } + Screen screen = new TerminalScreen(terminal); screen.startScreen();