1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
use mlua::{Function, UserData};
use ratatui::crossterm::event::KeyEvent;
use self::{
event_from_string::event_from_string,
keymap_store::{KeyMapStore, Runnable},
};
use super::{GlobalConfig, DUMMY_CONFIG};
use template::KeyMapSections;
KeyMapSections!(
ViewKeyMap => view,
GlobalKeyMap => global,
);
#[derive(Debug, Default, Clone)]
pub struct KeyMap {
pub view: ViewKeyMap,
pub global: GlobalKeyMap,
}
pub mod event_from_string;
pub mod keymap_store;
pub mod template;
impl KeyMap {
pub const fn new() -> Self {
Self {
view: ViewKeyMap::new(),
global: GlobalKeyMap::new(),
}
}
}
impl UserData for KeyMap {
fn add_fields<'lua, F: mlua::prelude::LuaUserDataFields<'lua, Self>>(fields: &mut F) {
fields.add_field_function_get("view", |_, _| Ok(DUMMY_CONFIG.keymap.view.clone()));
fields.add_field_function_get("global", |_, _| Ok(DUMMY_CONFIG.keymap.global.clone()));
}
}
|