enum Termisu::Terminal::Mode

Overview

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

Defined in:

termisu/terminal/mode.cr

Enum Members

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

Instance Method Summary

Constructor Detail

def self.cbreak : self #

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


[View source]
def self.cooked : self #

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


[View source]
def self.full_cooked : self #

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


[View source]
def self.password : self #

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


[View source]
def self.raw : self #

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


[View source]
def self.semi_raw : self #

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


[View source]

Instance Method Detail

def canonical? #

Returns true if this enum value contains Canonical


[View source]
def cr_to_nl? #

Returns true if this enum value contains CrToNl


[View source]
def echo? #

Returns true if this enum value contains Echo


[View source]
def extended? #

Returns true if this enum value contains Extended


[View source]
def flow_control? #

Returns true if this enum value contains FlowControl


[View source]
def none? #

Returns true if this enum value contains None


[View source]
def output_processing? #

Returns true if this enum value contains OutputProcessing


[View source]
def signals? #

Returns true if this enum value contains Signals


[View source]