X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTApplication.java;h=b4c53ec3a5ea8899db40c6dbdda283abe85153f7;hb=499fdccfad144aa58869d839d50edb898670626a;hp=abd69ca7cca11e537805dae99cf69ebe3fe47661;hpb=159f076db8ec60010cdf87b1164a875d51875dd4;p=fanfix.git diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index abd69ca..b4c53ec 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -28,6 +28,7 @@ */ package jexer; +import java.io.File; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; @@ -1430,9 +1431,15 @@ public class TApplication implements Runnable { if (activeWindow != null) { assert (activeWindow.getZ() == 0); - activeWindow.onUnfocus(); activeWindow.setActive(false); activeWindow.setZ(window.getZ()); + + // Unset activeWindow now before unfocus, so that a window + // lifecycle change inside onUnfocus() doesn't call + // switchWindow() and lead to a stack overflow. + TWindow oldActiveWindow = activeWindow; + activeWindow = null; + oldActiveWindow.onUnfocus(); } activeWindow = window; activeWindow.setZ(0); @@ -2755,6 +2762,7 @@ public class TApplication implements Runnable { TWindow window = new TWindow(this, title, 0, 0, width, height); return window; } + /** * Convenience function to create a new window and make it active. * Window will be located at (0, 0). @@ -2805,4 +2813,17 @@ public class TApplication implements Runnable { return window; } + /** + * Convenience function to open a file in an editor window and make it + * active. + * + * @param file the file to open + * @throws IOException if a java.io operation throws + */ + public final TEditorWindow addEditor(final File file) throws IOException { + + TEditorWindow editor = new TEditorWindow(this, file); + return editor; + } + }