diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-22 11:33:23 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2020-07-22 11:33:23 +0800 |
commit | 8c2a174ed31cfc6e7095cf1cf4dbc24bf38ea975 (patch) | |
tree | 7ccf4dddb750c00fcf43eedc9ebe562ac49f7fbf | |
parent | 29ee421dd40666c53f659692a9a55cf8874cee1a (diff) |
Help is back to normal
-rw-r--r-- | src/interactive/widgets/help.rs | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/interactive/widgets/help.rs b/src/interactive/widgets/help.rs index 3318ec2..7ab556e 100644 --- a/src/interactive/widgets/help.rs +++ b/src/interactive/widgets/help.rs @@ -49,40 +49,43 @@ impl HelpPane { pub fn render(&mut self, props: impl Borrow<HelpPaneProps>, area: Rect, buf: &mut Buffer) { let lines = { let lines = RefCell::new(Vec::<Spans>::with_capacity(30)); - - let spacer = || { - lines.borrow_mut().push(Spans::from("")); - lines.borrow_mut().push(Spans::from("")); + let add_newlines = |n| { + for _ in 0..n { + lines.borrow_mut().push(Spans::from(Span::raw(""))) + } }; + + let spacer = || add_newlines(2); let title = |name| { lines.borrow_mut().push(Spans::from(Span::styled( - format!("{}\n\n", name), + format!("{}", name), Style { add_modifier: Modifier::BOLD | Modifier::UNDERLINED, ..Default::default() }, ))); + add_newlines(1); }; let hotkey = |keys, description, other_line: Option<&str>| { let separator_size = 3; let column_size = 11 + separator_size; - lines.borrow_mut().push(Spans::from(Span::styled( - format!( - "{:>column_size$}", - keys, - column_size = column_size - separator_size + lines.borrow_mut().push(Spans::from(vec![ + Span::styled( + format!( + "{:>column_size$}", + keys, + column_size = column_size - separator_size + ), + Style { + fg: Color::Green.into(), + ..Default::default() + }, ), - Style { - fg: Color::Green.into(), - ..Default::default() - }, - ))); - lines - .borrow_mut() - .push(Spans::from(Span::from(format!(" => {}\n", description)))); + Span::from(format!(" => {}", description)), + ])); if let Some(second_line) = other_line { lines.borrow_mut().push(Spans::from(Span::from(format!( - "{:>column_size$}{}\n", + "{:>column_size$}{}", "", second_line, column_size = column_size + 1 |