Expand description
§use-terminal
Terminal capability primitives for RustUse CLI-adjacent code.
This crate provides terminal width and height wrapper types, color support enums, interactivity enums, and dependency-free detection helpers. It does not implement terminal UI, curses, layout, or styling.
§Example
use use_terminal::{ColorSupport, TerminalHeight, TerminalSize, TerminalWidth};
let size = TerminalSize::new(TerminalWidth::new(80)?, TerminalHeight::new(24)?);
let color = ColorSupport::from_env_values(None, Some("xterm-256color"), None);
assert_eq!(size.width().columns(), 80);
assert_eq!(color, ColorSupport::Ansi256);§Scope
Use this crate for capability vocabulary and basic std-based detection only.
Modules§
- prelude
- Commonly used terminal primitives.
Structs§
- Terminal
Height - A nonzero terminal height in rows.
- Terminal
Size - A terminal size value made from validated dimensions.
- Terminal
Width - A nonzero terminal width in columns.
Enums§
- Color
Support - Primitive terminal color capability.
- Interactivity
- Primitive stream interactivity state.
- Terminal
Dimension Error - Validation errors for terminal dimensions.
Functions§
- detect_
color_ support - Detects color support using
NO_COLOR,TERM, andCOLORTERM. - stderr_
interactivity - Detects whether stderr is attached to a terminal.
- stdin_
interactivity - Detects whether stdin is attached to a terminal.
- stdout_
interactivity - Detects whether stdout is attached to a terminal.