KeybindingsWidget now accepts actions

Views now pass a list of `Action` values to `KeybindingsWidget` instead
of
pre‑resolved `KeyBinding` references. The widget resolves the bindings
internally using `binding_for`, simplifying import statements and view
logic.
This commit is contained in:
GarandPLG committed 2026-03-15 22:00:00 +01:00
1 parent acc6ba08f3
commit 9d4ff19b6e
4 files changed
+27 -40

No files matched your search

+6 -4
View File
@@ -1,6 +1,4 @@
use std::collections::HashSet;
use crate::app::keybindings::{Group, KeyBinding};
use crate::app::keybindings::{Action, Group, KeyBinding, binding_for};
use clap::ValueEnum;
use ratatui::{
buffer::Buffer,
@@ -9,13 +7,17 @@ use ratatui::{
text::Line,
widgets::{Block, Borders, Padding, Paragraph, Widget},
};
use std::collections::HashSet;
pub struct KeybindingsWidget {
grouped: Vec<Paragraph<'static>>,
}
impl KeybindingsWidget {
pub fn new(keybindings: Vec<Option<&'static KeyBinding>>) -> Self {
pub fn new(actions: Vec<Action>) -> Self {
let keybindings: Vec<Option<&'static KeyBinding>> =
actions.iter().map(|a| binding_for(*a)).collect();
let used_groups: HashSet<Group> = keybindings
.iter()
.filter_map(|b| b.map(|binding| binding.group))