From 892aae267d3f6678532cdaf13ce517fcd4111106 Mon Sep 17 00:00:00 2001 From: rezural <69941255+rezural@users.noreply.github.com> Date: Wed, 17 Feb 2021 07:02:13 +1100 Subject: [PATCH] add height method to Host trait, and implementors (#3064) --- crates/nu-engine/src/env/basic_host.rs | 5 +++++ crates/nu-engine/src/env/host.rs | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/crates/nu-engine/src/env/basic_host.rs b/crates/nu-engine/src/env/basic_host.rs index 310d645f55..1dd521c5b3 100644 --- a/crates/nu-engine/src/env/basic_host.rs +++ b/crates/nu-engine/src/env/basic_host.rs @@ -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 + } } diff --git a/crates/nu-engine/src/env/host.rs b/crates/nu-engine/src/env/host.rs index 6496546ba3..f768b38032 100644 --- a/crates/nu-engine/src/env/host.rs +++ b/crates/nu-engine/src/env/host.rs @@ -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 { @@ -53,6 +54,10 @@ impl Host for Box { 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 + } }