summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2020-03-29 22:45:44 +0800
committerSebastian Thiel <sebastian.thiel@icloud.com>2020-03-29 22:45:44 +0800
commit7689016c537d054a519e4e61c577e30645537213 (patch)
tree83f458bae9c199ae736b6a8931ec697782608bd8
parentd5ed498b592ff2b7f725163cae0c8426930c005c (diff)
Toggle help for entries and mark pane
-rw-r--r--src/interactive/widgets/entries.rs14
-rw-r--r--src/interactive/widgets/mark.rs14
2 files changed, 26 insertions, 2 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(),
+ );
+ }
}
}
}
diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs
index 96b9862..53833ae 100644
--- a/src/interactive/widgets/mark.rs
+++ b/src/interactive/widgets/mark.rs
@@ -20,6 +20,7 @@ use tui::{
};
use tui_react::{
draw_text_nowrap_fn,
+ util::rect::line_bound,
util::{block_width, rect},
List, ListProps,
};
@@ -373,7 +374,7 @@ impl MarkPane {
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 = " . = 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),
@@ -387,6 +388,17 @@ impl MarkPane {
|_, _, _| Style::default(),
);
}
+ let bound = line_bound(bound, bound.height.saturating_sub(1) as usize);
+ let help_text = " mark-toggle = space|d";
+ 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(),
+ );
+ }
}
}
}