diff options
Diffstat (limited to 'src/state/editor')
| -rw-r--r-- | src/state/editor/bar.rs | 3 | ||||
| -rw-r--r-- | src/state/editor/mod.rs | 24 |
2 files changed, 9 insertions, 18 deletions
diff --git a/src/state/editor/bar.rs b/src/state/editor/bar.rs index 752d021..f6163af 100644 --- a/src/state/editor/bar.rs +++ b/src/state/editor/bar.rs @@ -3,6 +3,5 @@ use crate::state::{bar::BarState, GlobalState}; BarState!( EditorBarState, (), - GlobalState::instance().editor.bar, - GlobalState::instance_mut().editor.bar + GlobalState::get().editor.bar ); diff --git a/src/state/editor/mod.rs b/src/state/editor/mod.rs index 3639226..3e9d9e0 100644 --- a/src/state/editor/mod.rs +++ b/src/state/editor/mod.rs @@ -19,13 +19,7 @@ pub struct EditorState { macro_rules! cfg { () => { - GlobalState::instance().editor - }; -} - -macro_rules! cfg_mut { - () => { - GlobalState::instance_mut().editor + GlobalState::get().editor }; } @@ -51,12 +45,11 @@ impl UserData for EditorState { 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| { - let mut state = GlobalState::instance_mut(); - state.editor.visible = visible; + cfg!().visible = visible; - if let Window::Editor = state.active_window { + if let Window::Editor = GlobalState::get().active_window { if !visible { - state.set_focus(Window::View); + GlobalState::get().set_focus(Window::View); } } @@ -65,17 +58,16 @@ impl UserData for EditorState { fields.add_field_function_get("content", |_, _| Ok(cfg!().buffer.as_string())); fields.add_field_function_set("content", |_, _, content: String| { - cfg_mut!().buffer.set_lines_from_string(content); + cfg!().buffer.set_lines_from_string(content); Ok(()) }); fields.add_field_function_get("cursor_shape", |_, _| Ok(cfg!().cursor_shape)); fields.add_field_function_set("cursor_shape", |_, _, shape: CursorShape| { - cfg_mut!().cursor_shape = shape; + cfg!().cursor_shape = shape; Ok(()) }); - fields.add_field_function_get("lines", |lua, _| { let table = lua.create_table()?; @@ -86,7 +78,7 @@ impl UserData for EditorState { Ok(table) }); fields.add_field_function_set("lines", |_, _, content: String| { - cfg_mut!().buffer.set_lines_from_string(content); + cfg!().buffer.set_lines_from_string(content); Ok(()) }); @@ -100,7 +92,7 @@ impl UserData for EditorState { }); methods.add_function("move_cursor", |_, m: CursorMove| { - cfg_mut!().buffer.move_cursor(m); + cfg!().buffer.move_cursor(m); Ok(()) }) } |