X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTApplication.java;h=ab9c1962f6334094a03c6342eaad21eee6a03e8e;hb=3e0743556d1f31723a11a6019b5c2b018b4b2104;hp=d735e48b8da93d500451c3571f1d67d1837a605e;hpb=591688f594b8268b0e940d3144fd0dac0885a74c;p=fanfix.git diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index d735e48..ab9c196 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -51,16 +51,19 @@ import jexer.event.TMenuEvent; import jexer.event.TMouseEvent; import jexer.event.TResizeEvent; import jexer.backend.Backend; +import jexer.backend.Screen; import jexer.backend.SwingBackend; import jexer.backend.ECMA48Backend; -import jexer.io.Screen; +import jexer.backend.TWindowBackend; import jexer.menu.TMenu; import jexer.menu.TMenuItem; import static jexer.TCommand.*; import static jexer.TKeypress.*; /** - * TApplication sets up a full Text User Interface application. + * TApplication is the main driver class for a full Text User Interface + * application. It manages windows, provides a menu bar and status bar, and + * processes events received from the user. */ public class TApplication implements Runnable { @@ -403,7 +406,15 @@ public class TApplication implements Runnable { * @return the Screen */ public final Screen getScreen() { - return backend.getScreen(); + if (backend instanceof TWindowBackend) { + // We are being rendered to a TWindow. We can't use its + // getScreen() method because that is how it is rendering to a + // hardware backend somewhere. Instead use its getOtherScreen() + // method. + return ((TWindowBackend) backend).getOtherScreen(); + } else { + return backend.getScreen(); + } } /** @@ -635,6 +646,12 @@ public class TApplication implements Runnable { switch (backendType) { case SWING: + // The default SwingBackend is 80x25, 20 pt font. If you want to + // change that, you can pass the extra arguments to the + // SwingBackend constructor here. For example, if you wanted + // 90x30, 16 pt font: + // + // backend = new SwingBackend(this, 90, 30, 16); backend = new SwingBackend(this); break; case XTERM: @@ -711,6 +728,7 @@ public class TApplication implements Runnable { */ public TApplication(final Backend backend) { this.backend = backend; + backend.setListener(this); TApplicationImpl(); } @@ -902,6 +920,13 @@ public class TApplication implements Runnable { // Main loop -------------------------------------------------------------- // ------------------------------------------------------------------------ + /** + * Force this application to exit. + */ + public void exit() { + quit = true; + } + /** * Run this application until it exits. */