summaryrefslogtreecommitdiff
path: root/src/state/mod.rs
diff options
context:
space:
mode:
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(())
+ })
+ }
}