add height method to Host trait, and implementors (#3064)

This commit is contained in:
rezural 2021-02-17 07:02:13 +11:00 committed by GitHub
parent 11a9144e84
commit 892aae267d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -74,4 +74,9 @@ impl Host for BasicHost {
term_width -= 1;
term_width
}
fn height(&self) -> usize {
let (_, term_height) = term_size::dimensions().unwrap_or((80, 20));
term_height
}
}

View file

@ -15,6 +15,7 @@ pub trait Host: Debug + Send {
fn env_rm(&mut self, k: OsString);
fn width(&self) -> usize;
fn height(&self) -> usize;
}
impl Host for Box<dyn Host> {
@ -53,6 +54,10 @@ impl Host for Box<dyn Host> {
fn width(&self) -> usize {
(**self).width()
}
fn height(&self) -> usize {
(**self).height()
}
}
#[derive(Debug)]
@ -124,4 +129,8 @@ impl Host for FakeHost {
fn width(&self) -> usize {
1
}
fn height(&self) -> usize {
1
}
}