Provide list of key groups in config crate
This also fixes the f1 menu not displaying the room group.
This commit is contained in:
parent
48279e879a
commit
101d36cd45
6 changed files with 93 additions and 50 deletions
|
|
@ -10,9 +10,33 @@ use toss::{Frame, Terminal, WidthDb};
|
|||
|
||||
pub use crate::keys::*;
|
||||
|
||||
pub struct KeyBindingInfo<'a> {
|
||||
pub name: &'static str,
|
||||
pub binding: &'a KeyBinding,
|
||||
pub description: &'static str,
|
||||
}
|
||||
|
||||
/// A group of related key bindings.
|
||||
pub trait KeyGroup {
|
||||
fn bindings(&self) -> Vec<(&KeyBinding, &'static str)>;
|
||||
const DESCRIPTION: &'static str;
|
||||
|
||||
fn bindings(&self) -> Vec<KeyBindingInfo<'_>>;
|
||||
}
|
||||
|
||||
pub struct KeyGroupInfo<'a> {
|
||||
pub name: &'static str,
|
||||
pub description: &'static str,
|
||||
pub bindings: Vec<KeyBindingInfo<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> KeyGroupInfo<'a> {
|
||||
pub fn new<G: KeyGroup>(name: &'static str, group: &'a G) -> Self {
|
||||
Self {
|
||||
name,
|
||||
description: G::DESCRIPTION,
|
||||
bindings: group.bindings(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct InputEvent<'a> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue