generated from GarandPLG/rust-flake-template
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user