1
0
mirror of https://github.com/nushell/nushell.git synced 2025-07-10 19:37:16 +02:00

add height method to Host trait, and implementors ()

This commit is contained in:
rezural
2021-02-17 07:02:13 +11:00
committed by GitHub
parent 11a9144e84
commit 892aae267d
2 changed files with 14 additions and 0 deletions
crates/nu-engine/src/env

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

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