summaryrefslogtreecommitdiffstats
path: root/src/display/components/layout.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/display/components/layout.rs')
-rw-r--r--src/display/components/layout.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/display/components/layout.rs b/src/display/components/layout.rs
index e5ca069..9854e3c 100644
--- a/src/display/components/layout.rs
+++ b/src/display/components/layout.rs
@@ -2,6 +2,7 @@ use ::tui::backend::Backend;
use ::tui::layout::{Constraint, Direction, Rect};
use ::tui::terminal::Frame;
+use super::HelpText;
use super::Table;
use super::TotalBandwidth;
@@ -9,18 +10,26 @@ const FIRST_HEIGHT_BREAKPOINT: u16 = 30;
const FIRST_WIDTH_BREAKPOINT: u16 = 120;
const SECOND_WIDTH_BREAKPOINT: u16 = 150;
-fn leave_gap_on_top_of_rect(rect: Rect) -> Rect {
- let app = ::tui::layout::Layout::default()
+fn top_app_and_bottom_split(rect: Rect) -> (Rect, Rect, Rect) {
+ let parts = ::tui::layout::Layout::default()
.direction(Direction::Vertical)
.margin(0)
- .constraints([Constraint::Length(1), Constraint::Length(rect.height - 1)].as_ref())
+ .constraints(
+ [
+ Constraint::Length(1),
+ Constraint::Length(rect.height - 2),
+ Constraint::Length(1),
+ ]
+ .as_ref(),
+ )
.split(rect);
- app[1]
+ (parts[0], parts[1], parts[2])
}
pub struct Layout<'a> {
pub header: TotalBandwidth<'a>,
pub children: Vec<Table<'a>>,
+ pub footer: HelpText,
}
impl<'a> Layout<'a> {
@@ -52,7 +61,7 @@ impl<'a> Layout<'a> {
}
}
pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) {
- let app = leave_gap_on_top_of_rect(rect);
+ let (top, app, bottom) = top_app_and_bottom_split(rect);
let layout_slots = self.build_layout(app);
for i in 0..layout_slots.len() {
if let Some(rect) = layout_slots.get(i) {
@@ -61,6 +70,7 @@ impl<'a> Layout<'a> {
}
}
}
- self.header.render(frame, rect);
+ self.header.render(frame, top);
+ self.footer.render(frame, bottom);
}
}