From 7689016c537d054a519e4e61c577e30645537213 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 29 Mar 2020 22:45:44 +0800 Subject: Toggle help for entries and mark pane --- src/interactive/widgets/entries.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/interactive/widgets/entries.rs') 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(), + ); + } } } } -- cgit v1.2.3