mirror of
https://github.com/denisidoro/navi
synced 2024-11-26 05:20:21 +00:00
Add error info when getting terminal dimensions.
This commit is contained in:
parent
77d0de839e
commit
d371300fac
1 changed files with 5 additions and 4 deletions
|
@ -11,7 +11,7 @@ fn width_with_shell_out() -> u16 {
|
|||
.arg("size")
|
||||
.stderr(Stdio::inherit())
|
||||
.output()
|
||||
.unwrap()
|
||||
.expect("Failed to execute stty")
|
||||
} else {
|
||||
Command::new("stty")
|
||||
.arg("size")
|
||||
|
@ -19,15 +19,16 @@ fn width_with_shell_out() -> u16 {
|
|||
.arg("/dev/stderr")
|
||||
.stderr(Stdio::inherit())
|
||||
.output()
|
||||
.unwrap()
|
||||
.expect("Failed to execute stty")
|
||||
};
|
||||
|
||||
match output.status.code() {
|
||||
Some(0) => {
|
||||
let stdout = String::from_utf8(output.stdout).unwrap();
|
||||
let stdout = String::from_utf8(output.stdout).expect("Invalid utf8 output from stty");
|
||||
let mut data = stdout.split_whitespace();
|
||||
data.next();
|
||||
u16::from_str_radix(data.next().unwrap(), 10).unwrap()
|
||||
u16::from_str_radix(data.next().expect("Not enough data"), 10)
|
||||
.expect("Invalid base-10 number")
|
||||
}
|
||||
_ => 40,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue