Documentation
¶
Overview ¶
Package model provides rich domain models for terminal operations.
Index ¶
- type RawMode
- type Terminal
- func (t *Terminal) Capabilities() *value2.Capabilities
- func (t *Terminal) ColorDepth() value2.ColorDepth
- func (t *Terminal) IsRawMode() bool
- func (t *Terminal) RawMode() *RawMode
- func (t *Terminal) Size() value2.Size
- func (t *Terminal) SupportsANSI() bool
- func (t *Terminal) SupportsColor() bool
- func (t *Terminal) WithRawMode(rawMode *RawMode) *Terminal
- func (t *Terminal) WithSize(size value2.Size) *Terminal
- func (t *Terminal) WithoutRawMode() *Terminal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RawMode ¶
type RawMode struct {
// contains filtered or unexported fields
}
RawMode represents terminal raw mode state (entity with lifecycle).
Raw mode disables:
- Line buffering (input available immediately)
- Echo (typed characters not displayed)
- Signal generation (Ctrl+C doesn't send SIGINT)
- Input processing (Ctrl+S/Q, CR->NL translation)
This entity stores the original terminal state for restoration.
Invariants:
- OriginalState is never nil after creation
- Enabled flag accurately reflects raw mode status
Lifecycle:
- Created with original terminal state
- Enabled (raw mode activated)
- Disabled (terminal restored)
Platform-specific state:
- Unix: syscall.Termios
- Windows: uint32 (console mode)
func NewRawMode ¶
NewRawMode creates raw mode entity with original state. The state type depends on platform:
- Unix: syscall.Termios
- Windows: uint32
func (*RawMode) Disable ¶
Disable marks raw mode as disabled (immutable). Returns new RawMode instance with enabled flag cleared.
func (*RawMode) Enable ¶
Enable marks raw mode as enabled (immutable). Returns new RawMode instance with enabled flag set.
func (*RawMode) OriginalState ¶
func (r *RawMode) OriginalState() interface{}
OriginalState returns the saved terminal state for restoration. Type depends on platform - caller must type assert.
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal represents a terminal instance with its capabilities and state. This is the aggregate root for terminal operations.
Invariants:
- Capabilities is never nil
- Size is always valid (width, height >= 1)
- Terminal is immutable after creation
Lifecycle:
- Created with detected capabilities
- Can be put into raw mode (creates RawMode entity)
- Size can be updated on SIGWINCH
func NewTerminal ¶
func NewTerminal(caps *value2.Capabilities) *Terminal
NewTerminal creates a new Terminal with detected capabilities. Initial size defaults to 80x24 if not specified.
func (*Terminal) Capabilities ¶
func (t *Terminal) Capabilities() *value2.Capabilities
Capabilities returns terminal capabilities (immutable).
func (*Terminal) ColorDepth ¶
func (t *Terminal) ColorDepth() value2.ColorDepth
ColorDepth is a convenience method for getting color depth.
func (*Terminal) SupportsANSI ¶
SupportsANSI is a convenience method for checking ANSI support.
func (*Terminal) SupportsColor ¶
SupportsColor is a convenience method for checking color support.
func (*Terminal) WithRawMode ¶
WithRawMode returns new Terminal in raw mode (immutable). The RawMode entity contains the original terminal state for restoration.
func (*Terminal) WithSize ¶
WithSize returns new Terminal with updated size (immutable). This is called when SIGWINCH is received.
func (*Terminal) WithoutRawMode ¶
WithoutRawMode returns new Terminal not in raw mode (immutable). This is called after raw mode is successfully disabled.