diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-08-03 00:08:47 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-08-03 00:08:47 +0200 |
| commit | eafde55afcdf9dc4c17c6c97c1db472fc9ff9957 (patch) | |
| tree | 838cab985495ead6dc005bd934f9e87c896e4ddd /src/config/keymap/mod.rs | |
| parent | bb9944d086332ed0b8d6064316225e901c456bd7 (diff) | |
add keymap for view and global
Diffstat (limited to 'src/config/keymap/mod.rs')
| -rw-r--r-- | src/config/keymap/mod.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/config/keymap/mod.rs b/src/config/keymap/mod.rs new file mode 100644 index 0000000..e9995f2 --- /dev/null +++ b/src/config/keymap/mod.rs @@ -0,0 +1,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())); + } +} |