Class TermiosMapping

java.lang.Object
org.jline.terminal.impl.TermiosMapping
Direct Known Subclasses:
AixTermiosMapping, FreeBsdTermiosMapping, LinuxTermiosMapping, OsXTermiosMapping, SolarisTermiosMapping

public abstract class TermiosMapping extends Object
Converts between JLine Attributes and platform-native TermiosData.

Each platform subclass provides EnumMap tables that map JLine flag/control-char enums to their native bitmask or c_cc index values. The base class iterates those tables in toTermios(Attributes, TermiosData) and toAttributes(TermiosData), so subclasses are pure data declarations with no conversion logic.

See Also:
  • Constructor Details

  • Method Details

    • toAttributes

      public final Attributes toAttributes(TermiosData tio)
      Converts native termios data to JLine Attributes.
      Parameters:
      tio - the native termios data
      Returns:
      the corresponding JLine attributes
    • toTermios

      public final TermiosData toTermios(Attributes attr)
      Converts JLine Attributes to native termios data.

      Unmapped bits such as baud-rate flags and c_ispeed/c_ospeed are zero in the returned structure. Prefer toTermios(Attributes, TermiosData) when applying attributes onto an existing terminal so those fields are preserved.

      Parameters:
      attr - the JLine attributes
      Returns:
      the corresponding native termios data
    • toTermios

      public final TermiosData toTermios(Attributes attr, TermiosData existing)
      Converts JLine Attributes onto an existing native termios snapshot.

      Mapped flags and control characters are replaced from attr. Unmapped bits (including baud-rate flags such as CBAUD/CBAUDEX), input/output speeds, and unmapped c_cc entries from existing are preserved. When existing is null, this is equivalent to toTermios(Attributes).

      Parameters:
      attr - the JLine attributes
      existing - the current native termios data, or null
      Returns:
      native termios data with JLine flags applied
    • forCurrentPlatform

      public static TermiosMapping forCurrentPlatform()
      Returns the TermiosMapping for the current operating system.

      The result is cached after the first call via a lazy initialization holder, so this method is safe to call from any context without performance concerns.

      Returns:
      the platform-specific mapping
      Throws:
      UnsupportedOperationException - if the OS is not recognized