diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-08-03 12:20:54 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-08-03 12:20:54 +0200 |
| commit | 92fb3e17aa413046dff0a004ab5d790d45ef90f5 (patch) | |
| tree | 9dfbb3e71423abd80e65fc73e96952427e0738b8 /src/state/log.rs | |
| parent | 90daf295c7dd5fedc3219b8947fac110f05cc522 (diff) | |
add cursor shape handling
Diffstat (limited to 'src/state/log.rs')
| -rw-r--r-- | src/state/log.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/state/log.rs b/src/state/log.rs index 5afa8ca..f7311a0 100644 --- a/src/state/log.rs +++ b/src/state/log.rs @@ -1,5 +1,5 @@ use mlua::UserData; -use super::GlobalState; +use super::{window::Window, GlobalState}; #[derive(Debug, Default)] pub struct LogState { @@ -18,17 +18,19 @@ macro_rules! cfg { }; } -macro_rules! cfg_mut { - () => { - GlobalState::instance_mut().log - }; -} - impl UserData for LogState { fn add_fields<'lua, F: mlua::prelude::LuaUserDataFields<'lua, Self>>(fields: &mut F) { fields.add_field_function_get("visible", |_, _| Ok(cfg!().visible)); fields.add_field_function_set("visible", |_, _, visible: bool| { - cfg_mut!().visible = visible; + let mut state = GlobalState::instance_mut(); + state.log.visible = visible; + + if let Window::Log = state.active_window { + if !visible { + state.set_focus(Window::Log); + } + } + Ok(()) }); } |