From fa87aaf3d57ab174a4a9a8a489efd4b52bb001d0 Mon Sep 17 00:00:00 2001 From: Justin Date: Fri, 12 Apr 2024 21:22:29 -0400 Subject: [PATCH] refactor: pull keymap, layer, menu into a top-level module --- src/editor/mod.rs | 5 ++--- src/editor/runtime.rs | 2 +- src/{editor => keymap}/keymap.rs | 4 +++- src/{editor => keymap}/layer.rs | 2 +- src/{editor => keymap}/menu.rs | 2 +- src/keymap/mod.rs | 5 +++++ src/lib.rs | 1 + 7 files changed, 14 insertions(+), 7 deletions(-) rename src/{editor => keymap}/keymap.rs (99%) rename src/{editor => keymap}/layer.rs (99%) rename src/{editor => keymap}/menu.rs (99%) create mode 100644 src/keymap/mod.rs diff --git a/src/editor/mod.rs b/src/editor/mod.rs index 4e23395..7a94a64 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -2,9 +2,6 @@ mod app; mod interpreter; -mod keymap; -mod layer; -mod menu; mod runtime; mod stack; @@ -13,6 +10,8 @@ use crate::frontends::Frontend; use std::error::Error; use std::fmt; +pub use stack::{Op, Prog, Value}; + // TODO: Is this InterpreterError, AppError, a mix of both? #[derive(thiserror::Error, fmt::Debug)] pub enum EditorError { diff --git a/src/editor/runtime.rs b/src/editor/runtime.rs index 748054f..4d2c88d 100644 --- a/src/editor/runtime.rs +++ b/src/editor/runtime.rs @@ -1,8 +1,8 @@ -use super::layer::LayerManager; use super::stack::Prog; use super::EditorError; use crate::engine::{DocDisplayLabel, Engine}; use crate::frontends::{Event, Frontend, Key}; +use crate::keymap::LayerManager; use crate::style::Style; use crate::tree::Mode; use crate::util::SynlessBug; diff --git a/src/editor/keymap.rs b/src/keymap/keymap.rs similarity index 99% rename from src/editor/keymap.rs rename to src/keymap/keymap.rs index ef5d3dd..9cd352f 100644 --- a/src/editor/keymap.rs +++ b/src/keymap/keymap.rs @@ -1,4 +1,6 @@ -use super::stack::{Op, Prog, Value}; +#![allow(clippy::module_inception)] + +use crate::editor::{Op, Prog, Value}; use crate::frontends::Key; use crate::language::Storage; use crate::tree::Node; diff --git a/src/editor/layer.rs b/src/keymap/layer.rs similarity index 99% rename from src/editor/layer.rs rename to src/keymap/layer.rs index 6b2e046..2438ce1 100644 --- a/src/editor/layer.rs +++ b/src/keymap/layer.rs @@ -1,6 +1,6 @@ use super::keymap::Keymap; use super::menu::{Menu, MenuName, MenuSelectionCmd}; -use super::stack::Prog; +use crate::editor::Prog; use crate::engine::DocName; use crate::frontends::Key; use crate::language::Storage; diff --git a/src/editor/menu.rs b/src/keymap/menu.rs similarity index 99% rename from src/editor/menu.rs rename to src/keymap/menu.rs index 5eb3c5c..5d27d70 100644 --- a/src/editor/menu.rs +++ b/src/keymap/menu.rs @@ -1,5 +1,5 @@ use super::keymap::{Candidate, Keymap}; -use super::stack::Prog; +use crate::editor::Prog; use crate::frontends::Key; use crate::language::Storage; use crate::tree::Node; diff --git a/src/keymap/mod.rs b/src/keymap/mod.rs new file mode 100644 index 0000000..962d4bf --- /dev/null +++ b/src/keymap/mod.rs @@ -0,0 +1,5 @@ +mod keymap; +mod layer; +mod menu; + +pub use layer::LayerManager; diff --git a/src/lib.rs b/src/lib.rs index a0071cc..8d45a5e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ mod editor; mod engine; mod frontends; +mod keymap; mod language; mod pretty_doc; mod style;