Skip to main content

detect

Function detect 

Source
pub fn detect() -> TerminalCaps
Expand description

Detects terminal graphics capabilities from the process environment.

Examples found in repository?
examples/footers.rs (line 54)
53async fn main() -> io::Result<()> {
54	let caps = detect();
55	let charset = UiContext::default().with_terminal_caps(&caps).charset;
56	let mut terminal = Terminal::enter(TerminalOptions::new(caps).mouse(true))?;
57	let mut renderer = Renderer::new(TtyOut::new()?);
58	renderer.apply_caps(&caps)?;
59	match run(&mut terminal, &mut renderer, charset).await {
60		Ok(()) => terminal.leave_alt(),
61		Err(error) => {
62			let _ = terminal.leave_alt();
63			Err(error)
64		},
65	}
66}
More examples
Hide additional examples
examples/chat/main.rs (line 54)
53async fn main() -> io::Result<()> {
54	let caps = detect();
55	// One detected presentation context — charset, graphics, appearance —
56	// threads through every scene instead of per-module hardcodes.
57	let ctx = UiContext::default().with_terminal_caps(&caps);
58	let mut terminal =
59		Terminal::enter(TerminalOptions::new(caps).cursor_style(CursorStyle::BlinkingBar))?;
60	let mut renderer = Renderer::new(TtyOut::new()?);
61	renderer.apply_caps(&caps)?;
62	run(&mut terminal, &mut renderer, &ctx).await
63}