WIP - move terminal to project as pre-prep for collaboration
This commit is contained in:
parent
7dde54b052
commit
1b8763d0cf
14 changed files with 95 additions and 30 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
@ -4463,6 +4463,7 @@ dependencies = [
|
||||||
"smol",
|
"smol",
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"tempdir",
|
"tempdir",
|
||||||
|
"terminal",
|
||||||
"text",
|
"text",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"toml",
|
"toml",
|
||||||
|
@ -6257,6 +6258,31 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "terminal"
|
name = "terminal"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"alacritty_terminal",
|
"alacritty_terminal",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
@ -8166,7 +8192,7 @@ dependencies = [
|
||||||
"smol",
|
"smol",
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"tempdir",
|
"tempdir",
|
||||||
"terminal",
|
"terminal_view",
|
||||||
"text",
|
"text",
|
||||||
"theme",
|
"theme",
|
||||||
"theme_selector",
|
"theme_selector",
|
||||||
|
|
|
@ -32,6 +32,7 @@ lsp = { path = "../lsp" }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
|
terminal = { path = "../terminal" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
aho-corasick = "0.7"
|
aho-corasick = "0.7"
|
||||||
anyhow = "1.0.57"
|
anyhow = "1.0.57"
|
||||||
|
|
|
@ -60,6 +60,7 @@ use std::{
|
||||||
atomic::{AtomicUsize, Ordering::SeqCst},
|
atomic::{AtomicUsize, Ordering::SeqCst},
|
||||||
Arc,
|
Arc,
|
||||||
},
|
},
|
||||||
|
thread::panicking,
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
@ -1193,6 +1194,17 @@ impl Project {
|
||||||
!self.is_local()
|
!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(
|
pub fn create_buffer(
|
||||||
&mut self,
|
&mut self,
|
||||||
text: &str,
|
text: &str,
|
||||||
|
|
|
@ -7,17 +7,12 @@ edition = "2021"
|
||||||
path = "src/terminal.rs"
|
path = "src/terminal.rs"
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
context_menu = { path = "../context_menu" }
|
|
||||||
editor = { path = "../editor" }
|
|
||||||
language = { path = "../language" }
|
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
project = { path = "../project" }
|
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
theme = { path = "../theme" }
|
|
||||||
util = { path = "../util" }
|
|
||||||
workspace = { path = "../workspace" }
|
|
||||||
db = { path = "../db" }
|
db = { path = "../db" }
|
||||||
|
theme = { path = "../theme" }
|
||||||
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "a51dbe25d67e84d6ed4261e640d3954fbdd9be45" }
|
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "a51dbe25d67e84d6ed4261e640d3954fbdd9be45" }
|
||||||
procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }
|
procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { version = "1.6", features = ["union"] }
|
||||||
|
@ -33,12 +28,3 @@ anyhow = "1"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
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"
|
|
||||||
|
|
|
@ -2,16 +2,16 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use db::{define_connection, query, sqlez_macros::sql};
|
use db::{define_connection, query, sqlez_macros::sql};
|
||||||
|
|
||||||
use workspace::{ItemId, WorkspaceDb, WorkspaceId};
|
type ModelId = usize;
|
||||||
|
|
||||||
define_connection! {
|
define_connection! {
|
||||||
pub static ref TERMINAL_CONNECTION: TerminalDb<WorkspaceDb> =
|
pub static ref TERMINAL_CONNECTION: TerminalDb<()> =
|
||||||
&[sql!(
|
&[sql!(
|
||||||
CREATE TABLE terminals (
|
CREATE TABLE terminals (
|
||||||
workspace_id INTEGER,
|
workspace_id INTEGER,
|
||||||
item_id INTEGER UNIQUE,
|
model_id INTEGER UNIQUE,
|
||||||
working_directory BLOB,
|
working_directory BLOB,
|
||||||
PRIMARY KEY(workspace_id, item_id),
|
PRIMARY KEY(workspace_id, model_id),
|
||||||
FOREIGN KEY(workspace_id) REFERENCES workspaces(workspace_id)
|
FOREIGN KEY(workspace_id) REFERENCES workspaces(workspace_id)
|
||||||
ON DELETE CASCADE
|
ON DELETE CASCADE
|
||||||
) STRICT;
|
) STRICT;
|
||||||
|
@ -23,7 +23,7 @@ impl TerminalDb {
|
||||||
pub async fn update_workspace_id(
|
pub async fn update_workspace_id(
|
||||||
new_id: WorkspaceId,
|
new_id: WorkspaceId,
|
||||||
old_id: WorkspaceId,
|
old_id: WorkspaceId,
|
||||||
item_id: ItemId
|
item_id: ModelId
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
UPDATE terminals
|
UPDATE terminals
|
||||||
SET workspace_id = ?
|
SET workspace_id = ?
|
||||||
|
@ -33,7 +33,7 @@ impl TerminalDb {
|
||||||
|
|
||||||
query! {
|
query! {
|
||||||
pub async fn save_working_directory(
|
pub async fn save_working_directory(
|
||||||
item_id: ItemId,
|
item_id: ModelId,
|
||||||
workspace_id: WorkspaceId,
|
workspace_id: WorkspaceId,
|
||||||
working_directory: PathBuf
|
working_directory: PathBuf
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
@ -43,7 +43,7 @@ impl TerminalDb {
|
||||||
}
|
}
|
||||||
|
|
||||||
query! {
|
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_directory
|
SELECT working_directory
|
||||||
FROM terminals
|
FROM terminals
|
||||||
WHERE item_id = ? AND workspace_id = ?
|
WHERE item_id = ? AND workspace_id = ?
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
pub mod mappings;
|
pub mod mappings;
|
||||||
mod persistence;
|
mod persistence;
|
||||||
pub mod terminal_container_view;
|
|
||||||
pub mod terminal_element;
|
|
||||||
pub mod terminal_view;
|
|
||||||
|
|
||||||
use alacritty_terminal::{
|
use alacritty_terminal::{
|
||||||
ansi::{ClearMode, Handler},
|
ansi::{ClearMode, Handler},
|
||||||
|
@ -37,7 +34,6 @@ use persistence::TERMINAL_CONNECTION;
|
||||||
use procinfo::LocalProcessInfo;
|
use procinfo::LocalProcessInfo;
|
||||||
use settings::{AlternateScroll, Settings, Shell, TerminalBlink};
|
use settings::{AlternateScroll, Settings, Shell, TerminalBlink};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{ItemId, WorkspaceId};
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
cmp::min,
|
cmp::min,
|
||||||
|
|
44
crates/terminal_view/Cargo.toml
Normal file
44
crates/terminal_view/Cargo.toml
Normal file
|
@ -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"
|
|
@ -48,7 +48,7 @@ rpc = { path = "../rpc" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
text = { path = "../text" }
|
text = { path = "../text" }
|
||||||
terminal = { path = "../terminal" }
|
terminal_view = { path = "../terminal_view" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
theme_selector = { path = "../theme_selector" }
|
theme_selector = { path = "../theme_selector" }
|
||||||
theme_testbench = { path = "../theme_testbench" }
|
theme_testbench = { path = "../theme_testbench" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue