diff --git a/src/interactive/widgets/entries.rs b/src/interactive/widgets/entries.rs index adb8a083..9f483e48 100644 --- a/src/interactive/widgets/entries.rs +++ b/src/interactive/widgets/entries.rs @@ -12,7 +12,11 @@ use tui::{ style::{Color, Modifier, Style}, widgets::{Block, Borders, Text}, }; -use tui_react::{fill_background_to_right, List, ListProps}; +use tui_react::{ + draw_text_nowrap_fn, fill_background_to_right, + util::{block_width, rect}, + List, ListProps, +}; pub struct EntriesProps<'a> { pub tree: &'a Tree, @@ -155,5 +159,22 @@ impl Entries { ); list.render(props, lines, area, buf); + + if *is_focussed { + let help_text = " . = o|.. = u || ⇊ = CTRL+d|↓ = j|⇈ = CTRL+u|↑ = k "; + let help_text_block_width = block_width(help_text); + let bound = Rect { + width: area.width.saturating_sub(1), + ..area + }; + if block_width(&title) + help_text_block_width <= bound.width { + draw_text_nowrap_fn( + rect::snap_to_right(bound, help_text_block_width), + buf, + help_text, + |_, _, _| Style::default(), + ); + } + } } } diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs index 8f8ef7c4..96b9862c 100644 --- a/src/interactive/widgets/mark.rs +++ b/src/interactive/widgets/mark.rs @@ -18,7 +18,11 @@ use tui::{ widgets::Text, widgets::{Paragraph, Widget}, }; -use tui_react::{List, ListProps}; +use tui_react::{ + draw_text_nowrap_fn, + util::{block_width, rect}, + List, ListProps, +}; use unicode_segmentation::UnicodeSegmentation; pub enum MarkMode { @@ -366,6 +370,23 @@ impl MarkPane { block: None, entry_in_view, }; - self.list.render(props, entries, list_area, buf) + self.list.render(props, entries, list_area, buf); + + if has_focus { + let help_text = " . = o|.. = u || ⇊ = CTRL+d|↓ = j|⇈ = CTRL+u|↑ = k "; + let help_text_block_width = block_width(help_text); + let bound = Rect { + width: area.width.saturating_sub(1), + ..area + }; + if block_width(&title) + help_text_block_width <= bound.width { + draw_text_nowrap_fn( + rect::snap_to_right(bound, help_text_block_width), + buf, + help_text, + |_, _, _| Style::default(), + ); + } + } } }