Class AbstractTerminal

  • All Implemented Interfaces:
    InputProvider, Terminal, java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    DefaultVirtualTerminal, StreamBasedTerminal

    public abstract class AbstractTerminal
    extends java.lang.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.
    • Constructor Detail

      • AbstractTerminal

        protected AbstractTerminal()
    • Method Detail

      • 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:
        TerminalResizeListener
      • 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 java.io.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:
        java.io.IOException - If there was an I/O error when setting up the TextGraphics object