Class FfmTerminalProvider

java.lang.Object
org.jline.terminal.impl.ffm.FfmTerminalProvider
All Implemented Interfaces:
TerminalProvider

public class FfmTerminalProvider extends Object implements TerminalProvider
  • Constructor Details

    • FfmTerminalProvider

      public FfmTerminalProvider()
  • Method Details

    • name

      public String name()
      Description copied from interface: TerminalProvider
      Returns the name of this terminal provider.

      The provider name is a unique identifier that can be used to request this specific provider when creating terminals. Common provider names include "ffm", "jni", "exec", and "dumb".

      Specified by:
      name in interface TerminalProvider
      Returns:
      the name of this terminal provider
    • getConsoleCodepage

      public int getConsoleCodepage()
      Description copied from interface: TerminalProvider
      Retrieve the Windows console output code page. On Windows this returns the console output code page; on non-Windows platforms or when the code page cannot be determined this returns -1.
      Specified by:
      getConsoleCodepage in interface TerminalProvider
      Returns:
      the console output code page, or -1 if not available
    • sysTerminal

      public Terminal sysTerminal(String name, String type, boolean ansiPassThrough, Charset encoding, Charset inputEncoding, Charset outputEncoding, boolean nativeSignals, Terminal.SignalHandler signalHandler, boolean paused, SystemStream systemStream) throws IOException
      Creates a Terminal bound to the process system streams (stdin/stdout/stderr) or an equivalent PTY-backed terminal.
      Specified by:
      sysTerminal in interface TerminalProvider
      Parameters:
      name - terminal name or identifier
      type - terminal type (TERM)
      ansiPassThrough - ignored on POSIX ? only used on Windows
      encoding - overall character set for the terminal
      inputEncoding - character set used for input decoding
      outputEncoding - character set used for output encoding
      nativeSignals - if true, attempt to use native signal handling when available
      signalHandler - handler invoked for terminal signals
      paused - ignored on POSIX ? only used on Windows and PTY-backed terminals
      systemStream - which system stream this terminal should be associated with
      Returns:
      a Terminal instance bound to the specified system stream (or an equivalent PTY-backed terminal)
      Throws:
      IOException - if the native PTY or system terminal cannot be created or accessed
    • newTerminal

      public Terminal newTerminal(String name, String type, InputStream in, OutputStream out, Charset encoding, Charset inputEncoding, Charset outputEncoding, Terminal.SignalHandler signalHandler, boolean paused, Attributes attributes, Size size) throws IOException
      Description copied from interface: TerminalProvider
      Creates a new terminal with custom input and output streams.

      This method creates a terminal that is connected to the specified input and output streams. Such terminals can be used for various purposes, such as connecting to remote terminals over network connections or creating virtual terminals for testing.

      Specified by:
      newTerminal in interface TerminalProvider
      Parameters:
      name - the name of the terminal
      type - the terminal type (e.g., "xterm", "dumb")
      in - the input stream to read from
      out - the output stream to write to
      encoding - the general character encoding to use
      inputEncoding - the character encoding to use for input
      outputEncoding - the character encoding to use for output
      signalHandler - the signal handler to use
      paused - whether the terminal should start in a paused state
      attributes - the initial terminal attributes
      size - the initial terminal size
      Returns:
      a new terminal connected to the specified streams
      Throws:
      IOException - if an I/O error occurs
    • isSystemStream

      public boolean isSystemStream(SystemStream stream)
      Description copied from interface: TerminalProvider
      Checks if the specified system stream is available on this platform.

      This method determines whether the specified system stream (standard input, standard output, or standard error) is available for use on the current platform. Some platforms or environments may restrict access to certain system streams.

      Specified by:
      isSystemStream in interface TerminalProvider
      Parameters:
      stream - the system stream to check
      Returns:
      true if the system stream is available, false otherwise
    • isWindowsSystemStream

      public boolean isWindowsSystemStream(SystemStream stream)
    • isPosixSystemStream

      public boolean isPosixSystemStream(SystemStream stream)
    • systemStreamName

      public String systemStreamName(SystemStream stream)
      Description copied from interface: TerminalProvider
      Returns the name of the specified system stream on this platform.

      This method returns a platform-specific name or identifier for the specified system stream. The name may be used for display purposes or for accessing the stream through platform-specific APIs.

      Specified by:
      systemStreamName in interface TerminalProvider
      Parameters:
      stream - the system stream
      Returns:
      the name of the system stream on this platform
    • systemStreamWidth

      public int systemStreamWidth(SystemStream stream)
      Obtain the current width, in columns, of the specified system stream.
      Specified by:
      systemStreamWidth in interface TerminalProvider
      Parameters:
      stream - the system stream whose width to query
      Returns:
      the width in columns of the given system stream
    • registerSignal

      public Object registerSignal(String signal, Runnable handler)
      Register a handler to be invoked when the specified signal is delivered.
      Specified by:
      registerSignal in interface TerminalProvider
      Parameters:
      signal - the name of the signal to handle (platform-specific string)
      handler - the runnable to execute when the signal is received
      Returns:
      an opaque registration handle that can be passed to unregisterSignal to remove the handler
    • registerDefaultSignal

      public Object registerDefaultSignal(String signal)
      Register the default handler for the specified signal.

      When FFM signal handling is available, delegates entirely to FfmSignalHandler.registerDefault(String), which may return null to preserve a foreign handler (e.g. HotSpot's SIGQUIT thread-dump handler). In that case this method also returns null ? it does not fall back to Signals.registerDefault(String) because doing so would install SIG_DFL and clobber the very handler that the FFM probe chose to preserve.

      Falls back to Signals.registerDefault(String) only when FFM signal handling is unavailable on this platform.

      Specified by:
      registerDefaultSignal in interface TerminalProvider
      Parameters:
      signal - the name of the signal (for example, "INT" or "TERM")
      Returns:
      an object representing the installed registration, or null if the signal has a foreign handler that must be preserved, or the signal is unsupported
    • unregisterSignal

      public void unregisterSignal(String signal, Object registration)
      Unregisters a previously registered signal handler; uses FFM unregistration when the provided registration is an FFM registration, otherwise uses the platform fallback.
      Specified by:
      unregisterSignal in interface TerminalProvider
      Parameters:
      signal - the name of the signal to unregister (e.g., "INT", "TERM")
      registration - the registration token returned by a prior register call
    • toString

      public String toString()
      Provide a short identifying string for this terminal provider.
      Overrides:
      toString in class Object
      Returns:
      a string of the form "TerminalProvider[]" identifying the provider