Skip to main content

Crate use_terminal

Crate use_terminal 

Source
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§

TerminalHeight
A nonzero terminal height in rows.
TerminalSize
A terminal size value made from validated dimensions.
TerminalWidth
A nonzero terminal width in columns.

Enums§

ColorSupport
Primitive terminal color capability.
Interactivity
Primitive stream interactivity state.
TerminalDimensionError
Validation errors for terminal dimensions.

Functions§

detect_color_support
Detects color support using NO_COLOR, TERM, and COLORTERM.
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.