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 {
* @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();
+ }
}
/**
*/
public TApplication(final Backend backend) {
this.backend = backend;
+ backend.setListener(this);
TApplicationImpl();
}
// Main loop --------------------------------------------------------------
// ------------------------------------------------------------------------
+ /**
+ * Force this application to exit.
+ */
+ public void exit() {
+ quit = true;
+ }
+
/**
* Run this application until it exits.
*/