feat: add extended help (#1540)

Given some of the questions we've had lately, I think it's sensible to
add extended help to the top of the Atuin window.

Future plans: Ctrl-<something else> to open up a help popup, with all
common keys
This commit is contained in:
Ellie Huxtable 2024-01-10 14:07:40 +00:00 committed by GitHub
parent 99f76ced50
commit 6dda16d047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -390,9 +390,9 @@ impl State {
.direction(Direction::Horizontal) .direction(Direction::Horizontal)
.constraints( .constraints(
[ [
Constraint::Ratio(1, 3), Constraint::Ratio(1, 5),
Constraint::Ratio(1, 3), Constraint::Ratio(3, 5),
Constraint::Ratio(1, 3), Constraint::Ratio(1, 5),
] ]
.as_ref(), .as_ref(),
) )
@ -429,29 +429,37 @@ impl State {
fn build_title(&mut self) -> Paragraph { fn build_title(&mut self) -> Paragraph {
let title = if self.update_needed.is_some() { let title = if self.update_needed.is_some() {
let version = self.update_needed.clone().unwrap();
Paragraph::new(Text::from(Span::styled( Paragraph::new(Text::from(Span::styled(
format!(" Atuin v{VERSION} - UPDATE AVAILABLE {version}"), format!("Atuin v{VERSION} - UPGRADE"),
Style::default().add_modifier(Modifier::BOLD).fg(Color::Red), Style::default().add_modifier(Modifier::BOLD).fg(Color::Red),
))) )))
} else { } else {
Paragraph::new(Text::from(Span::styled( Paragraph::new(Text::from(Span::styled(
format!(" Atuin v{VERSION}"), format!("Atuin v{VERSION}"),
Style::default().add_modifier(Modifier::BOLD), Style::default().add_modifier(Modifier::BOLD),
))) )))
}; };
title title.alignment(Alignment::Left)
} }
#[allow(clippy::unused_self)] #[allow(clippy::unused_self)]
fn build_help(&mut self) -> Paragraph { fn build_help(&mut self) -> Paragraph {
let help = Paragraph::new(Text::from(Line::from(vec![ let help = Paragraph::new(Text::from(Line::from(vec![
Span::styled("Esc", Style::default().add_modifier(Modifier::BOLD)), Span::styled("<esc>", Style::default().add_modifier(Modifier::BOLD)),
Span::raw(" to exit"), Span::raw(": exit"),
Span::raw(", "),
Span::styled("<tab>", Style::default().add_modifier(Modifier::BOLD)),
Span::raw(": edit"),
Span::raw(", "),
Span::styled("<enter>", Style::default().add_modifier(Modifier::BOLD)),
Span::raw(": execute"),
Span::raw(", "),
Span::styled("<ctrl-r>", Style::default().add_modifier(Modifier::BOLD)),
Span::raw(": filter toggle"),
]))) ])))
.style(Style::default().fg(Color::DarkGray)) .style(Style::default().fg(Color::DarkGray))
.alignment(Alignment::Center); .alignment(Alignment::Center);
help help
} }