Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,35 @@ where
.margin(2)
.split(f.size());

let white = Style::default().fg(app.user_config.theme.text);
let gray = Style::default().fg(app.user_config.theme.text);
// Create a one-column table to avoid flickering due to non-determinism when
// resolving constraints on widths of table columns.
let format_row = |r: Vec<String>| vec![format!("{:50}{:40}{:20}", r[0], r[1], r[2])];

let help_menu_style = Style::default().fg(app.user_config.theme.text);
let header = ["Description", "Event", "Context"];
let header = format_row(header.iter().map(|s| s.to_string()).collect());

let help_docs = get_help_docs(&app.user_config.keys);
let help_docs = help_docs.into_iter().map(format_row).collect::<Vec<_>>();
let help_docs = &help_docs[app.help_menu_offset as usize..];

let rows = help_docs
.iter()
.map(|item| Row::StyledData(item.iter(), gray));
.map(|item| Row::StyledData(item.iter(), help_menu_style));

let help_menu = Table::new(header.iter(), rows)
.block(
Block::default()
.borders(Borders::ALL)
.style(white)
.title(Span::styled("Help (press <Esc> to go back)", gray))
.border_style(gray),
.style(help_menu_style)
.title(Span::styled(
"Help (press <Esc> to go back)",
help_menu_style,
))
.border_style(help_menu_style),
)
.style(Style::default().fg(app.user_config.theme.text))
.widths(&[
Constraint::Length(50),
Constraint::Length(40),
Constraint::Length(20),
]);
.style(help_menu_style)
.widths(&[Constraint::Max(110)]);
f.render_widget(help_menu, chunks[0]);
}

Expand Down