From eafde55afcdf9dc4c17c6c97c1db472fc9ff9957 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 3 Aug 2024 00:08:47 +0200 Subject: add keymap for view and global --- src/state/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/state/mod.rs') 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 = 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(()) + }) + } } -- cgit v1.2.3-70-g09d2