Class AbstractTerminal

java.lang.Object
org.aesh.terminal.tty.impl.AbstractTerminal
All Implemented Interfaces:
Closeable, AutoCloseable, Terminal
Direct Known Subclasses:
AbstractPosixTerminal, LineDisciplineTerminal, WinSysTerminal

public abstract class AbstractTerminal extends Object implements Terminal
Abstract base class providing common functionality for terminal implementations.
Author:
Stale W. Pedersen
  • Field Details

    • LOGGER

      protected final Logger LOGGER
      Logger for this terminal instance.
    • name

      protected final String name
      The terminal name.
    • type

      protected final String type
      The terminal type (e.g., "xterm", "vt100").
    • handlers

      protected final Map<Signal,Terminal.SignalHandler> handlers
      Map of signal types to their handlers.
    • device

      protected final Device device
      The device capabilities for this terminal.
  • Constructor Details

    • AbstractTerminal

      public AbstractTerminal(String name, String type) throws IOException
      Creates a new terminal with the specified name and type using default signal handling.
      Parameters:
      name - the terminal name
      type - the terminal type
      Throws:
      IOException - if an I/O error occurs during initialization
    • AbstractTerminal

      public AbstractTerminal(String name, String type, Terminal.SignalHandler signalHandler) throws IOException
      Creates a new terminal with the specified name, type, and signal handler.
      Parameters:
      name - the terminal name
      type - the terminal type
      signalHandler - the default handler for all signals
      Throws:
      IOException - if an I/O error occurs during initialization
  • Method Details

    • handle

      public Terminal.SignalHandler handle(Signal signal, Terminal.SignalHandler handler)
      Specified by:
      handle in interface Terminal
    • raise

      public void raise(Signal signal)
      Specified by:
      raise in interface Terminal
    • handleDefaultSignal

      protected void handleDefaultSignal(Signal signal)
      Handles the default behavior for a signal when no custom handler is registered. Subclasses can override this method to provide default signal handling behavior.
      Parameters:
      signal - the signal to handle
    • echoSignal

      protected void echoSignal(Signal signal)
      Echoes the control character representation of a signal to the terminal output. For example, SIGINT is echoed as "^C".
      Parameters:
      signal - the signal whose control character should be echoed
    • echo

      public boolean echo()
      Specified by:
      echo in interface Terminal
    • echo

      public boolean echo(boolean echo)
      Specified by:
      echo in interface Terminal
    • getName

      public String getName()
      Specified by:
      getName in interface Terminal
    • getType

      public String getType()
      Returns the terminal type identifier.
      Returns:
      the terminal type (e.g., "xterm", "vt100")
    • device

      public Device device()
      Specified by:
      device in interface Terminal