Termisu::Terminal::Mode
Inherits Enum / Comparable / Value / Object
Terminal mode flags for controlling input behavior.
Maps to POSIX termios local flags (c_lflag). Combine flags to create custom modes, or use preset methods.
Standard Terminal Modes: | Mode | ICANON | ECHO | ISIG | IEXTEN | IXON | OPOST | ICRNL | Use Case | |------------|--------|------|------|--------|------|-------|-------|-----------------------------| | Raw | OFF | OFF | OFF | OFF | OFF | OFF | OFF | Full TUI control | | Cbreak | OFF | ON | ON | OFF | OFF | OFF | OFF | Char-by-char with feedback | | Cooked | ON | ON | ON | ON | - | - | - | Shell-out, external programs| | FullCooked | ON | ON | ON | ON | ON | ON | ON | Complete shell emulation | | Password | ON | OFF | ON | OFF | - | - | - | Secure text entry | | SemiRaw | OFF | OFF | ON | OFF | OFF | OFF | OFF | TUI with Ctrl+C support |
Example:
# Using a preset mode
mode = Termisu::Terminal::Mode.cooked
mode.canonical? # => true
mode.echo? # => true
# Custom mode: char-by-char with echo, no signals
custom = Termisu::Terminal::Mode::Echo
custom.echo? # => true
custom.signals? # => false
# Combining flags
mode = Termisu::Terminal::Mode::Canonical | Termisu::Terminal::Mode::Signals
Constants
No special handling - raw character-by-character input. Application receives every keystroke immediately.
Enable canonical (line-buffered) input mode. Input is collected until Enter is pressed. Terminal driver handles backspace, delete, line editing. Maps to ICANON flag.
Enable echo of typed characters to terminal. Characters are displayed as the user types. Maps to ECHO flag.
Enable signal generation from control characters. Ctrl+C sends SIGINT, Ctrl+Z sends SIGTSTP, Ctrl+\ sends SIGQUIT. Maps to ISIG flag.
Enable extended input processing. Implementation-defined extensions (e.g., Ctrl+V literal next). Maps to IEXTEN flag.
Enable software flow control (XON/XOFF). Ctrl+S pauses output, Ctrl+Q resumes. Maps to IXON flag in c_iflag.
Enable output processing. NL→CRNL translation and other output transformations. Maps to OPOST flag in c_oflag.
Enable CR to NL translation on input. Carriage return (0x0D) is translated to newline (0x0A). Maps to ICRNL flag in c_iflag.
Constructors
Cbreak mode - character-by-character with feedback. Each keystroke available immediately, with echo and signals. Use for: Interactive prompts, char-by-char input with visual feedback
Full cooked mode - standard terminal behavior. Line buffering, echo, signals, extended processing. Use for: Shell-out to external programs, REPL input
Complete cooked mode - full terminal driver processing. All standard cooked flags plus flow control, output processing, and CR→NL translation for maximum shell compatibility. Use for: Complete shell emulation, legacy program support
Password mode - secure text entry. Line buffering for editing, but no echo. User can use backspace but characters aren't displayed. Use for: Password prompts, sensitive input
Full raw mode - no terminal driver processing. Application handles all input, no echo, no signals. Use for: Full TUI applications (current Termisu default)
Semi-raw mode - raw with signal handling. Character-by-character, no echo, but Ctrl+C works. Use for: TUI that needs graceful Ctrl+C handling