cutting v0.0.1
[nikiroo-utils.git] / src / jexer / TApplication.java
index 88b329f6f62158668562b821be59d235b67725c5..4c55aad9a70f20f83d63fdfb49e9b6b5df8c0e9f 100644 (file)
@@ -312,12 +312,26 @@ public class TApplication {
     public TApplication(final InputStream input,
         final OutputStream output) throws UnsupportedEncodingException {
 
-        if (System.getProperty("jexer.AWT", "false").equals("true")) {
+        // AWT is the default backend on Windows unless explicitly overridden
+        // by jexer.AWT.
+        boolean useAWT = false;
+        if (System.getProperty("os.name").startsWith("Windows")) {
+            useAWT = true;
+        }
+        if (System.getProperty("jexer.AWT") != null) {
+            if (System.getProperty("jexer.AWT", "false").equals("true")) {
+                useAWT = true;
+            } else {
+                useAWT = false;
+            }
+        }
+
+
+        if (useAWT) {
             backend     = new AWTBackend();
         } else {
             backend     = new ECMA48Backend(input, output);
         }
-
         theme           = new ColorTheme();
         desktopBottom   = getScreen().getHeight() - 1;
         fillEventQueue  = new ArrayList<TInputEvent>();
@@ -487,7 +501,9 @@ public class TApplication {
             doIdle();
 
             // Update the screen
-            drawAll();
+            synchronized (getScreen()) {
+                drawAll();
+            }
         }
 
         // Shutdown the consumer threads
@@ -1273,7 +1289,7 @@ public class TApplication {
      * @param title menu title
      * @return the new menu
      */
-    public final TMenu addMenu(String title) {
+    public final TMenu addMenu(final String title) {
         int x = 0;
         int y = 0;
         TMenu menu = new TMenu(this, x, y, title);