diff options
Diffstat (limited to 'src/display/components')
-rw-r--r-- | src/display/components/help_text.rs | 20 | ||||
-rw-r--r-- | src/display/components/layout.rs | 4 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/display/components/help_text.rs b/src/display/components/help_text.rs index 2b49551..7d66ad8 100644 --- a/src/display/components/help_text.rs +++ b/src/display/components/help_text.rs @@ -9,10 +9,14 @@ pub struct HelpText { pub show_dns: bool, } -const TEXT_WHEN_PAUSED: &str = " Press <SPACE> to resume"; -const TEXT_WHEN_NOT_PAUSED: &str = " Press <SPACE> to pause"; +const FIRST_WIDTH_BREAKPOINT: u16 = 76; +const SECOND_WIDTH_BREAKPOINT: u16 = 54; + +const TEXT_WHEN_PAUSED: &str = " Press <SPACE> to resume."; +const TEXT_WHEN_NOT_PAUSED: &str = " Press <SPACE> to pause."; const TEXT_WHEN_DNS_NOT_SHOWN: &str = " (DNS queries hidden)."; const TEXT_WHEN_DNS_SHOWN: &str = " (DNS queries shown)."; +const TEXT_TAB_TIP: &str = " Use <TAB> to rearrange tables."; impl HelpText { pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) { @@ -23,14 +27,22 @@ impl HelpText { TEXT_WHEN_NOT_PAUSED }; - let dns_content = if self.show_dns { + let dns_content = if rect.width <= FIRST_WIDTH_BREAKPOINT { + "" + } else if self.show_dns { TEXT_WHEN_DNS_SHOWN } else { TEXT_WHEN_DNS_NOT_SHOWN }; + let tab_text = if rect.width <= SECOND_WIDTH_BREAKPOINT { + "" + } else { + TEXT_TAB_TIP + }; + [Text::styled( - format!("{}{}", pause_content, dns_content), + format!("{}{}{}", pause_content, tab_text, dns_content), Style::default().modifier(Modifier::BOLD), )] }; diff --git a/src/display/components/layout.rs b/src/display/components/layout.rs index d3edb81..51c0175 100644 --- a/src/display/components/layout.rs +++ b/src/display/components/layout.rs @@ -100,12 +100,12 @@ impl<'a> Layout<'a> { } } - pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect) { + pub fn render(&self, frame: &mut Frame<impl Backend>, rect: Rect, ui_offset: usize) { 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) { - if let Some(child) = self.children.get(i) { + if let Some(child) = self.children.get((i + ui_offset) % self.children.len()) { child.render(frame, *rect); } } |