diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-03-29 22:45:44 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-03-29 22:45:44 +0800 |
commit | 7689016c537d054a519e4e61c577e30645537213 (patch) | |
tree | 83f458bae9c199ae736b6a8931ec697782608bd8 /src/interactive/widgets/entries.rs | |
parent | d5ed498b592ff2b7f725163cae0c8426930c005c (diff) |
Toggle help for entries and mark pane
Diffstat (limited to 'src/interactive/widgets/entries.rs')
-rw-r--r-- | src/interactive/widgets/entries.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/interactive/widgets/entries.rs b/src/interactive/widgets/entries.rs index 9f483e4..fc68f44 100644 --- a/src/interactive/widgets/entries.rs +++ b/src/interactive/widgets/entries.rs @@ -12,6 +12,7 @@ use tui::{ style::{Color, Modifier, Style}, widgets::{Block, Borders, Text}, }; +use tui_react::util::rect::line_bound; use tui_react::{ draw_text_nowrap_fn, fill_background_to_right, util::{block_width, rect}, @@ -161,7 +162,7 @@ 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 = " . = 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), @@ -175,6 +176,17 @@ impl Entries { |_, _, _| Style::default(), ); } + let bound = line_bound(bound, bound.height.saturating_sub(1) as usize); + let help_text = " mark-move = d | mark-toggle = space "; + let help_text_block_width = block_width(help_text); + if help_text_block_width <= bound.width { + draw_text_nowrap_fn( + rect::snap_to_right(bound, help_text_block_width), + buf, + help_text, + |_, _, _| Style::default(), + ); + } } } } |