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
+4 -3
View File
@@ -1,6 +1,7 @@
use std::collections::HashSet;
use crate::app::keybindings::{Group, KeyBinding};
use clap::ValueEnum;
use ratatui::{
buffer::Buffer,
layout::{Alignment, Constraint, Layout, Rect},
@@ -21,14 +22,14 @@ impl KeybindingsWidget {
.collect();
let mut grouped_keybindings: Vec<Paragraph<'static>> = Vec::new();
for (i, group) in Group::iter().enumerate() {
if !used_groups.contains(&group) {
for (i, group) in Group::value_variants().iter().enumerate() {
if !used_groups.contains(group) {
continue;
}
let grouped_lines: Vec<Line<'_>> = keybindings
.iter()
.filter(|b| b.as_ref().map_or(false, |kb| kb.group == group))
.filter(|b| b.as_ref().map_or(false, |kb| kb.group == *group))
.filter_map(|b| {
b.as_ref().map(|kb| {
Line::from_iter([