Skip to content
Snippets Groups Projects

WIP: Use /dev/tty to check terminal size

Open 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

Members who can merge are allowed to add commits.

Pipeline #3355 passed

Pipeline passed for d88a080d on xPMo:tty_size

Approval is optional
The target branch master does not exist. Please restore it or use a different target branch.

Merge details

  • The source branch is 90 commits behind the target branch.
  • 1 commit and 1 merge commit will be added to master.
  • Source branch will be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading