Documentation
¶
Overview ¶
Package terminal is a generated GoMock package.
Index ¶
- Constants
- func ChildColorEnv(environ []string, destination io.Writer) []string
- func HasRealTTYInput() bool
- func IsSpeedLimited(speed float64) bool
- func IsTTYWriter(w io.Writer) bool
- type ColorProfile
- type Config
- type IOStream
- type IOWriter
- type MockIOWriter
- type MockIOWriterMockRecorder
- type MockTerminal
- func (m *MockTerminal) Alert()
- func (m *MockTerminal) ColorProfile() ColorProfile
- func (m *MockTerminal) ColorProfileFor(stream Stream) ColorProfile
- func (m *MockTerminal) EXPECT() *MockTerminalMockRecorder
- func (m *MockTerminal) Height(stream Stream) int
- func (m *MockTerminal) IsPiped(stream Stream) bool
- func (m *MockTerminal) IsTTY(stream Stream) bool
- func (m *MockTerminal) RestoreTitle()
- func (m *MockTerminal) SetTitle(title string)
- func (m *MockTerminal) Width(stream Stream) int
- func (m *MockTerminal) Write(content string) error
- type MockTerminalMockRecorder
- func (mr *MockTerminalMockRecorder) Alert() *gomock.Call
- func (mr *MockTerminalMockRecorder) ColorProfile() *gomock.Call
- func (mr *MockTerminalMockRecorder) ColorProfileFor(stream any) *gomock.Call
- func (mr *MockTerminalMockRecorder) Height(stream any) *gomock.Call
- func (mr *MockTerminalMockRecorder) IsPiped(stream any) *gomock.Call
- func (mr *MockTerminalMockRecorder) IsTTY(stream any) *gomock.Call
- func (mr *MockTerminalMockRecorder) RestoreTitle() *gomock.Call
- func (mr *MockTerminalMockRecorder) SetTitle(title any) *gomock.Call
- func (mr *MockTerminalMockRecorder) Width(stream any) *gomock.Call
- func (mr *MockTerminalMockRecorder) Write(content any) *gomock.Call
- type Option
- type PacingWriter
- type Stream
- type Terminal
Constants ¶
const ( // ANSI cursor control sequences. EscCarriageReturn = "\r" // Return cursor to start of line EscClearLine = "\x1b[K" // Clear from cursor to end of line EscResetLine = "\r\x1b[K" // Return to start and clear entire line EscCursorUp = "\x1b[A" // Move cursor up one line EscCursorDown = "\x1b[B" // Move cursor down one line EscSaveCursor = "\x1b[s" // Save cursor position EscRestoreCursor = "\x1b[u" // Restore cursor position )
Variables ¶
This section is empty.
Functions ¶
func ChildColorEnv ¶
ChildColorEnv preserves color preferences when a child's output is forwarded through a pipe to destination. It conveys rendering only; stdin and TTY/interactivity remain untouched. Explicit child force-color and opt-out settings are preserved. Parent global opt-outs still disable colors.
func HasRealTTYInput ¶ added in v1.223.0
func HasRealTTYInput() bool
HasRealTTYInput reports whether stdin is a physical terminal, ignoring --force-tty/ATMOS_FORCE_TTY. Forcing TTY mode can make output render as if a terminal were attached (screenshots, cast recordings), but it cannot conjure an input device — interactive readers (e.g. bubbletea) must not try to open /dev/tty when this returns false.
func IsSpeedLimited ¶ added in v1.222.0
IsSpeedLimited reports whether terminal output should be paced. A speed of 0 means unlimited output, which preserves existing behavior.
func IsTTYWriter ¶ added in v1.222.0
IsTTYWriter reports whether w is an interactive terminal file.
Types ¶
type ColorProfile ¶
type ColorProfile int
ColorProfile represents terminal color capabilities.
const ( ColorNone ColorProfile = iota // No color support Color16 // 16 colors (basic ANSI) Color256 // 256 colors ColorTrue // Truecolor (16 million colors) )
func (ColorProfile) String ¶
func (c ColorProfile) String() string
String returns the string representation of ColorProfile.
type Config ¶
type Config struct {
// From CLI flags
NoColor bool
Color bool
ForceColor bool
ForceTTY bool
// From environment variables
EnvNoColor bool // NO_COLOR
EnvCLIColor string // CLICOLOR
EnvCLIColorForce bool // CLICOLOR_FORCE
EnvTerm string // TERM
EnvColorTerm string // COLORTERM
EnvCI bool // CI
// From atmos.yaml
AtmosConfig schema.AtmosConfiguration
}
Config holds terminal configuration from various sources.
func (*Config) DetectColorProfile ¶
func (c *Config) DetectColorProfile(isTTY bool) ColorProfile
DetectColorProfile determines the terminal's color capabilities.
func (*Config) ShouldUseColor ¶
ShouldUseColor determines if color should be used based on config priority. Priority (highest to lowest): 1. NO_COLOR or --no-color disables all color. 2. CLICOLOR=0 disables color unless forced. 3. CLICOLOR_FORCE or --force-color forces color even for non-TTY output. 4. --color enables color for TTY output. 5. Atmos terminal settings control color, respecting TTY detection. 6. CI enables color by default. 7. Otherwise use TTY detection.
type IOStream ¶
type IOStream int
IOStream represents an I/O stream type for terminal operations. This mirrors io.Stream but avoids circular dependency.
type IOWriter ¶
type IOWriter interface {
// Write outputs content to the specified stream with automatic masking.
// stream values: 0=Data (stdout), 1=UI (stderr)
Write(stream int, content string) error
}
IOWriter is the interface for writing to I/O streams. This avoids circular dependency with pkg/io. The stream parameter uses int to allow different packages to define their own stream types.
type MockIOWriter ¶
type MockIOWriter struct {
// contains filtered or unexported fields
}
MockIOWriter is a mock of IOWriter interface.
func NewMockIOWriter ¶
func NewMockIOWriter(ctrl *gomock.Controller) *MockIOWriter
NewMockIOWriter creates a new mock instance.
func (*MockIOWriter) EXPECT ¶
func (m *MockIOWriter) EXPECT() *MockIOWriterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockIOWriterMockRecorder ¶
type MockIOWriterMockRecorder struct {
// contains filtered or unexported fields
}
MockIOWriterMockRecorder is the mock recorder for MockIOWriter.
type MockTerminal ¶
type MockTerminal struct {
// contains filtered or unexported fields
}
MockTerminal is a mock of Terminal interface.
func NewMockTerminal ¶
func NewMockTerminal(ctrl *gomock.Controller) *MockTerminal
NewMockTerminal creates a new mock instance.
func (*MockTerminal) ColorProfile ¶
func (m *MockTerminal) ColorProfile() ColorProfile
ColorProfile mocks base method.
func (*MockTerminal) ColorProfileFor ¶
func (m *MockTerminal) ColorProfileFor(stream Stream) ColorProfile
ColorProfileFor mocks base method.
func (*MockTerminal) EXPECT ¶
func (m *MockTerminal) EXPECT() *MockTerminalMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockTerminal) Height ¶
func (m *MockTerminal) Height(stream Stream) int
Height mocks base method.
func (*MockTerminal) IsPiped ¶
func (m *MockTerminal) IsPiped(stream Stream) bool
IsPiped mocks base method.
func (*MockTerminal) IsTTY ¶
func (m *MockTerminal) IsTTY(stream Stream) bool
IsTTY mocks base method.
func (*MockTerminal) RestoreTitle ¶
func (m *MockTerminal) RestoreTitle()
RestoreTitle mocks base method.
func (*MockTerminal) SetTitle ¶
func (m *MockTerminal) SetTitle(title string)
SetTitle mocks base method.
func (*MockTerminal) Width ¶
func (m *MockTerminal) Width(stream Stream) int
Width mocks base method.
func (*MockTerminal) Write ¶
func (m *MockTerminal) Write(content string) error
Write mocks base method.
type MockTerminalMockRecorder ¶
type MockTerminalMockRecorder struct {
// contains filtered or unexported fields
}
MockTerminalMockRecorder is the mock recorder for MockTerminal.
func (*MockTerminalMockRecorder) Alert ¶
func (mr *MockTerminalMockRecorder) Alert() *gomock.Call
Alert indicates an expected call of Alert.
func (*MockTerminalMockRecorder) ColorProfile ¶
func (mr *MockTerminalMockRecorder) ColorProfile() *gomock.Call
ColorProfile indicates an expected call of ColorProfile.
func (*MockTerminalMockRecorder) ColorProfileFor ¶
func (mr *MockTerminalMockRecorder) ColorProfileFor(stream any) *gomock.Call
ColorProfileFor indicates an expected call of ColorProfileFor.
func (*MockTerminalMockRecorder) Height ¶
func (mr *MockTerminalMockRecorder) Height(stream any) *gomock.Call
Height indicates an expected call of Height.
func (*MockTerminalMockRecorder) IsPiped ¶
func (mr *MockTerminalMockRecorder) IsPiped(stream any) *gomock.Call
IsPiped indicates an expected call of IsPiped.
func (*MockTerminalMockRecorder) IsTTY ¶
func (mr *MockTerminalMockRecorder) IsTTY(stream any) *gomock.Call
IsTTY indicates an expected call of IsTTY.
func (*MockTerminalMockRecorder) RestoreTitle ¶
func (mr *MockTerminalMockRecorder) RestoreTitle() *gomock.Call
RestoreTitle indicates an expected call of RestoreTitle.
func (*MockTerminalMockRecorder) SetTitle ¶
func (mr *MockTerminalMockRecorder) SetTitle(title any) *gomock.Call
SetTitle indicates an expected call of SetTitle.
type Option ¶
type Option func(*terminal)
Option configures Terminal.
func WithConfig ¶
WithConfig sets a custom config (for testing).
type PacingWriter ¶ added in v1.222.0
type PacingWriter struct {
// contains filtered or unexported fields
}
PacingWriter reveals complete lines at a configured lines-per-second rate. Partial trailing output is buffered until another write completes the line or Close is called.
func NewPacingWriter ¶ added in v1.222.0
func NewPacingWriter(writer io.Writer, speed float64) *PacingWriter
NewPacingWriter creates a writer that emits complete lines at speed lines per second.
func (*PacingWriter) Close ¶ added in v1.222.0
func (w *PacingWriter) Close() error
Close flushes any buffered partial trailing line immediately.
type Terminal ¶
type Terminal interface {
// Write outputs UI content to the terminal.
// Content flows: terminal.Write() → io.Write(UIStream) → masking → stderr
Write(content string) error
// IsTTY reports whether the stream supports terminal UI. TERM=dumb disables
// terminal UI unless --force-tty explicitly overrides it.
IsTTY(stream Stream) bool
// IsPiped returns whether the given stream is piped to/from another process.
IsPiped(stream Stream) bool
// ColorProfile returns the terminal's color capabilities, using stderr's TTY
// status (falling back to stdout) -- see ColorProfile's doc comment.
ColorProfile() ColorProfile
// ColorProfileFor returns the terminal's color capabilities for a specific
// output stream -- see ColorProfileFor's doc comment.
ColorProfileFor(stream Stream) ColorProfile
// Width returns the terminal width for the given stream.
// Returns 0 if width cannot be determined.
Width(stream Stream) int
// Height returns the terminal height for the given stream.
// Returns 0 if height cannot be determined.
Height(stream Stream) int
// SetTitle sets the terminal window title (if supported).
// Does nothing if terminal doesn't support titles or if disabled in config.
SetTitle(title string)
// RestoreTitle restores the original terminal title.
RestoreTitle()
// Alert emits a terminal bell/alert (if enabled).
Alert()
}
Terminal provides terminal capability detection and operations. Terminal writes UI output through the I/O layer for automatic masking.