forked from extern/nushell
add height method to Host trait, and implementors (#3064)
This commit is contained in:
parent
11a9144e84
commit
892aae267d
5
crates/nu-engine/src/env/basic_host.rs
vendored
5
crates/nu-engine/src/env/basic_host.rs
vendored
@ -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
|
||||
}
|
||||
}
|
||||
|
9
crates/nu-engine/src/env/host.rs
vendored
9
crates/nu-engine/src/env/host.rs
vendored
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user