summaryrefslogtreecommitdiff
path: root/src/state/mod.rs
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2024-08-03 00:08:47 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2024-08-03 00:08:47 +0200
commiteafde55afcdf9dc4c17c6c97c1db472fc9ff9957 (patch)
tree838cab985495ead6dc005bd934f9e87c896e4ddd /src/state/mod.rs
parentbb9944d086332ed0b8d6064316225e901c456bd7 (diff)
add keymap for view and global
Diffstat (limited to 'src/state/mod.rs')
-rw-r--r--src/state/mod.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/state/mod.rs b/src/state/mod.rs
index 3b5d3c5..a5528e3 100644
--- a/src/state/mod.rs
+++ b/src/state/mod.rs
@@ -16,6 +16,7 @@ pub struct GlobalState {
pub editor: editor::EditorState,
pub active_window: window::Window,
pub log: log::LogState,
+ pub exit: bool,
}
static GLOBAL_STATE: RwLock<GlobalState> = RwLock::new(GlobalState::new());
@@ -28,6 +29,7 @@ impl GlobalState {
editor: editor::EditorState::new(),
log: LogState::new(),
active_window: window::Window::View,
+ exit: false,
}
}
@@ -62,4 +64,11 @@ impl UserData for GlobalState {
Ok(())
});
}
+
+ fn add_methods<'lua, M: mlua::prelude::LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
+ methods.add_function("quit", |_, _: ()| {
+ GlobalState::instance_mut().exit = true;
+ Ok(())
+ })
+ }
}