diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-07 14:45:09 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-07 14:45:09 +0530 |
commit | 05ed8c494a1201daa4daa1506455a52f8b2b5b8e (patch) | |
tree | 55890350fac5c8ef1480c3651ac91877cf530f92 /src/interactive | |
parent | f34ceeb91f41298278f4be62a053308946d41ea7 (diff) |
Only show hotkey for deletion when focus is on the mark pane
Diffstat (limited to 'src/interactive')
-rw-r--r-- | src/interactive/widgets/help.rs | 9 | ||||
-rw-r--r-- | src/interactive/widgets/mark.rs | 73 |
2 files changed, 49 insertions, 33 deletions
diff --git a/src/interactive/widgets/help.rs b/src/interactive/widgets/help.rs index 02698e6..652cf48 100644 --- a/src/interactive/widgets/help.rs +++ b/src/interactive/widgets/help.rs @@ -137,6 +137,15 @@ impl HelpPane { hotkey("<space bar>", "Toggle the currently selected entry", None); spacer(); } + title("Keys in the Mark pane"); + { + hotkey( + "Ctrl + Shift + r", + "Permanently delete all marked entries without prompt!", + None, + ); + spacer(); + } title("Keys for application control"); { hotkey( diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs index c877a28..2b4f8f7 100644 --- a/src/interactive/widgets/mark.rs +++ b/src/interactive/widgets/mark.rs @@ -185,41 +185,48 @@ impl MarkPane { let inner_area = block.inner(area); block.draw(area, buf); - let (help_line_area, list_area) = { - let regions = Layout::default() - .direction(Direction::Vertical) - .constraints([Constraint::Length(1), Constraint::Max(256)].as_ref()) - .split(inner_area); - (regions[0], regions[1]) - }; + let list_area = if self.has_focus { + let (help_line_area, list_area) = { + let regions = Layout::default() + .direction(Direction::Vertical) + .constraints([Constraint::Length(1), Constraint::Max(256)].as_ref()) + .split(inner_area); + (regions[0], regions[1]) + }; - let default_style = Style { - fg: Color::Black, - bg: Color::White, - modifier: Modifier::BOLD, - ..Default::default() + let default_style = Style { + fg: Color::Black, + bg: Color::White, + modifier: Modifier::BOLD, + ..Default::default() + }; + Paragraph::new( + [ + Text::Styled( + " Ctrl + Shift + r".into(), + Style { + fg: Color::Red, + modifier: default_style.modifier | Modifier::RAPID_BLINK, + ..default_style + }, + ), + Text::Styled( + " permanently deletes list without prompt".into(), + default_style, + ), + ] + .iter(), + ) + .style(Style { + bg: Color::White, + ..Style::default() + }) + .draw(help_line_area, buf); + list_area + } else { + inner_area }; - Paragraph::new( - [ - Text::Styled( - " Ctrl + Shift + r".into(), - Style { - fg: Color::Red, - ..default_style - }, - ), - Text::Styled( - " permanently deletes list without prompt".into(), - default_style, - ), - ] - .iter(), - ) - .style(Style { - bg: Color::White, - ..Style::default() - }) - .draw(help_line_area, buf); + let props = ListProps { block: None, entry_in_view, |