enum

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

None = 0

No special handling - raw character-by-character input. Application receives every keystroke immediately.

Canonical = 1

Enable canonical (line-buffered) input mode. Input is collected until Enter is pressed. Terminal driver handles backspace, delete, line editing. Maps to ICANON flag.

Echo = 2

Enable echo of typed characters to terminal. Characters are displayed as the user types. Maps to ECHO flag.

Signals = 4

Enable signal generation from control characters. Ctrl+C sends SIGINT, Ctrl+Z sends SIGTSTP, Ctrl+\ sends SIGQUIT. Maps to ISIG flag.

Extended = 8

Enable extended input processing. Implementation-defined extensions (e.g., Ctrl+V literal next). Maps to IEXTEN flag.

FlowControl = 16

Enable software flow control (XON/XOFF). Ctrl+S pauses output, Ctrl+Q resumes. Maps to IXON flag in c_iflag.

OutputProcessing = 32

Enable output processing. NL→CRNL translation and other output transformations. Maps to OPOST flag in c_oflag.

CrToNl = 64

Enable CR to NL translation on input. Carriage return (0x0D) is translated to newline (0x0A). Maps to ICRNL flag in c_iflag.

All = 127

Constructors

cbreak

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

Source
cooked

Full cooked mode - standard terminal behavior. Line buffering, echo, signals, extended processing. Use for: Shell-out to external programs, REPL input

Source
full_cooked

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

Source
password

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

Source
raw

Full raw mode - no terminal driver processing. Application handles all input, no echo, no signals. Use for: Full TUI applications (current Termisu default)

Source
semi_raw

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

Source

Instance methods

canonical?

Returns true if this enum value contains Canonical

Source
cr_to_nl?

Returns true if this enum value contains CrToNl

Source
echo?

Returns true if this enum value contains Echo

Source
extended?

Returns true if this enum value contains Extended

Source
flow_control?

Returns true if this enum value contains FlowControl

Source
none?

Returns true if this enum value contains None

Source
output_processing?

Returns true if this enum value contains OutputProcessing

Source
signals?

Returns true if this enum value contains Signals

Source