Adopt clap::ValueEnum for Group and tidy menu view

- Derive `ValueEnum` for `Group` and remove its custom `iter` method.
- Update keybindings widget to use `Group::value_variants()` and adjust
  containment and filtering logic.
- Replace view option generation with a `format_view_string` helper that
  inserts a space before the second capital letter, eliminating the
  previous filter for “MAIN MENU”.
- Adjust imports to include `clap::ValueEnum` where needed.
This commit is contained in:
2026-03-14 20:13:41 +01:00
parent 61e9dedfe8
commit 3d0aa42d7d
3 changed files with 28 additions and 33 deletions
+2 -9
View File
@@ -1,3 +1,4 @@
use clap::ValueEnum;
use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -11,21 +12,13 @@ pub enum Action {
Esc,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, ValueEnum)]
pub enum Group {
Movement,
Select,
Quit,
}
impl Group {
pub fn iter() -> impl Iterator<Item = Group> {
[Group::Movement, Group::Select, Group::Quit]
.iter()
.copied()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct KeyBinding {
pub action: Action,