Class AbstractTerminal

java.lang.Object
com.googlecode.lanterna.terminal.AbstractTerminal
All Implemented Interfaces:
InputProvider, Terminal, Closeable, AutoCloseable
Direct Known Subclasses:
DefaultVirtualTerminal, StreamBasedTerminal

public abstract class AbstractTerminal extends Object implements Terminal
Containing a some very fundamental functionality that should be common (and usable) to all terminal implementations. All the Terminal implementers within Lanterna extends from this class.
  • Field Details

  • Constructor Details

    • AbstractTerminal

      protected AbstractTerminal()
  • Method Details

    • addResizeListener

      public void addResizeListener(TerminalResizeListener listener)
      Description copied from interface: Terminal
      Adds a TerminalResizeListener to be called when the terminal has changed size. There is no guarantee that this listener will really be invoked when the terminal has changed size, at all depends on the terminal emulator implementation. Normally on Unix systems the WINCH signal will be sent to the process and lanterna can intercept this.

      There are no guarantees on what thread the call will be made on, so please be careful with what kind of operation you perform in this callback. You should probably not take too long to return.

      Specified by:
      addResizeListener in interface Terminal
      Parameters:
      listener - Listener object to be called when the terminal has been changed
      See Also:
    • removeResizeListener

      public void removeResizeListener(TerminalResizeListener listener)
      Description copied from interface: Terminal
      Removes a TerminalResizeListener from the list of listeners to be notified when the terminal has changed size
      Specified by:
      removeResizeListener in interface Terminal
      Parameters:
      listener - Listener object to remove
      See Also:
    • onResized

      protected void onResized(int columns, int rows)
      Call this method when the terminal has been resized or the initial size of the terminal has been discovered. It will trigger all resize listeners, but only if the size has changed from before.
      Parameters:
      columns - Number of columns in the new size
      rows - Number of rows in the new size
    • onResized

      protected void onResized(TerminalSize newSize)
      Call this method when the terminal has been resized or the initial size of the terminal has been discovered. It will trigger all resize listeners, but only if the size has changed from before.
      Parameters:
      newSize - Last discovered terminal size
    • newTextGraphics

      public TextGraphics newTextGraphics() throws IOException
      Description copied from interface: Terminal
      Creates a new TextGraphics object that uses this Terminal directly when outputting. Keep in mind that you are probably better off to switch to a Screen to make advanced text graphics more efficient. Also, this TextGraphics implementation will not call .flush() after any operation, so you'll need to do that on your own.
      Specified by:
      newTextGraphics in interface Terminal
      Returns:
      TextGraphics implementation that draws directly using this Terminal interface
      Throws:
      IOException - If there was an I/O error when setting up the TextGraphics object