Refactor view handling and keybinding API

Move the `View` enum to a dedicated module and implement `Widget` for
`&App` there.
Rename `default_view_keybindings` to `default_keybindings` and adjust
its
signature. Redesign `KeybindingsWidget` to accept an explicit list of
bindings instead of a `View`. Update imports, function signatures, and
rendering
logic across the codebase to reflect these changes.
This commit is contained in:
GarandPLG committed 2026-03-13 20:10:49 +01:00
1 parent d563bbc966
commit 61e9dedfe8
15 files changed
+109 -115

No files matched your search

+8 -6
View File
@@ -1,7 +1,6 @@
use crate::app::{
View,
keybindings::{Group, binding_for_view},
};
use std::collections::HashSet;
use crate::app::keybindings::{Group, KeyBinding};
use ratatui::{
buffer::Buffer,
layout::{Alignment, Constraint, Layout, Rect},
@@ -15,8 +14,11 @@ pub struct KeybindingsWidget {
}
impl KeybindingsWidget {
pub fn new(view: View) -> Self {
let (used_groups, keybindings) = binding_for_view(view);
pub fn new(keybindings: Vec<Option<&'static KeyBinding>>) -> Self {
let used_groups: HashSet<Group> = keybindings
.iter()
.filter_map(|b| b.map(|binding| binding.group))
.collect();
let mut grouped_keybindings: Vec<Paragraph<'static>> = Vec::new();
for (i, group) in Group::iter().enumerate() {