Skip to content

WIP: Use /dev/tty to check terminal size

xPMo requested to merge xPMo/termion:tty_size into master

Related issues: #163 #89. This will solve the root cause of #89.

Without this MR:

$ cargo run --example=size | cat
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `/home/pmo/Repos/rust-termion/target/debug/examples/size`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 25, kind: Other, message: "Inappropriate ioctl for device" }', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

With this MR:

$ cargo run --example=size | cat
    Finished dev [unoptimized + debuginfo] target(s) in 0.75s
     Running `/home/pmo/Repos/rust-termion/target/debug/examples/size`
Size is (135, 72)

Note that this will also allow the associated test to pass when stdout is not a tty.


Feedback is appreciated, I am not an expert on idiomatic Rust. Let me know if this is better rolled into a full refactor for any filedes.

Merge request reports