diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-04 16:28:06 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-04 16:28:06 +0530 |
commit | 286bfd4cb2e3416fda987ff8ea9a6b70397b9970 (patch) | |
tree | 6e4606317630d213907ec49706854770064b3927 /src/interactive/widgets/help.rs | |
parent | e522160a66a770d88371922b479fc1f3837022b7 (diff) |
help comes to live, slowly
Diffstat (limited to 'src/interactive/widgets/help.rs')
-rw-r--r-- | src/interactive/widgets/help.rs | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/interactive/widgets/help.rs b/src/interactive/widgets/help.rs index 504443a..0a544d6 100644 --- a/src/interactive/widgets/help.rs +++ b/src/interactive/widgets/help.rs @@ -1,5 +1,8 @@ use tui::{ - buffer::Buffer, layout::Rect, style::Style, widgets::Block, widgets::Borders, widgets::Widget, + buffer::Buffer, + layout::Rect, + style::{Modifier, Style}, + widgets::{Block, Borders, Paragraph, Text, Widget}, }; #[derive(Copy, Clone)] @@ -12,10 +15,31 @@ pub struct HelpPane { impl Widget for HelpPane { fn draw(&mut self, area: Rect, buf: &mut Buffer) { - Block::default() + fn title(name: &str) -> Text { + Text::Styled( + format!("{}\n\n", name).into(), + Style { + modifier: Modifier::BOLD, + ..Default::default() + }, + ) + }; + fn hotkey(keys: &str, description: &str) -> Text<'static> { + Text::Styled( + format!("{} => {}\n", keys, description).into(), + Style { + ..Default::default() + }, + ) + }; + + let mut block = Block::default() .title("Help") .border_style(self.border_style) - .borders(Borders::ALL) - .draw(area, buf); + .borders(Borders::ALL); + block.draw(area, buf); + let area = block.inner(area).inner(1); + + Paragraph::new([title("Hotkeys"), hotkey("j", "move down")].iter()).draw(area, buf); } } |