#18 move to event-driven main loop
[fanfix.git] / src / jexer / tterminal / ECMA48.java
index 69a9da12191dc65fad624177c93935488489c9a6..46952da4b19066ce96b8dab768074e054e5e3665 100644 (file)
@@ -302,6 +302,21 @@ public class ECMA48 implements Runnable {
         }
     }
 
+    /**
+     * The enclosing listening object.
+     */
+    private DisplayListener listener;
+
+    /**
+     * Set a listening object.
+     *
+     * @param listener the object that will have displayChanged() called
+     * after bytes are received from the remote terminal
+     */
+    public void setListener(final DisplayListener listener) {
+        this.listener = listener;
+    }
+
     /**
      * When true, the reader thread is expected to exit.
      */
@@ -6024,6 +6039,10 @@ public class ECMA48 implements Runnable {
                             consume((char)ch);
                         }
                     }
+                    // Permit my enclosing UI to know that I updated.
+                    if (listener != null) {
+                        listener.displayChanged();
+                    }
                 }
                 // System.err.println("end while loop"); System.err.flush();
             } catch (IOException e) {