From 0ad2f0266f6cf1bae22d7cb73e70291f749821a1 Mon Sep 17 00:00:00 2001 From: Ryan Brue Date: Tue, 28 Oct 2025 04:04:21 +0000 Subject: [PATCH] Separate `helix-input` and `helix-graphics` from `helix-view`. This commit separates some primitives from `helix-view` into their own crates, for later use by crates that view might depend on, without causing cyclic dependencies. --- Cargo.lock | 36 +++++++++++++++++++ Cargo.toml | 2 ++ helix-graphics/Cargo.toml | 32 +++++++++++++++++ .../src/graphics.rs | 0 helix-graphics/src/lib.rs | 2 ++ {helix-view => helix-graphics}/src/theme.rs | 0 helix-input/Cargo.toml | 35 ++++++++++++++++++ {helix-view => helix-input}/src/clipboard.rs | 0 {helix-view => helix-input}/src/input.rs | 0 {helix-view => helix-input}/src/keyboard.rs | 0 helix-input/src/lib.rs | 3 ++ helix-view/Cargo.toml | 4 ++- helix-view/src/lib.rs | 12 ++++--- 13 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 helix-graphics/Cargo.toml rename {helix-view => helix-graphics}/src/graphics.rs (100%) create mode 100644 helix-graphics/src/lib.rs rename {helix-view => helix-graphics}/src/theme.rs (100%) create mode 100644 helix-input/Cargo.toml rename {helix-view => helix-input}/src/clipboard.rs (100%) rename {helix-view => helix-input}/src/input.rs (100%) rename {helix-view => helix-input}/src/keyboard.rs (100%) create mode 100644 helix-input/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index dd8896d34307..8c389a97f9fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1423,6 +1423,40 @@ dependencies = [ "tokio", ] +[[package]] +name = "helix-graphics" +version = "25.7.1" +dependencies = [ + "anyhow", + "bitflags", + "crossterm", + "helix-core", + "helix-loader", + "log", + "once_cell", + "serde", + "termina", + "toml", +] + +[[package]] +name = "helix-input" +version = "25.7.1" +dependencies = [ + "anyhow", + "bitflags", + "clipboard-win", + "crossterm", + "helix-core", + "helix-stdx", + "libc", + "log", + "rustix 1.1.2", + "serde", + "termina", + "thiserror", +] + [[package]] name = "helix-loader" version = "25.7.1" @@ -1591,6 +1625,8 @@ dependencies = [ "helix-core", "helix-dap", "helix-event", + "helix-graphics", + "helix-input", "helix-loader", "helix-lsp", "helix-stdx", diff --git a/Cargo.toml b/Cargo.toml index 90542831f891..e80bc7440733 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,8 @@ resolver = "2" members = [ "helix-core", + "helix-graphics", + "helix-input", "helix-view", "helix-term", "helix-tui", diff --git a/helix-graphics/Cargo.toml b/helix-graphics/Cargo.toml new file mode 100644 index 000000000000..8515b3275c3d --- /dev/null +++ b/helix-graphics/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "helix-graphics" +version.workspace = true +edition.workspace = true +authors.workspace = true +categories.workspace = true +repository.workspace = true +homepage.workspace = true +license.workspace = true +rust-version.workspace = true + +[features] +default = [] +term = ["termina", "crossterm"] + +[dependencies] +helix-core = { path = "../helix-core" } +helix-loader = { path = "../helix-loader" } +bitflags.workspace = true +anyhow = "1" + +termina = { workspace = true, optional = true } + +# Conversion traits +once_cell = "1.21" + +serde = { version = "1.0", features = ["derive"] } +toml.workspace = true +log = "~0.4" + +[target.'cfg(windows)'.dependencies] +crossterm = { version = "0.28", optional = true } \ No newline at end of file diff --git a/helix-view/src/graphics.rs b/helix-graphics/src/graphics.rs similarity index 100% rename from helix-view/src/graphics.rs rename to helix-graphics/src/graphics.rs diff --git a/helix-graphics/src/lib.rs b/helix-graphics/src/lib.rs new file mode 100644 index 000000000000..06337036c82b --- /dev/null +++ b/helix-graphics/src/lib.rs @@ -0,0 +1,2 @@ +pub mod graphics; +pub mod theme; diff --git a/helix-view/src/theme.rs b/helix-graphics/src/theme.rs similarity index 100% rename from helix-view/src/theme.rs rename to helix-graphics/src/theme.rs diff --git a/helix-input/Cargo.toml b/helix-input/Cargo.toml new file mode 100644 index 000000000000..fe52f181b066 --- /dev/null +++ b/helix-input/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "helix-input" +version.workspace = true +edition.workspace = true +authors.workspace = true +categories.workspace = true +repository.workspace = true +homepage.workspace = true +license.workspace = true +rust-version.workspace = true + +[features] +default = [] +term = ["termina", "crossterm"] + +[dependencies] +helix-stdx = { path = "../helix-stdx" } +helix-core = { path = "../helix-core" } + +bitflags.workspace = true +anyhow = "1" +termina = { workspace = true, optional = true } + +serde = { version = "1.0", features = ["derive"] } +log = "~0.4" + +thiserror.workspace = true + +[target.'cfg(windows)'.dependencies] +clipboard-win = { version = "5.4", features = ["std"] } +crossterm = { version = "0.28", optional = true } + +[target.'cfg(unix)'.dependencies] +libc = "0.2" +rustix = { version = "1.1", features = ["fs"] } \ No newline at end of file diff --git a/helix-view/src/clipboard.rs b/helix-input/src/clipboard.rs similarity index 100% rename from helix-view/src/clipboard.rs rename to helix-input/src/clipboard.rs diff --git a/helix-view/src/input.rs b/helix-input/src/input.rs similarity index 100% rename from helix-view/src/input.rs rename to helix-input/src/input.rs diff --git a/helix-view/src/keyboard.rs b/helix-input/src/keyboard.rs similarity index 100% rename from helix-view/src/keyboard.rs rename to helix-input/src/keyboard.rs diff --git a/helix-input/src/lib.rs b/helix-input/src/lib.rs new file mode 100644 index 000000000000..23a6d61b72be --- /dev/null +++ b/helix-input/src/lib.rs @@ -0,0 +1,3 @@ +pub mod clipboard; +pub mod input; +pub mod keyboard; diff --git a/helix-view/Cargo.toml b/helix-view/Cargo.toml index 24dd0f2aaab2..6c4c02fc6e17 100644 --- a/helix-view/Cargo.toml +++ b/helix-view/Cargo.toml @@ -12,7 +12,7 @@ homepage.workspace = true [features] default = [] -term = ["termina", "crossterm"] +term = ["termina", "crossterm", "helix-graphics/term", "helix-input/term"] unicode-lines = [] [dependencies] @@ -23,6 +23,8 @@ helix-loader = { path = "../helix-loader" } helix-lsp = { path = "../helix-lsp" } helix-dap = { path = "../helix-dap" } helix-vcs = { path = "../helix-vcs" } +helix-graphics = { path = "../helix-graphics" } +helix-input = { path = "../helix-input" } bitflags.workspace = true anyhow = "1" diff --git a/helix-view/src/lib.rs b/helix-view/src/lib.rs index a7e9f4618c91..b653f274470c 100644 --- a/helix-view/src/lib.rs +++ b/helix-view/src/lib.rs @@ -2,22 +2,24 @@ pub mod macros; pub mod annotations; -pub mod clipboard; pub mod document; pub mod editor; pub mod events; pub mod expansion; -pub mod graphics; pub mod gutter; pub mod handlers; pub mod info; -pub mod input; -pub mod keyboard; pub mod register; -pub mod theme; pub mod tree; pub mod view; +pub use helix_input::clipboard; +pub use helix_input::input; +pub use helix_input::keyboard; + +pub use helix_graphics::graphics; +pub use helix_graphics::theme; + use std::num::NonZeroUsize; // uses NonZeroUsize so Option use a byte rather than two