Refactor to View enum and add keybindings

Replace the `default_window` string field with a `View` enum throughout
the
application. Introduce a new keybinding module providing `Action`,
`KeyBinding` structs and helper functions, and integrate a keybindings
widget
into the main menu. Update the CLI to accept a `View` value enum and
adjust
imports and event handling accordingly. Add a release profile in
`Cargo.toml` with LTO, single codegen unit, higher optimisation level
and
binary stripping for smaller, faster builds.
This commit is contained in:
2026-03-10 14:26:18 +01:00
parent 64eb906b5f
commit de42569a51
10 changed files with 147 additions and 43 deletions
+31
View File
@@ -0,0 +1,31 @@
use ratatui::{
crossterm::event::KeyCode,
layout::Alignment,
style::Stylize,
text::{Line, Span},
widgets::{Block, Borders, Paragraph},
};
use crate::app::{View, binding_for_view};
pub fn keybindings_widget(view: View) -> Paragraph<'static> {
let lines: Vec<Line> = binding_for_view(view)
.iter()
.map(|b| {
let key_span = match b.code {
KeyCode::Char(c) => Span::raw(c.to_string()),
other => Span::raw(format!("{:?}", other)),
}
.bold()
.red();
Line::from_iter([key_span, "\t - ".into(), b.description.into()])
})
.collect();
Paragraph::new(lines).alignment(Alignment::Left).block(
Block::default()
.borders(Borders::ALL)
.title("[ Keybindings ]"),
)
}