Add 'src/jexer/' from commit 'cf01c92f5809a0732409e280fb0f32f27393618d'
[nikiroo-utils.git] / src / jexer / backend / Backend.java
index bb29b578c5387040257e209e4be58a836a6d24d6..eaed7e64966228e6386d21349c757ae80efaa5e2 100644 (file)
@@ -3,7 +3,7 @@
  *
  * The MIT License (MIT)
  *
- * Copyright (C) 2016 Kevin Lamonte
+ * Copyright (C) 2019 Kevin Lamonte
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -31,62 +31,74 @@ package jexer.backend;
 import java.util.List;
 
 import jexer.event.TInputEvent;
-import jexer.io.Screen;
-import jexer.session.SessionInfo;
 
 /**
- * This abstract class provides a screen, keyboard, and mouse to
- * TApplication.  It also exposes session information as gleaned from lower
- * levels of the communication stack.
+ * This interface provides a screen, keyboard, and mouse to TApplication.  It
+ * also exposes session information as gleaned from lower levels of the
+ * communication stack.
  */
-public abstract class Backend {
+public interface Backend {
 
     /**
-     * The session information.
+     * Get a SessionInfo, which exposes text width/height, language,
+     * username, and other information from the communication stack.
+     *
+     * @return the SessionInfo
      */
-    protected SessionInfo sessionInfo;
+    public SessionInfo getSessionInfo();
 
     /**
-     * Getter for sessionInfo.
+     * Get a Screen, which displays the text cells to the user.
      *
-     * @return the SessionInfo
+     * @return the Screen
      */
-    public final SessionInfo getSessionInfo() {
-        return sessionInfo;
-    }
+    public Screen getScreen();
 
     /**
-     * The screen to draw on.
+     * Classes must provide an implementation that syncs the logical screen
+     * to the physical device.
      */
-    protected Screen screen;
+    public void flushScreen();
 
     /**
-     * Getter for screen.
+     * Check if there are events in the queue.
      *
-     * @return the Screen
+     * @return if true, getEvents() has something to return to the application
      */
-    public final Screen getScreen() {
-        return screen;
-    }
+    public boolean hasEvents();
 
     /**
-     * Subclasses must provide an implementation that syncs the logical
-     * screen to the physical device.
+     * Classes must provide an implementation to get keyboard, mouse, and
+     * screen resize events.
+     *
+     * @param queue list to append new events to
      */
-    public abstract void flushScreen();
+    public void getEvents(List<TInputEvent> queue);
 
     /**
-     * Subclasses must provide an implementation to get keyboard, mouse, and
-     * screen resize events.
+     * Classes must provide an implementation that closes sockets, restores
+     * console, etc.
+     */
+    public void shutdown();
+
+    /**
+     * Classes must provide an implementation that sets the window title.
      *
-     * @param queue list to append new events to
+     * @param title the new title
+     */
+    public void setTitle(final String title);
+
+    /**
+     * Set listener to a different Object.
+     *
+     * @param listener the new listening object that run() wakes up on new
+     * input
      */
-    public abstract void getEvents(List<TInputEvent> queue);
+    public void setListener(final Object listener);
 
     /**
-     * Subclasses must provide an implementation that closes sockets,
-     * restores console, etc.
+     * Reload backend options from System properties.
      */
-    public abstract void shutdown();
+    public void reloadOptions();
 
 }