From 219c560c7c0ad9e3960298ec125d4e64637fe84b Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Fri, 2 Aug 2024 20:41:29 +0200 Subject: add editor theme and state lua bindings --- src/state/editor/bar.rs | 8 ++++++++ src/state/editor/mod.rs | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 src/state/editor/bar.rs (limited to 'src/state/editor') diff --git a/src/state/editor/bar.rs b/src/state/editor/bar.rs new file mode 100644 index 0000000..752d021 --- /dev/null +++ b/src/state/editor/bar.rs @@ -0,0 +1,8 @@ +use crate::state::{bar::BarState, GlobalState}; + +BarState!( + EditorBarState, + (), + GlobalState::instance().editor.bar, + GlobalState::instance_mut().editor.bar +); diff --git a/src/state/editor/mod.rs b/src/state/editor/mod.rs index 6fbd2b9..279a164 100644 --- a/src/state/editor/mod.rs +++ b/src/state/editor/mod.rs @@ -1,14 +1,16 @@ -use self::buffer::Buffer; +use self::{bar::EditorBarState, buffer::Buffer}; -use super::GlobalState; +use super::{GlobalState, DUMMY_STATE}; use mlua::{Lua, UserData}; pub mod buffer; +pub mod bar; #[derive(Default, Debug)] pub struct EditorState { pub visible: bool, pub buffer: Buffer, + pub bar: EditorBarState, } macro_rules! cfg { @@ -28,6 +30,7 @@ impl EditorState { Self { visible: false, buffer: Buffer::new(), + bar: EditorBarState::new(), } } @@ -45,7 +48,9 @@ impl UserData for EditorState { fields.add_field_function_set("visible", |_, _, visible: bool| { cfg_mut!().visible = visible; Ok(()) - }) + }); + + fields.add_field_function_get("bar", |_, _| Ok(DUMMY_STATE.editor.bar)); } fn add_methods<'lua, M: mlua::prelude::LuaUserDataMethods<'lua, Self>>(methods: &mut M) { -- cgit v1.2.3-70-g09d2