Interface TextGUI

All Known Subinterfaces:
WindowBasedTextGUI
All Known Implementing Classes:
AbstractTextGUI, MultiWindowTextGUI

public interface TextGUI
This is the base interface for advanced text GUIs supported in Lanterna. You may want to use this in combination with a TextGUIThread, that can be created/retrieved by using getGUIThread().
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Listener interface for TextGUI, firing on events related to the overall GUI
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a listener to this TextGUI to fire events on.
    Returns the interactable component currently in focus
    The first time this method is called, it will create a new TextGUIThread object that you can use to automatically manage this TextGUI instead of manually calling processInput() and updateScreen().
    Returns the Screen for this WindowBasedTextGUI
    Returns the theme currently assigned to this TextGUI
    boolean
    This method can be used to determine if any component has requested a redraw.
    boolean
    Drains the input queue and passes the key strokes to the GUI system for processing.
    void
    Removes a listener from this TextGUI so that it will no longer receive events
    void
    setTheme(Theme theme)
    Sets the global theme to be used by this TextGUI.
    void
    setVirtualScreenEnabled(boolean virtualScreenEnabled)
    This method controls whether or not the virtual screen should be used.
    void
    Updates the screen, to make any changes visible to the user.
  • Method Details

    • getTheme

      Theme getTheme()
      Returns the theme currently assigned to this TextGUI
      Returns:
      Currently active Theme
    • setTheme

      void setTheme(Theme theme)
      Sets the global theme to be used by this TextGUI. This value will be set on every TextGUIGraphics object created for drawing the GUI, but individual components can override this if they want. If you don't call this method you should assume that a default theme is assigned by the library.
      Parameters:
      theme - Theme to use as the default theme for this TextGUI
    • processInput

      boolean processInput() throws IOException
      Drains the input queue and passes the key strokes to the GUI system for processing. For window-based system, it will send each key stroke to the active window for processing. If the input read gives an EOF, it will throw EOFException and this is normally the signal to shut down the GUI (any command coming in before the EOF will be processed as usual before this).
      Returns:
      true if at least one key stroke was read and processed, false if there was nothing on the input queue (only for non-blocking IO)
      Throws:
      IOException - In case there was an underlying I/O error
      EOFException - In the input stream received an EOF marker
    • getScreen

      Screen getScreen()
      Returns the Screen for this WindowBasedTextGUI
      Returns:
      the Screen used by this WindowBasedTextGUI
    • updateScreen

      void updateScreen() throws IOException
      Updates the screen, to make any changes visible to the user.
      Throws:
      IOException - In case there was an underlying I/O error
    • isPendingUpdate

      boolean isPendingUpdate()
      This method can be used to determine if any component has requested a redraw. If this method returns true, you may want to call updateScreen().
      Returns:
      true if this TextGUI has a change and is waiting for someone to call updateScreen()
    • setVirtualScreenEnabled

      void setVirtualScreenEnabled(boolean virtualScreenEnabled)
      This method controls whether or not the virtual screen should be used. This is what enabled you to make your UI larger than what fits the terminal, as it will expand the virtual area and put in scrollbars. If set to false, the virtual screen will be bypassed and any content outside of the screen will be cropped. This property is true by default.
      Parameters:
      virtualScreenEnabled - If true, then virtual screen will be used, otherwise it is bypassed
    • getGUIThread

      TextGUIThread getGUIThread()
      The first time this method is called, it will create a new TextGUIThread object that you can use to automatically manage this TextGUI instead of manually calling processInput() and updateScreen(). After the initial call, it will return the same object as it was originally returning.
      Returns:
      A TextGUIThread implementation that can be used to asynchronously manage the GUI
    • getFocusedInteractable

      Interactable getFocusedInteractable()
      Returns the interactable component currently in focus
      Returns:
      Component that is currently in input focus
    • addListener

      void addListener(TextGUI.Listener listener)
      Adds a listener to this TextGUI to fire events on.
      Parameters:
      listener - Listener to add
    • removeListener

      void removeListener(TextGUI.Listener listener)
      Removes a listener from this TextGUI so that it will no longer receive events
      Parameters:
      listener - Listener to remove