From 92fb3e17aa413046dff0a004ab5d790d45ef90f5 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 3 Aug 2024 12:20:54 +0200 Subject: add cursor shape handling --- src/state/log.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/state/log.rs') 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(()) }); } -- cgit v1.2.3-70-g09d2