X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTApplication.java;h=e61cea28d631afba3c84964c7a2a13803c597aca;hb=eb29bbb5ec70c43895dd0f053630c7e3cd402cba;hp=b7c5f8ef51e5c63f30605d840d8dab0967f1b86b;hpb=b2d49e0f15810a35a206e88c9bad11b053ed65fc;p=fanfix.git diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index b7c5f8e..e61cea2 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -575,6 +575,39 @@ public class TApplication implements Runnable { // Constructors ----------------------------------------------------------- // ------------------------------------------------------------------------ + /** + * Public constructor. + * + * @param backendType BackendType.XTERM, BackendType.ECMA48 or + * BackendType.SWING + * @param windowWidth the number of text columns to start with + * @param windowHeight the number of text rows to start with + * @param fontSize the size in points + * @throws UnsupportedEncodingException if an exception is thrown when + * creating the InputStreamReader + */ + public TApplication(final BackendType backendType, final int windowWidth, + final int windowHeight, final int fontSize) + throws UnsupportedEncodingException { + + switch (backendType) { + case SWING: + backend = new SwingBackend(this, windowWidth, windowHeight, + fontSize); + break; + case XTERM: + // Fall through... + case ECMA48: + backend = new ECMA48Backend(this, null, null, windowWidth, + windowHeight, fontSize); + break; + default: + throw new IllegalArgumentException("Invalid backend type: " + + backendType); + } + TApplicationImpl(); + } + /** * Public constructor. * @@ -1623,6 +1656,12 @@ public class TApplication implements Runnable { windows.remove(0); activeWindow = null; for (TWindow w: windows) { + + // Do not activate a hidden window. + if (w.isHidden()) { + continue; + } + if (w.getZ() > z) { w.setZ(w.getZ() - 1); if (w.getZ() == 0) { @@ -1941,10 +1980,16 @@ public class TApplication implements Runnable { continue; } for (int x = w.getX(); x < w.getX() + w.getWidth(); x++) { + if (x < 0) { + continue; + } if (x >= width) { continue; } for (int y = w.getY(); y < w.getY() + w.getHeight(); y++) { + if (y < 0) { + continue; + } if (y >= height) { continue; } @@ -2830,6 +2875,22 @@ public class TApplication implements Runnable { return openTerminal(x, y, TWindow.RESIZABLE, commandLine); } + /** + * Convenience function to open a terminal window and execute a custom + * command line inside it. + * + * @param x column relative to parent + * @param y row relative to parent + * @param flags mask of CENTERED, MODAL, or RESIZABLE + * @param command the command line to execute + * @return the terminal new window + */ + public final TTerminalWindow openTerminal(final int x, final int y, + final int flags, final String [] command) { + + return new TTerminalWindow(this, x, y, flags, command); + } + /** * Convenience function to open a terminal window and execute a custom * command line inside it. @@ -2843,7 +2904,7 @@ public class TApplication implements Runnable { public final TTerminalWindow openTerminal(final int x, final int y, final int flags, final String commandLine) { - return new TTerminalWindow(this, x, y, flags, commandLine); + return new TTerminalWindow(this, x, y, flags, commandLine.split("\\s")); } /**