minicrossterm/examples/is_tty.rs

15 lines
348 B
Rust
Raw Normal View History

use crossterm::{tty::IsTty, terminal::{size, SetSize}, execute};
use std::io::{stdin, stdout};
pub fn main() {
println!("{:?}", size().unwrap());
execute!(stdout(), SetSize(10, 10)).unwrap();
println!("{:?}", size().unwrap());
if stdin().is_tty() {
println!("Is TTY");
} else {
println!("Is not TTY");
}
}