tui-journal 0.17.0

Tui app allows writing and managing journals/notes from within the terminal With different local back-ends
Documentation
use std::collections::BTreeMap;

use ratatui::widgets::TableState;

use crate::app::{
    keymap::{Input, get_multi_select_keymaps},
    ui::UICommand,
};

use super::keybindings_table::KeybindingsTable;

#[derive(Debug)]
pub struct MultiSelectBindings {
    state: TableState,
    bingings_map: BTreeMap<UICommand, Vec<Input>>,
}

impl MultiSelectBindings {
    pub fn new() -> Self {
        let state = TableState::default();
        let mut bingings_map: BTreeMap<UICommand, Vec<Input>> = BTreeMap::new();

        get_multi_select_keymaps().into_iter().for_each(|keymap| {
            bingings_map
                .entry(keymap.command)
                .and_modify(|keys| keys.push(keymap.key))
                .or_insert(vec![keymap.key]);
        });
        Self {
            state,
            bingings_map,
        }
    }
}

impl KeybindingsTable for MultiSelectBindings {
    fn get_state_mut(&mut self) -> &mut TableState {
        &mut self.state
    }

    fn get_bindings_map(&self) -> &BTreeMap<UICommand, Vec<Input>> {
        &self.bingings_map
    }

    fn get_title(&self) -> &str {
        "Multi-Select Mode Keybindings"
    }
}