Class Attributes

java.lang.Object
org.jline.terminal.Attributes

public class Attributes extends Object
Encapsulates terminal attributes and settings that control terminal behavior.

The Attributes class represents the terminal settings similar to the POSIX termios structure, providing control over terminal input/output behavior, control characters, and various flags. These attributes determine how the terminal processes input and output, handles special characters, and behaves in response to various conditions.

Terminal attributes are organized into several categories:

  • Input Flags - Control input processing (e.g., character mapping, parity checking)
  • Output Flags - Control output processing (e.g., newline translation)
  • Control Flags - Control hardware settings (e.g., baud rate, character size)
  • Local Flags - Control various terminal behaviors (e.g., echo, canonical mode)
  • Control Characters - Define special characters (e.g., EOF, interrupt, erase)

Attributes objects are typically obtained from a Terminal using Terminal.getAttributes(), modified as needed, and then applied back to the terminal using Terminal.setAttributes(Attributes).

Example usage:

 Terminal terminal = TerminalBuilder.terminal();

 // Get current attributes
 Attributes attrs = terminal.getAttributes();

 // Modify attributes
 attrs.setLocalFlag(LocalFlag.ECHO, false);  // Disable echo
 attrs.setInputFlag(InputFlag.ICRNL, false); // Disable CR to NL mapping
 attrs.setControlChar(ControlChar.VMIN, 1);   // Set minimum input to 1 character

 // Apply modified attributes
 terminal.setAttributes(attrs);
 
See Also: