Debian Codegraph @

debian/rust-vendor/crossterm/examples/is_tty.rs

raw
1 use crossterm::{
2 execute,
3 terminal::{size, SetSize},
4 tty::IsTty,
5 };
6 use std::io::{stdin, stdout};
7
8 pub fn main() {
9 println!("size: {:?}", size().unwrap());
10 execute!(stdout(), SetSize(10, 10)).unwrap();
11 println!("resized: {:?}", size().unwrap());
12
13 if stdin().is_tty() {
14 println!("Is TTY");
15 } else {
16 println!("Is not TTY");
17 }
18 }