Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
WIP - move terminal to project as pre-prep for collaboration
Mikayla Maki1b8763d0cfea
diff --git a/Cargo.lock b/Cargo.lockindex 7d7dc42bea7..1868959a094 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -4463,6 +4463,7 @@ dependencies = ["smol","sum_tree","tempdir",+ "terminal","text","thiserror","toml",@@ -6257,6 +6258,31 @@ dependencies = [[[package]]name = "terminal"version = "0.1.0"+dependencies = [+ "alacritty_terminal",+ "anyhow",+ "db",+ "dirs 4.0.0",+ "futures 0.3.25",+ "gpui",+ "itertools",+ "lazy_static",+ "libc",+ "mio-extras",+ "ordered-float",+ "procinfo",+ "serde",+ "settings",+ "shellexpand",+ "smallvec",+ "smol",+ "theme",+ "thiserror",+]++[[package]]+name = "terminal_view"+version = "0.1.0"dependencies = ["alacritty_terminal","anyhow",@@ -8166,7 +8192,7 @@ dependencies = ["smol","sum_tree","tempdir",- "terminal",+ "terminal_view","text","theme","theme_selector",diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.tomlindex 76c60f95562..dd4d2be5b68 100644--- a/crates/project/Cargo.toml+++ b/crates/project/Cargo.toml@@ -32,6 +32,7 @@ lsp = { path = "../lsp" }rpc = { path = "../rpc" }settings = { path = "../settings" }sum_tree = { path = "../sum_tree" }+terminal = { path = "../terminal" }util = { path = "../util" }aho-corasick = "0.7"anyhow = "1.0.57"diff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex 512ac702d06..e61f0fe0b7e 100644--- a/crates/project/src/project.rs+++ b/crates/project/src/project.rs@@ -60,6 +60,7 @@ use std::{atomic::{AtomicUsize, Ordering::SeqCst},Arc,},+ thread::panicking,time::Instant,};use thiserror::Error;@@ -1193,6 +1194,17 @@ impl Project {!self.is_local()}+ pub fn create_terminal_connection(+ &mut self,+ cx: &mut ModelContext<Self>,+ ) -> Result<ModelHandle<TerminalConnection>> {+ if self.is_remote() {+ return Err(anyhow!(+ "creating terminals as a guest is not supported yet"+ ));+ }+ }+pub fn create_buffer(&mut self,text: &str,diff --git a/crates/terminal/Cargo.toml b/crates/terminal/Cargo.tomlindex 5593ee92d4d..2948eaec69a 100644--- a/crates/terminal/Cargo.toml+++ b/crates/terminal/Cargo.toml@@ -7,17 +7,12 @@ edition = "2021"path = "src/terminal.rs"doctest = false+[dependencies]-context_menu = { path = "../context_menu" }-editor = { path = "../editor" }-language = { path = "../language" }gpui = { path = "../gpui" }-project = { path = "../project" }settings = { path = "../settings" }-theme = { path = "../theme" }-util = { path = "../util" }-workspace = { path = "../workspace" }db = { path = "../db" }+theme = { path = "../theme" }alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "a51dbe25d67e84d6ed4261e640d3954fbdd9be45" }procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }smallvec = { version = "1.6", features = ["union"] }@@ -32,13 +27,4 @@ libc = "0.2"anyhow = "1"thiserror = "1.0"lazy_static = "1.4.0"-serde = { version = "1.0", features = ["derive"] }----[dev-dependencies]-gpui = { path = "../gpui", features = ["test-support"] }-client = { path = "../client", features = ["test-support"]}-project = { path = "../project", features = ["test-support"]}-workspace = { path = "../workspace", features = ["test-support"] }-rand = "0.8.5"+serde = { version = "1.0", features = ["derive"] }\ No newline at end of filediff --git a/crates/terminal/src/persistence.rs b/crates/terminal/src/persistence.rsindex 1669a3a5467..333911ee6d6 100644--- a/crates/terminal/src/persistence.rs+++ b/crates/terminal/src/persistence.rs@@ -2,16 +2,16 @@ use std::path::PathBuf;use db::{define_connection, query, sqlez_macros::sql};-use workspace::{ItemId, WorkspaceDb, WorkspaceId};+type ModelId = usize;define_connection! {- pub static ref TERMINAL_CONNECTION: TerminalDb<WorkspaceDb> =+ pub static ref TERMINAL_CONNECTION: TerminalDb<()> =&[sql!(CREATE TABLE terminals (workspace_id INTEGER,- item_id INTEGER UNIQUE,+ model_id INTEGER UNIQUE,working_directory BLOB,- PRIMARY KEY(workspace_id, item_id),+ PRIMARY KEY(workspace_id, model_id),FOREIGN KEY(workspace_id) REFERENCES workspaces(workspace_id)ON DELETE CASCADE) STRICT;@@ -23,7 +23,7 @@ impl TerminalDb {pub async fn update_workspace_id(new_id: WorkspaceId,old_id: WorkspaceId,- item_id: ItemId+ item_id: ModelId) -> Result<()> {UPDATE terminalsSET workspace_id = ?@@ -33,7 +33,7 @@ impl TerminalDb {query! {pub async fn save_working_directory(- item_id: ItemId,+ item_id: ModelId,workspace_id: WorkspaceId,working_directory: PathBuf) -> Result<()> {@@ -43,7 +43,7 @@ impl TerminalDb {}query! {- pub fn get_working_directory(item_id: ItemId, workspace_id: WorkspaceId) -> Result<Option<PathBuf>> {+ pub fn get_working_directory(item_id: ModelId, workspace_id: WorkspaceId) -> Result<Option<PathBuf>> {SELECT working_directoryFROM terminalsWHERE item_id = ? AND workspace_id = ?diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rsindex 0cbb6d36b11..62df8aca827 100644--- a/crates/terminal/src/terminal.rs+++ b/crates/terminal/src/terminal.rs@@ -1,8 +1,5 @@pub mod mappings;mod persistence;-pub mod terminal_container_view;-pub mod terminal_element;-pub mod terminal_view;use alacritty_terminal::{ansi::{ClearMode, Handler},@@ -37,7 +34,6 @@ use persistence::TERMINAL_CONNECTION;use procinfo::LocalProcessInfo;use settings::{AlternateScroll, Settings, Shell, TerminalBlink};use util::ResultExt;-use workspace::{ItemId, WorkspaceId};use std::{cmp::min,diff --git a/crates/terminal_view/Cargo.toml b/crates/terminal_view/Cargo.tomlnew file mode 100644index 00000000000..181ed606e0b--- /dev/null+++ b/crates/terminal_view/Cargo.toml@@ -0,0 +1,44 @@+[package]+name = "terminal_view"+version = "0.1.0"+edition = "2021"++[lib]+path = "src/terminal_container_view.rs"+doctest = false++[dependencies]+context_menu = { path = "../context_menu" }+editor = { path = "../editor" }+language = { path = "../language" }+gpui = { path = "../gpui" }+project = { path = "../project" }+settings = { path = "../settings" }+theme = { path = "../theme" }+util = { path = "../util" }+workspace = { path = "../workspace" }+db = { path = "../db" }+alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "a51dbe25d67e84d6ed4261e640d3954fbdd9be45" }+procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }+smallvec = { version = "1.6", features = ["union"] }+smol = "1.2.5"+mio-extras = "2.0.6"+futures = "0.3"+ordered-float = "2.1.1"+itertools = "0.10"+dirs = "4.0.0"+shellexpand = "2.1.0"+libc = "0.2"+anyhow = "1"+thiserror = "1.0"+lazy_static = "1.4.0"+serde = { version = "1.0", features = ["derive"] }++++[dev-dependencies]+gpui = { path = "../gpui", features = ["test-support"] }+client = { path = "../client", features = ["test-support"]}+project = { path = "../project", features = ["test-support"]}+workspace = { path = "../workspace", features = ["test-support"] }+rand = "0.8.5"diff --git a/crates/terminal/README.md b/crates/terminal_view/README.mdsimilarity index 100%rename from crates/terminal/README.mdrename to crates/terminal_view/README.mddiff --git a/crates/terminal/scripts/print256color.sh b/crates/terminal_view/scripts/print256color.shsimilarity index 100%rename from crates/terminal/scripts/print256color.shrename to crates/terminal_view/scripts/print256color.shdiff --git a/crates/terminal/scripts/truecolor.sh b/crates/terminal_view/scripts/truecolor.shsimilarity index 100%rename from crates/terminal/scripts/truecolor.shrename to crates/terminal_view/scripts/truecolor.shdiff --git a/crates/terminal/src/terminal_container_view.rs b/crates/terminal_view/src/terminal_container_view.rssimilarity index 100%rename from crates/terminal/src/terminal_container_view.rsrename to crates/terminal_view/src/terminal_container_view.rsdiff --git a/crates/terminal/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rssimilarity index 100%rename from crates/terminal/src/terminal_element.rsrename to crates/terminal_view/src/terminal_element.rsdiff --git a/crates/terminal/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rssimilarity index 100%rename from crates/terminal/src/terminal_view.rsrename to crates/terminal_view/src/terminal_view.rsdiff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.tomlindex 6dfb739f3ab..a07c0c899c9 100644--- a/crates/zed/Cargo.toml+++ b/crates/zed/Cargo.toml@@ -48,7 +48,7 @@ rpc = { path = "../rpc" }settings = { path = "../settings" }sum_tree = { path = "../sum_tree" }text = { path = "../text" }-terminal = { path = "../terminal" }+terminal_view = { path = "../terminal_view" }theme = { path = "../theme" }theme_selector = { path = "../theme_selector" }theme_testbench = { path = "../theme_testbench" }