Compare commits
3 commits
main
...
gpui_teard
Author | SHA1 | Date | |
---|---|---|---|
![]() |
37a74e8412 | ||
![]() |
f34014b279 | ||
![]() |
990dac51aa |
62 changed files with 356 additions and 235 deletions
91
Cargo.lock
generated
91
Cargo.lock
generated
|
@ -609,6 +609,7 @@ dependencies = [
|
||||||
"tempdir",
|
"tempdir",
|
||||||
"theme",
|
"theme",
|
||||||
"util",
|
"util",
|
||||||
|
"util_http",
|
||||||
"workspace",
|
"workspace",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1230,6 +1231,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap 3.2.25",
|
"clap 3.2.25",
|
||||||
|
"cli_rpc",
|
||||||
"core-foundation",
|
"core-foundation",
|
||||||
"core-services",
|
"core-services",
|
||||||
"dirs 3.0.2",
|
"dirs 3.0.2",
|
||||||
|
@ -1240,6 +1242,15 @@ dependencies = [
|
||||||
"util",
|
"util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cli_rpc"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"ipc-channel",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "client"
|
name = "client"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -1271,6 +1282,7 @@ dependencies = [
|
||||||
"tiny_http",
|
"tiny_http",
|
||||||
"url",
|
"url",
|
||||||
"util",
|
"util",
|
||||||
|
"util_http",
|
||||||
"uuid 1.3.2",
|
"uuid 1.3.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1510,6 +1522,7 @@ dependencies = [
|
||||||
"smol",
|
"smol",
|
||||||
"theme",
|
"theme",
|
||||||
"util",
|
"util",
|
||||||
|
"util_http",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1855,7 +1868,6 @@ checksum = "14d05c10f541ae6f3bc5b3d923c20001f47db7d5f0b2bc6ad16490133842db79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
"libnghttp2-sys",
|
|
||||||
"libz-sys",
|
"libz-sys",
|
||||||
"openssl-sys",
|
"openssl-sys",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
|
@ -2885,20 +2897,12 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-task",
|
"async-task",
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bindgen",
|
|
||||||
"block",
|
|
||||||
"cc",
|
|
||||||
"cocoa",
|
|
||||||
"collections",
|
"collections",
|
||||||
"core-foundation",
|
|
||||||
"core-graphics",
|
|
||||||
"core-text",
|
|
||||||
"ctor",
|
"ctor",
|
||||||
"dhat",
|
"dhat",
|
||||||
"env_logger 0.9.3",
|
"env_logger 0.9.3",
|
||||||
"etagere",
|
"etagere",
|
||||||
"font-kit",
|
"font-kit",
|
||||||
"foreign-types",
|
|
||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
"gpui_macros",
|
"gpui_macros",
|
||||||
"image",
|
"image",
|
||||||
|
@ -2906,9 +2910,7 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"media",
|
"media",
|
||||||
"metal",
|
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"objc",
|
|
||||||
"ordered-float",
|
"ordered-float",
|
||||||
"parking",
|
"parking",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
|
@ -2936,6 +2938,41 @@ dependencies = [
|
||||||
"waker-fn",
|
"waker-fn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gpui_mac"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"async-task",
|
||||||
|
"bindgen",
|
||||||
|
"block",
|
||||||
|
"cc",
|
||||||
|
"cocoa",
|
||||||
|
"collections",
|
||||||
|
"core-foundation",
|
||||||
|
"core-graphics",
|
||||||
|
"core-text",
|
||||||
|
"ctor",
|
||||||
|
"etagere",
|
||||||
|
"font-kit",
|
||||||
|
"foreign-types",
|
||||||
|
"gpui",
|
||||||
|
"log",
|
||||||
|
"media",
|
||||||
|
"metal",
|
||||||
|
"objc",
|
||||||
|
"ordered-float",
|
||||||
|
"parking_lot 0.11.2",
|
||||||
|
"pathfinder_geometry",
|
||||||
|
"postage",
|
||||||
|
"resvg",
|
||||||
|
"smol",
|
||||||
|
"time 0.3.21",
|
||||||
|
"tiny-skia",
|
||||||
|
"usvg",
|
||||||
|
"uuid 1.3.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpui_macros"
|
name = "gpui_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -3594,6 +3631,7 @@ dependencies = [
|
||||||
"unicase",
|
"unicase",
|
||||||
"unindent",
|
"unindent",
|
||||||
"util",
|
"util",
|
||||||
|
"util_http",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -3691,16 +3729,6 @@ version = "0.2.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
|
checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libnghttp2-sys"
|
|
||||||
version = "0.1.7+1.45.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "57ed28aba195b38d5ff02b9170cbff627e336a20925e43b4945390401c5dc93f"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
version = "0.24.2"
|
version = "0.24.2"
|
||||||
|
@ -4241,6 +4269,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"smol",
|
"smol",
|
||||||
"util",
|
"util",
|
||||||
|
"util_http",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -5011,6 +5040,7 @@ dependencies = [
|
||||||
"toml",
|
"toml",
|
||||||
"unindent",
|
"unindent",
|
||||||
"util",
|
"util",
|
||||||
|
"util_http",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -7898,7 +7928,6 @@ dependencies = [
|
||||||
"dirs 3.0.2",
|
"dirs 3.0.2",
|
||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
"git2",
|
"git2",
|
||||||
"isahc",
|
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"rand 0.8.5",
|
"rand 0.8.5",
|
||||||
|
@ -7908,6 +7937,20 @@ dependencies = [
|
||||||
"smol",
|
"smol",
|
||||||
"take-until",
|
"take-until",
|
||||||
"tempdir",
|
"tempdir",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "util_http"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"futures 0.3.28",
|
||||||
|
"isahc",
|
||||||
|
"log",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"smol",
|
||||||
|
"tempdir",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -8919,7 +8962,7 @@ dependencies = [
|
||||||
"breadcrumbs",
|
"breadcrumbs",
|
||||||
"call",
|
"call",
|
||||||
"chrono",
|
"chrono",
|
||||||
"cli",
|
"cli_rpc",
|
||||||
"client",
|
"client",
|
||||||
"clock",
|
"clock",
|
||||||
"collab_ui",
|
"collab_ui",
|
||||||
|
@ -8941,6 +8984,7 @@ dependencies = [
|
||||||
"fuzzy",
|
"fuzzy",
|
||||||
"go_to_line",
|
"go_to_line",
|
||||||
"gpui",
|
"gpui",
|
||||||
|
"gpui_mac",
|
||||||
"ignore",
|
"ignore",
|
||||||
"image",
|
"image",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
|
@ -9011,6 +9055,7 @@ dependencies = [
|
||||||
"url",
|
"url",
|
||||||
"urlencoding",
|
"urlencoding",
|
||||||
"util",
|
"util",
|
||||||
|
"util_http",
|
||||||
"uuid 1.3.2",
|
"uuid 1.3.2",
|
||||||
"vim",
|
"vim",
|
||||||
"welcome",
|
"welcome",
|
||||||
|
|
|
@ -6,6 +6,7 @@ members = [
|
||||||
"crates/breadcrumbs",
|
"crates/breadcrumbs",
|
||||||
"crates/call",
|
"crates/call",
|
||||||
"crates/cli",
|
"crates/cli",
|
||||||
|
"crates/cli_rpc",
|
||||||
"crates/client",
|
"crates/client",
|
||||||
"crates/clock",
|
"crates/clock",
|
||||||
"crates/collab",
|
"crates/collab",
|
||||||
|
@ -27,6 +28,7 @@ members = [
|
||||||
"crates/git",
|
"crates/git",
|
||||||
"crates/go_to_line",
|
"crates/go_to_line",
|
||||||
"crates/gpui",
|
"crates/gpui",
|
||||||
|
"crates/gpui_mac",
|
||||||
"crates/gpui_macros",
|
"crates/gpui_macros",
|
||||||
"crates/install_cli",
|
"crates/install_cli",
|
||||||
"crates/journal",
|
"crates/journal",
|
||||||
|
@ -62,6 +64,7 @@ members = [
|
||||||
"crates/theme",
|
"crates/theme",
|
||||||
"crates/theme_selector",
|
"crates/theme_selector",
|
||||||
"crates/util",
|
"crates/util",
|
||||||
|
"crates/util_http",
|
||||||
"crates/vim",
|
"crates/vim",
|
||||||
"crates/workspace",
|
"crates/workspace",
|
||||||
"crates/welcome",
|
"crates/welcome",
|
||||||
|
@ -79,7 +82,7 @@ env_logger = { version = "0.9" }
|
||||||
futures = { version = "0.3" }
|
futures = { version = "0.3" }
|
||||||
globset = { version = "0.4" }
|
globset = { version = "0.4" }
|
||||||
indoc = "1"
|
indoc = "1"
|
||||||
isahc = "1.7.2"
|
isahc = {version = "1.7.2", default-features = false, features = ["text-decoding"]}
|
||||||
lazy_static = { version = "1.4.0" }
|
lazy_static = { version = "1.4.0" }
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
ordered-float = { version = "2.1.1" }
|
ordered-float = { version = "2.1.1" }
|
||||||
|
|
|
@ -18,6 +18,7 @@ settings = { path = "../settings" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
util_http = { path = "../util_http" }
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
isahc.workspace = true
|
isahc.workspace = true
|
||||||
lazy_static.workspace = true
|
lazy_static.workspace = true
|
||||||
|
|
|
@ -15,7 +15,7 @@ use smol::{fs::File, io::AsyncReadExt, process::Command};
|
||||||
use std::{ffi::OsString, sync::Arc, time::Duration};
|
use std::{ffi::OsString, sync::Arc, time::Duration};
|
||||||
use update_notification::UpdateNotification;
|
use update_notification::UpdateNotification;
|
||||||
use util::channel::ReleaseChannel;
|
use util::channel::ReleaseChannel;
|
||||||
use util::http::HttpClient;
|
use util_http::HttpClient;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
const SHOULD_SHOW_UPDATE_NOTIFICATION_KEY: &str = "auto-updater-should-show-updated-notification";
|
const SHOULD_SHOW_UPDATE_NOTIFICATION_KEY: &str = "auto-updater-should-show-updated-notification";
|
||||||
|
|
|
@ -4,9 +4,6 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[lib]
|
|
||||||
path = "src/cli.rs"
|
|
||||||
doctest = false
|
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "cli"
|
name = "cli"
|
||||||
|
@ -20,6 +17,7 @@ ipc-channel = "0.16"
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_derive.workspace = true
|
serde_derive.workspace = true
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
cli_rpc = {path = "../cli_rpc"}
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
core-foundation = "0.9"
|
core-foundation = "0.9"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cli::{CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME};
|
use cli_rpc::{CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME};
|
||||||
use core_foundation::{
|
use core_foundation::{
|
||||||
array::{CFArray, CFIndex},
|
array::{CFArray, CFIndex},
|
||||||
string::kCFStringEncodingUTF8,
|
string::kCFStringEncodingUTF8,
|
||||||
|
|
11
crates/cli_rpc/Cargo.toml
Normal file
11
crates/cli_rpc/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "cli_rpc"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
ipc-channel = "0.16"
|
||||||
|
serde.workspace = true
|
||||||
|
serde_derive.workspace = true
|
|
@ -16,6 +16,7 @@ collections = { path = "../collections" }
|
||||||
db = { path = "../db" }
|
db = { path = "../db" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
util_http = { path = "../util_http" }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
staff_mode = { path = "../staff_mode" }
|
staff_mode = { path = "../staff_mode" }
|
||||||
|
|
|
@ -41,7 +41,7 @@ use telemetry::Telemetry;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::channel::ReleaseChannel;
|
use util::channel::ReleaseChannel;
|
||||||
use util::http::HttpClient;
|
use util_http::HttpClient;
|
||||||
use util::{ResultExt, TryFutureExt};
|
use util::{ResultExt, TryFutureExt};
|
||||||
|
|
||||||
pub use rpc::*;
|
pub use rpc::*;
|
||||||
|
@ -141,7 +141,7 @@ pub enum EstablishConnectionError {
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
Other(#[from] anyhow::Error),
|
Other(#[from] anyhow::Error),
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
Http(#[from] util::http::Error),
|
Http(#[from] util_http::Error),
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
Io(#[from] std::io::Error),
|
Io(#[from] std::io::Error),
|
||||||
#[error("{0}")]
|
#[error("{0}")]
|
||||||
|
@ -1416,7 +1416,7 @@ mod tests {
|
||||||
use gpui::{executor::Deterministic, TestAppContext};
|
use gpui::{executor::Deterministic, TestAppContext};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::future;
|
use std::future;
|
||||||
use util::http::FakeHttpClient;
|
use util_http::FakeHttpClient;
|
||||||
|
|
||||||
#[gpui::test(iterations = 10)]
|
#[gpui::test(iterations = 10)]
|
||||||
async fn test_reconnection(cx: &mut TestAppContext) {
|
async fn test_reconnection(cx: &mut TestAppContext) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use parking_lot::Mutex;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::{env, io::Write, mem, path::PathBuf, sync::Arc, time::Duration};
|
use std::{env, io::Write, mem, path::PathBuf, sync::Arc, time::Duration};
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
use util::http::HttpClient;
|
use util_http::HttpClient;
|
||||||
use util::{channel::ReleaseChannel, TryFutureExt};
|
use util::{channel::ReleaseChannel, TryFutureExt};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use rpc::{
|
||||||
ConnectionId, Peer, Receipt, TypedEnvelope,
|
ConnectionId, Peer, Receipt, TypedEnvelope,
|
||||||
};
|
};
|
||||||
use std::{rc::Rc, sync::Arc};
|
use std::{rc::Rc, sync::Arc};
|
||||||
use util::http::FakeHttpClient;
|
use util_http::FakeHttpClient;
|
||||||
|
|
||||||
pub struct FakeServer {
|
pub struct FakeServer {
|
||||||
peer: Arc<Peer>,
|
peer: Arc<Peer>,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use postage::{sink::Sink, watch};
|
||||||
use rpc::proto::{RequestMessage, UsersResponse};
|
use rpc::proto::{RequestMessage, UsersResponse};
|
||||||
use staff_mode::StaffMode;
|
use staff_mode::StaffMode;
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
use util::http::HttpClient;
|
use util_http::HttpClient;
|
||||||
use util::TryFutureExt as _;
|
use util::TryFutureExt as _;
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
|
|
|
@ -28,6 +28,7 @@ theme = { path = "../theme" }
|
||||||
lsp = { path = "../lsp" }
|
lsp = { path = "../lsp" }
|
||||||
node_runtime = { path = "../node_runtime"}
|
node_runtime = { path = "../node_runtime"}
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
util_http = { path = "../util_http" }
|
||||||
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
|
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
|
||||||
async-tar = "0.4.2"
|
async-tar = "0.4.2"
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
|
|
@ -29,8 +29,9 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use util::{
|
use util::{
|
||||||
fs::remove_matching, github::latest_github_release, http::HttpClient, paths, ResultExt,
|
fs::remove_matching, paths, ResultExt,
|
||||||
};
|
};
|
||||||
|
use util_http::{HttpClient, github::latest_github_release};
|
||||||
|
|
||||||
const COPILOT_AUTH_NAMESPACE: &'static str = "copilot_auth";
|
const COPILOT_AUTH_NAMESPACE: &'static str = "copilot_auth";
|
||||||
actions!(copilot_auth, [SignIn, SignOut]);
|
actions!(copilot_auth, [SignIn, SignOut]);
|
||||||
|
|
|
@ -14,6 +14,7 @@ doctest = false
|
||||||
test-support = ["backtrace", "dhat", "env_logger", "collections/test-support"]
|
test-support = ["backtrace", "dhat", "env_logger", "collections/test-support"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow.workspace = true
|
||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
gpui_macros = { path = "../gpui_macros" }
|
gpui_macros = { path = "../gpui_macros" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
@ -52,10 +53,6 @@ usvg = { version = "0.14", features = [] }
|
||||||
uuid = { version = "1.1.2", features = ["v4"] }
|
uuid = { version = "1.1.2", features = ["v4"] }
|
||||||
waker-fn = "1.1.0"
|
waker-fn = "1.1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
bindgen = "0.65.1"
|
|
||||||
cc = "1.0.67"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
backtrace = "0.3"
|
backtrace = "0.3"
|
||||||
collections = { path = "../collections", features = ["test-support"] }
|
collections = { path = "../collections", features = ["test-support"] }
|
||||||
|
@ -66,14 +63,4 @@ simplelog = "0.9"
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
media = { path = "../media" }
|
media = { path = "../media" }
|
||||||
anyhow.workspace = true
|
|
||||||
block = "0.1"
|
|
||||||
cocoa = "0.24"
|
|
||||||
core-foundation = { version = "0.9.3", features = ["with-uuid"] }
|
|
||||||
core-graphics = "0.22.3"
|
|
||||||
core-text = "19.2"
|
|
||||||
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "b2f77d56f450338aa4f7dd2f0197d8c9acb0cf18" }
|
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "b2f77d56f450338aa4f7dd2f0197d8c9acb0cf18" }
|
||||||
foreign-types = "0.3"
|
|
||||||
log.workspace = true
|
|
||||||
metal = "0.21.0"
|
|
||||||
objc = "0.2"
|
|
||||||
|
|
|
@ -138,10 +138,12 @@ pub trait BorrowWindowContext {
|
||||||
pub struct App(Rc<RefCell<AppContext>>);
|
pub struct App(Rc<RefCell<AppContext>>);
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(asset_source: impl AssetSource) -> Result<Self> {
|
pub fn new(
|
||||||
let platform = platform::current::platform();
|
asset_source: impl AssetSource,
|
||||||
|
platform: Arc<dyn Platform>,
|
||||||
|
foreground_platform: Rc<dyn platform::ForegroundPlatform>,
|
||||||
|
) -> Result<Self> {
|
||||||
let foreground = Rc::new(executor::Foreground::platform(platform.dispatcher())?);
|
let foreground = Rc::new(executor::Foreground::platform(platform.dispatcher())?);
|
||||||
let foreground_platform = platform::current::foreground_platform(foreground.clone());
|
|
||||||
let app = Self(Rc::new(RefCell::new(AppContext::new(
|
let app = Self(Rc::new(RefCell::new(AppContext::new(
|
||||||
foreground,
|
foreground,
|
||||||
Arc::new(executor::Background::new()),
|
Arc::new(executor::Background::new()),
|
||||||
|
|
|
@ -33,8 +33,11 @@ impl ClipboardItem {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|m| serde_json::from_str(m).ok())
|
.and_then(|m| serde_json::from_str(m).ok())
|
||||||
}
|
}
|
||||||
|
pub fn raw_metadata(&self) -> Option<&str> {
|
||||||
|
self.metadata.as_deref()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn text_hash(text: &str) -> u64 {
|
pub fn text_hash(text: &str) -> u64 {
|
||||||
let mut hasher = SeaHasher::new();
|
let mut hasher = SeaHasher::new();
|
||||||
text.hash(&mut hasher);
|
text.hash(&mut hasher);
|
||||||
hasher.finish()
|
hasher.finish()
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
mod app;
|
mod app;
|
||||||
pub use app::*;
|
pub use app::*;
|
||||||
mod assets;
|
mod assets;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
|
||||||
pub mod test;
|
|
||||||
pub use assets::*;
|
pub use assets::*;
|
||||||
pub mod elements;
|
pub mod elements;
|
||||||
pub mod font_cache;
|
pub mod font_cache;
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
mod event;
|
mod event;
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
pub mod mac;
|
|
||||||
pub mod test;
|
|
||||||
pub mod current {
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
pub use super::mac::*;
|
|
||||||
}
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
executor,
|
executor,
|
||||||
|
@ -87,7 +80,7 @@ pub trait Platform: Send + Sync {
|
||||||
fn restart(&self);
|
fn restart(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait ForegroundPlatform {
|
pub trait ForegroundPlatform {
|
||||||
fn on_become_active(&self, callback: Box<dyn FnMut()>);
|
fn on_become_active(&self, callback: Box<dyn FnMut()>);
|
||||||
fn on_resign_active(&self, callback: Box<dyn FnMut()>);
|
fn on_resign_active(&self, callback: Box<dyn FnMut()>);
|
||||||
fn on_quit(&self, callback: Box<dyn FnMut()>);
|
fn on_quit(&self, callback: Box<dyn FnMut()>);
|
||||||
|
@ -300,9 +293,9 @@ impl Default for CursorStyle {
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
pub struct AppVersion {
|
pub struct AppVersion {
|
||||||
major: usize,
|
pub major: usize,
|
||||||
minor: usize,
|
pub minor: usize,
|
||||||
patch: usize,
|
pub patch: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for AppVersion {
|
impl FromStr for AppVersion {
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::{
|
||||||
fonts::{FontId, GlyphId},
|
fonts::{FontId, GlyphId},
|
||||||
geometry::{rect::RectF, vector::Vector2F},
|
geometry::{rect::RectF, vector::Vector2F},
|
||||||
json::ToJson,
|
json::ToJson,
|
||||||
platform::{current::Surface, CursorStyle},
|
platform::CursorStyle,
|
||||||
ImageData,
|
ImageData,
|
||||||
};
|
};
|
||||||
pub use mouse_event::*;
|
pub use mouse_event::*;
|
||||||
|
@ -100,6 +100,11 @@ pub struct Icon {
|
||||||
pub color: Color,
|
pub color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Surface {
|
||||||
|
pub bounds: RectF,
|
||||||
|
pub image_buffer: media::core_video::CVImageBuffer,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default, Debug, JsonSchema)]
|
#[derive(Clone, Copy, Default, Debug, JsonSchema)]
|
||||||
pub struct Border {
|
pub struct Border {
|
||||||
pub width: f32,
|
pub width: f32,
|
||||||
|
|
41
crates/gpui_mac/Cargo.toml
Normal file
41
crates/gpui_mac/Cargo.toml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
[package]
|
||||||
|
name = "gpui_mac"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
resvg = "0.14"
|
||||||
|
gpui = {path = "../gpui"}
|
||||||
|
usvg = { version = "0.14", features = [] }
|
||||||
|
tiny-skia = "0.5"
|
||||||
|
uuid = { version = "1.1.2", features = ["v4"] }
|
||||||
|
time.workspace = true
|
||||||
|
etagere = "0.2"
|
||||||
|
ordered-float.workspace = true
|
||||||
|
postage.workspace = true
|
||||||
|
smol.workspace = true
|
||||||
|
ctor.workspace = true
|
||||||
|
parking_lot.workspace = true
|
||||||
|
collections = { path = "../collections" }
|
||||||
|
async-task = "4.0.3"
|
||||||
|
pathfinder_geometry = "0.5"
|
||||||
|
|
||||||
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
|
media = { path = "../media" }
|
||||||
|
anyhow.workspace = true
|
||||||
|
block = "0.1"
|
||||||
|
cocoa = "0.24"
|
||||||
|
core-foundation = { version = "0.9.3", features = ["with-uuid"] }
|
||||||
|
core-graphics = "0.22.3"
|
||||||
|
core-text = "19.2"
|
||||||
|
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "b2f77d56f450338aa4f7dd2f0197d8c9acb0cf18" }
|
||||||
|
foreign-types = "0.3"
|
||||||
|
log.workspace = true
|
||||||
|
metal = "0.21.0"
|
||||||
|
objc = "0.2"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
bindgen = "0.65.1"
|
||||||
|
cc = "1.0.67"
|
|
@ -12,10 +12,10 @@ fn main() {
|
||||||
|
|
||||||
fn generate_dispatch_bindings() {
|
fn generate_dispatch_bindings() {
|
||||||
println!("cargo:rustc-link-lib=framework=System");
|
println!("cargo:rustc-link-lib=framework=System");
|
||||||
println!("cargo:rerun-if-changed=src/platform/mac/dispatch.h");
|
println!("cargo:rerun-if-changed=src/dispatch.h");
|
||||||
|
|
||||||
let bindings = bindgen::Builder::default()
|
let bindings = bindgen::Builder::default()
|
||||||
.header("src/platform/mac/dispatch.h")
|
.header("src/dispatch.h")
|
||||||
.allowlist_var("_dispatch_main_q")
|
.allowlist_var("_dispatch_main_q")
|
||||||
.allowlist_function("dispatch_async_f")
|
.allowlist_function("dispatch_async_f")
|
||||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||||
|
@ -29,10 +29,10 @@ fn generate_dispatch_bindings() {
|
||||||
.expect("couldn't write dispatch bindings");
|
.expect("couldn't write dispatch bindings");
|
||||||
}
|
}
|
||||||
|
|
||||||
const SHADER_HEADER_PATH: &str = "./src/platform/mac/shaders/shaders.h";
|
const SHADER_HEADER_PATH: &str = "./src/shaders/shaders.h";
|
||||||
|
|
||||||
fn compile_metal_shaders() {
|
fn compile_metal_shaders() {
|
||||||
let shader_path = "./src/platform/mac/shaders/shaders.metal";
|
let shader_path = "./src/shaders/shaders.metal";
|
||||||
let air_output_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("shaders.air");
|
let air_output_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("shaders.air");
|
||||||
let metallib_output_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("shaders.metallib");
|
let metallib_output_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("shaders.metallib");
|
||||||
|
|
|
@ -1,30 +1,33 @@
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
|
||||||
use crate::platform::Appearance;
|
|
||||||
use cocoa::{
|
use cocoa::{
|
||||||
appkit::{NSAppearanceNameVibrantDark, NSAppearanceNameVibrantLight},
|
appkit::{NSAppearanceNameVibrantDark, NSAppearanceNameVibrantLight},
|
||||||
base::id,
|
base::id,
|
||||||
foundation::NSString,
|
foundation::NSString,
|
||||||
};
|
};
|
||||||
|
use gpui::platform::Appearance;
|
||||||
use objc::{msg_send, sel, sel_impl};
|
use objc::{msg_send, sel, sel_impl};
|
||||||
|
|
||||||
impl Appearance {
|
pub trait AppearanceFromNative {
|
||||||
pub unsafe fn from_native(appearance: id) -> Self {
|
unsafe fn from_native(appearance: id) -> Self;
|
||||||
|
}
|
||||||
|
impl AppearanceFromNative for Appearance {
|
||||||
|
unsafe fn from_native(appearance: id) -> Appearance {
|
||||||
let name: id = msg_send![appearance, name];
|
let name: id = msg_send![appearance, name];
|
||||||
if name == NSAppearanceNameVibrantLight {
|
if name == NSAppearanceNameVibrantLight {
|
||||||
Self::VibrantLight
|
Appearance::VibrantLight
|
||||||
} else if name == NSAppearanceNameVibrantDark {
|
} else if name == NSAppearanceNameVibrantDark {
|
||||||
Self::VibrantDark
|
Appearance::VibrantDark
|
||||||
} else if name == NSAppearanceNameAqua {
|
} else if name == NSAppearanceNameAqua {
|
||||||
Self::Light
|
Appearance::Light
|
||||||
} else if name == NSAppearanceNameDarkAqua {
|
} else if name == NSAppearanceNameDarkAqua {
|
||||||
Self::Dark
|
Appearance::Dark
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
"unknown appearance: {:?}",
|
"unknown appearance: {:?}",
|
||||||
CStr::from_ptr(name.UTF8String())
|
CStr::from_ptr(name.UTF8String())
|
||||||
);
|
);
|
||||||
Self::Light
|
Appearance::Light
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::geometry::{
|
use etagere::BucketedAtlasAllocator;
|
||||||
|
use foreign_types::ForeignType;
|
||||||
|
use gpui::geometry::{
|
||||||
rect::RectI,
|
rect::RectI,
|
||||||
vector::{vec2i, Vector2I},
|
vector::{vec2i, Vector2I},
|
||||||
};
|
};
|
||||||
use etagere::BucketedAtlasAllocator;
|
|
||||||
use foreign_types::ForeignType;
|
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use metal::{Device, TextureDescriptor};
|
use metal::{Device, TextureDescriptor};
|
||||||
use objc::{msg_send, sel, sel_impl};
|
use objc::{msg_send, sel, sel_impl};
|
|
@ -10,7 +10,7 @@ use objc::{
|
||||||
};
|
};
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
|
|
||||||
use crate::platform;
|
use gpui::platform;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/dispatch_sys.rs"));
|
include!(concat!(env!("OUT_DIR"), "/dispatch_sys.rs"));
|
||||||
|
|
|
@ -1,12 +1,3 @@
|
||||||
use crate::{
|
|
||||||
geometry::vector::vec2f,
|
|
||||||
keymap_matcher::Keystroke,
|
|
||||||
platform::{
|
|
||||||
Event, KeyDownEvent, KeyUpEvent, Modifiers, ModifiersChangedEvent, MouseButton,
|
|
||||||
MouseButtonEvent, MouseExitedEvent, MouseMovedEvent, NavigationDirection, ScrollDelta,
|
|
||||||
ScrollWheelEvent, TouchPhase,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use cocoa::{
|
use cocoa::{
|
||||||
appkit::{NSEvent, NSEventModifierFlags, NSEventPhase, NSEventType},
|
appkit::{NSEvent, NSEventModifierFlags, NSEventPhase, NSEventType},
|
||||||
base::{id, YES},
|
base::{id, YES},
|
||||||
|
@ -18,6 +9,15 @@ use core_graphics::{
|
||||||
};
|
};
|
||||||
use ctor::ctor;
|
use ctor::ctor;
|
||||||
use foreign_types::ForeignType;
|
use foreign_types::ForeignType;
|
||||||
|
use gpui::{
|
||||||
|
geometry::vector::vec2f,
|
||||||
|
keymap_matcher::Keystroke,
|
||||||
|
platform::{
|
||||||
|
Event, KeyDownEvent, KeyUpEvent, Modifiers, ModifiersChangedEvent, MouseButton,
|
||||||
|
MouseButtonEvent, MouseExitedEvent, MouseMovedEvent, NavigationDirection, ScrollDelta,
|
||||||
|
ScrollWheelEvent, TouchPhase,
|
||||||
|
},
|
||||||
|
};
|
||||||
use objc::{class, msg_send, sel, sel_impl};
|
use objc::{class, msg_send, sel, sel_impl};
|
||||||
use std::{borrow::Cow, ffi::CStr, mem, os::raw::c_char, ptr};
|
use std::{borrow::Cow, ffi::CStr, mem, os::raw::c_char, ptr};
|
||||||
|
|
||||||
|
@ -86,8 +86,11 @@ unsafe fn read_modifiers(native_event: id) -> Modifiers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Event {
|
pub trait EventFromNative {
|
||||||
pub unsafe fn from_native(native_event: id, window_height: Option<f32>) -> Option<Self> {
|
unsafe fn from_native(native_event: id, window_height: Option<f32>) -> Option<Event>;
|
||||||
|
}
|
||||||
|
impl EventFromNative for Event {
|
||||||
|
unsafe fn from_native(native_event: id, window_height: Option<f32>) -> Option<Event> {
|
||||||
let event_type = native_event.eventType();
|
let event_type = native_event.eventType();
|
||||||
|
|
||||||
// Filter out event types that aren't in the NSEventType enum.
|
// Filter out event types that aren't in the NSEventType enum.
|
|
@ -1,15 +1,5 @@
|
||||||
mod open_type;
|
mod open_type;
|
||||||
|
|
||||||
use crate::{
|
|
||||||
fonts::{Features, FontId, GlyphId, Metrics, Properties},
|
|
||||||
geometry::{
|
|
||||||
rect::{RectF, RectI},
|
|
||||||
transform2d::Transform2F,
|
|
||||||
vector::{vec2f, Vector2F},
|
|
||||||
},
|
|
||||||
platform::{self, RasterizationOptions},
|
|
||||||
text_layout::{Glyph, LineLayout, Run, RunStyle},
|
|
||||||
};
|
|
||||||
use cocoa::appkit::{CGFloat, CGPoint};
|
use cocoa::appkit::{CGFloat, CGPoint};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use core_foundation::{
|
use core_foundation::{
|
||||||
|
@ -27,6 +17,16 @@ use core_text::{font::CTFont, line::CTLine, string_attributes::kCTFontAttributeN
|
||||||
use font_kit::{
|
use font_kit::{
|
||||||
handle::Handle, hinting::HintingOptions, source::SystemSource, sources::mem::MemSource,
|
handle::Handle, hinting::HintingOptions, source::SystemSource, sources::mem::MemSource,
|
||||||
};
|
};
|
||||||
|
use gpui::{
|
||||||
|
fonts::{Features, FontId, GlyphId, Metrics, Properties},
|
||||||
|
geometry::{
|
||||||
|
rect::{RectF, RectI},
|
||||||
|
transform2d::Transform2F,
|
||||||
|
vector::{vec2f, Vector2F},
|
||||||
|
},
|
||||||
|
platform::{self, RasterizationOptions},
|
||||||
|
text_layout::{Glyph, LineLayout, Run, RunStyle},
|
||||||
|
};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use std::{cell::RefCell, char, cmp, convert::TryFrom, ffi::c_void, sync::Arc};
|
use std::{cell::RefCell, char, cmp, convert::TryFrom, ffi::c_void, sync::Arc};
|
||||||
|
|
||||||
|
@ -506,8 +506,8 @@ extern "C" {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::AppContext;
|
|
||||||
use font_kit::properties::{Style, Weight};
|
use font_kit::properties::{Style, Weight};
|
||||||
|
use gpui::AppContext;
|
||||||
use platform::FontSystem as _;
|
use platform::FontSystem as _;
|
||||||
|
|
||||||
#[crate::test(self, retries = 5)]
|
#[crate::test(self, retries = 5)]
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use crate::fonts::Features;
|
|
||||||
use cocoa::appkit::CGFloat;
|
use cocoa::appkit::CGFloat;
|
||||||
use core_foundation::{base::TCFType, number::CFNumber};
|
use core_foundation::{base::TCFType, number::CFNumber};
|
||||||
use core_graphics::geometry::CGAffineTransform;
|
use core_graphics::geometry::CGAffineTransform;
|
||||||
|
@ -13,6 +12,7 @@ use core_text::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use font_kit::font::Font;
|
use font_kit::font::Font;
|
||||||
|
use gpui::fonts::Features;
|
||||||
|
|
||||||
const kCaseSensitiveLayoutOffSelector: i32 = 1;
|
const kCaseSensitiveLayoutOffSelector: i32 = 1;
|
||||||
const kCaseSensitiveLayoutOnSelector: i32 = 0;
|
const kCaseSensitiveLayoutOnSelector: i32 = 0;
|
|
@ -1,12 +1,12 @@
|
||||||
use super::atlas::{AllocId, AtlasAllocator};
|
use super::atlas::{AllocId, AtlasAllocator};
|
||||||
use crate::{
|
use anyhow::anyhow;
|
||||||
|
use gpui::{
|
||||||
fonts::{FontId, GlyphId},
|
fonts::{FontId, GlyphId},
|
||||||
geometry::{rect::RectI, vector::Vector2I},
|
geometry::{rect::RectI, vector::Vector2I},
|
||||||
platform::{FontSystem, RasterizationOptions},
|
platform::{FontSystem, RasterizationOptions},
|
||||||
scene::ImageGlyph,
|
scene::ImageGlyph,
|
||||||
ImageData,
|
ImageData,
|
||||||
};
|
};
|
||||||
use anyhow::anyhow;
|
|
||||||
use metal::{MTLPixelFormat, TextureDescriptor, TextureRef};
|
use metal::{MTLPixelFormat, TextureDescriptor, TextureRef};
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use std::{collections::HashMap, mem, sync::Arc};
|
use std::{collections::HashMap, mem, sync::Arc};
|
|
@ -10,6 +10,8 @@ mod renderer;
|
||||||
mod screen;
|
mod screen;
|
||||||
mod sprite_cache;
|
mod sprite_cache;
|
||||||
mod status_item;
|
mod status_item;
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test;
|
||||||
mod window;
|
mod window;
|
||||||
|
|
||||||
use cocoa::{
|
use cocoa::{
|
||||||
|
@ -23,15 +25,15 @@ pub use renderer::Surface;
|
||||||
use std::{ops::Range, rc::Rc, sync::Arc};
|
use std::{ops::Range, rc::Rc, sync::Arc};
|
||||||
use window::Window;
|
use window::Window;
|
||||||
|
|
||||||
use crate::executor;
|
use gpui::executor;
|
||||||
|
|
||||||
pub(crate) fn platform() -> Arc<dyn super::Platform> {
|
pub fn platform() -> Arc<dyn gpui::platform::Platform> {
|
||||||
Arc::new(MacPlatform::new())
|
Arc::new(MacPlatform::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn foreground_platform(
|
pub fn foreground_platform(
|
||||||
foreground: Rc<executor::Foreground>,
|
foreground: Rc<executor::Foreground>,
|
||||||
) -> Rc<dyn super::ForegroundPlatform> {
|
) -> Rc<dyn gpui::platform::ForegroundPlatform> {
|
||||||
Rc::new(MacForegroundPlatform::new(foreground))
|
Rc::new(MacForegroundPlatform::new(foreground))
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,7 @@ use super::{
|
||||||
event::key_to_native, screen::Screen, status_item::StatusItem, BoolExt as _, Dispatcher,
|
event::key_to_native, screen::Screen, status_item::StatusItem, BoolExt as _, Dispatcher,
|
||||||
FontSystem, Window,
|
FontSystem, Window,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::event::EventFromNative;
|
||||||
executor,
|
|
||||||
keymap_matcher::KeymapMatcher,
|
|
||||||
platform::{self, AppVersion, CursorStyle, Event},
|
|
||||||
Action, ClipboardItem, Menu, MenuItem,
|
|
||||||
};
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use block::ConcreteBlock;
|
use block::ConcreteBlock;
|
||||||
use cocoa::{
|
use cocoa::{
|
||||||
|
@ -30,6 +25,12 @@ use core_foundation::{
|
||||||
string::{CFString, CFStringRef},
|
string::{CFString, CFStringRef},
|
||||||
};
|
};
|
||||||
use ctor::ctor;
|
use ctor::ctor;
|
||||||
|
use gpui::{
|
||||||
|
executor,
|
||||||
|
keymap_matcher::KeymapMatcher,
|
||||||
|
platform::{self, AppVersion, CursorStyle, Event},
|
||||||
|
Action, ClipboardItem, Menu, MenuItem,
|
||||||
|
};
|
||||||
use objc::{
|
use objc::{
|
||||||
class,
|
class,
|
||||||
declare::ClassDecl,
|
declare::ClassDecl,
|
||||||
|
@ -235,12 +236,12 @@ impl MacForegroundPlatform {
|
||||||
.find(|binding| binding.action().eq(action.as_ref()))
|
.find(|binding| binding.action().eq(action.as_ref()))
|
||||||
.map(|binding| binding.keystrokes());
|
.map(|binding| binding.keystrokes());
|
||||||
let selector = match os_action {
|
let selector = match os_action {
|
||||||
Some(crate::OsAction::Cut) => selector("cut:"),
|
Some(gpui::OsAction::Cut) => selector("cut:"),
|
||||||
Some(crate::OsAction::Copy) => selector("copy:"),
|
Some(gpui::OsAction::Copy) => selector("copy:"),
|
||||||
Some(crate::OsAction::Paste) => selector("paste:"),
|
Some(gpui::OsAction::Paste) => selector("paste:"),
|
||||||
Some(crate::OsAction::SelectAll) => selector("selectAll:"),
|
Some(gpui::OsAction::SelectAll) => selector("selectAll:"),
|
||||||
Some(crate::OsAction::Undo) => selector("undo:"),
|
Some(gpui::OsAction::Undo) => selector("undo:"),
|
||||||
Some(crate::OsAction::Redo) => selector("redo:"),
|
Some(gpui::OsAction::Redo) => selector("redo:"),
|
||||||
None => selector("handleGPUIMenuItem:"),
|
None => selector("handleGPUIMenuItem:"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -611,14 +612,14 @@ impl platform::Platform for MacPlatform {
|
||||||
|
|
||||||
let text_bytes = NSData::dataWithBytes_length_(
|
let text_bytes = NSData::dataWithBytes_length_(
|
||||||
nil,
|
nil,
|
||||||
item.text.as_ptr() as *const c_void,
|
item.text().as_ptr() as *const c_void,
|
||||||
item.text.len() as u64,
|
item.text().len() as u64,
|
||||||
);
|
);
|
||||||
self.pasteboard
|
self.pasteboard
|
||||||
.setData_forType(text_bytes, NSPasteboardTypeString);
|
.setData_forType(text_bytes, NSPasteboardTypeString);
|
||||||
|
|
||||||
if let Some(metadata) = item.metadata.as_ref() {
|
if let Some(metadata) = item.raw_metadata() {
|
||||||
let hash_bytes = ClipboardItem::text_hash(&item.text).to_be_bytes();
|
let hash_bytes = ClipboardItem::text_hash(&item.text()).to_be_bytes();
|
||||||
let hash_bytes = NSData::dataWithBytes_length_(
|
let hash_bytes = NSData::dataWithBytes_length_(
|
||||||
nil,
|
nil,
|
||||||
hash_bytes.as_ptr() as *const c_void,
|
hash_bytes.as_ptr() as *const c_void,
|
||||||
|
@ -652,21 +653,12 @@ impl platform::Platform for MacPlatform {
|
||||||
|
|
||||||
if let Some((hash, metadata)) = hash_bytes.zip(metadata_bytes) {
|
if let Some((hash, metadata)) = hash_bytes.zip(metadata_bytes) {
|
||||||
if hash == ClipboardItem::text_hash(&text) {
|
if hash == ClipboardItem::text_hash(&text) {
|
||||||
Some(ClipboardItem {
|
Some(ClipboardItem::new(text).with_metadata(metadata))
|
||||||
text,
|
|
||||||
metadata: Some(metadata),
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
Some(ClipboardItem {
|
Some(ClipboardItem::new(text))
|
||||||
text,
|
|
||||||
metadata: None,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Some(ClipboardItem {
|
Some(ClipboardItem::new(text))
|
||||||
text,
|
|
||||||
metadata: None,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -868,7 +860,7 @@ impl platform::Platform for MacPlatform {
|
||||||
"macOS"
|
"macOS"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn os_version(&self) -> Result<crate::platform::AppVersion> {
|
fn os_version(&self) -> Result<gpui::platform::AppVersion> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let process_info = NSProcessInfo::processInfo(nil);
|
let process_info = NSProcessInfo::processInfo(nil);
|
||||||
let version = process_info.operatingSystemVersion();
|
let version = process_info.operatingSystemVersion();
|
||||||
|
@ -1097,7 +1089,7 @@ mod security {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::platform::Platform;
|
use gpui::platform::Platform;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
use super::{atlas::AtlasAllocator, image_cache::ImageCache, sprite_cache::SpriteCache};
|
use super::{atlas::AtlasAllocator, image_cache::ImageCache, sprite_cache::SpriteCache};
|
||||||
use crate::{
|
use crate::renderer::shaders::ColorToUchar4;
|
||||||
|
use cocoa::{
|
||||||
|
base::{NO, YES},
|
||||||
|
foundation::NSUInteger,
|
||||||
|
quartzcore::AutoresizingMask,
|
||||||
|
};
|
||||||
|
use core_foundation::base::TCFType;
|
||||||
|
use foreign_types::ForeignTypeRef;
|
||||||
|
pub use gpui::scene::Surface;
|
||||||
|
use gpui::{
|
||||||
color::Color,
|
color::Color,
|
||||||
geometry::{
|
geometry::{
|
||||||
rect::RectF,
|
rect::RectF,
|
||||||
|
@ -8,13 +17,6 @@ use crate::{
|
||||||
platform,
|
platform,
|
||||||
scene::{Glyph, Icon, Image, ImageGlyph, Layer, Quad, Scene, Shadow, Underline},
|
scene::{Glyph, Icon, Image, ImageGlyph, Layer, Quad, Scene, Shadow, Underline},
|
||||||
};
|
};
|
||||||
use cocoa::{
|
|
||||||
base::{NO, YES},
|
|
||||||
foundation::NSUInteger,
|
|
||||||
quartzcore::AutoresizingMask,
|
|
||||||
};
|
|
||||||
use core_foundation::base::TCFType;
|
|
||||||
use foreign_types::ForeignTypeRef;
|
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use media::core_video::{self, CVMetalTextureCache};
|
use media::core_video::{self, CVMetalTextureCache};
|
||||||
use metal::{CommandQueue, MTLPixelFormat, MTLResourceOptions, NSRange};
|
use metal::{CommandQueue, MTLPixelFormat, MTLResourceOptions, NSRange};
|
||||||
|
@ -49,11 +51,6 @@ struct PathSprite {
|
||||||
shader_data: shaders::GPUISprite,
|
shader_data: shaders::GPUISprite,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Surface {
|
|
||||||
pub bounds: RectF,
|
|
||||||
pub image_buffer: core_video::CVImageBuffer,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Renderer {
|
impl Renderer {
|
||||||
pub fn new(is_opaque: bool, fonts: Arc<dyn platform::FontSystem>) -> Self {
|
pub fn new(is_opaque: bool, fonts: Arc<dyn platform::FontSystem>) -> Self {
|
||||||
const PIXEL_FORMAT: MTLPixelFormat = MTLPixelFormat::BGRA8Unorm;
|
const PIXEL_FORMAT: MTLPixelFormat = MTLPixelFormat::BGRA8Unorm;
|
||||||
|
@ -1208,7 +1205,7 @@ mod shaders {
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::{
|
use gpui::{
|
||||||
color::Color,
|
color::Color,
|
||||||
geometry::vector::{Vector2F, Vector2I},
|
geometry::vector::{Vector2F, Vector2I},
|
||||||
};
|
};
|
||||||
|
@ -1247,9 +1244,11 @@ mod shaders {
|
||||||
self.to_f32().to_float2()
|
self.to_f32().to_float2()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pub trait ColorToUchar4 {
|
||||||
impl Color {
|
fn to_uchar4(&self) -> vector_uchar4;
|
||||||
pub fn to_uchar4(&self) -> vector_uchar4 {
|
}
|
||||||
|
impl ColorToUchar4 for Color {
|
||||||
|
fn to_uchar4(&self) -> vector_uchar4 {
|
||||||
let mut vec = self.a as vector_uchar4;
|
let mut vec = self.a as vector_uchar4;
|
||||||
vec <<= 8;
|
vec <<= 8;
|
||||||
vec |= self.b as vector_uchar4;
|
vec |= self.b as vector_uchar4;
|
|
@ -1,6 +1,5 @@
|
||||||
use std::{any::Any, ffi::c_void};
|
use std::{any::Any, ffi::c_void};
|
||||||
|
|
||||||
use crate::platform;
|
|
||||||
use cocoa::{
|
use cocoa::{
|
||||||
appkit::NSScreen,
|
appkit::NSScreen,
|
||||||
base::{id, nil},
|
base::{id, nil},
|
||||||
|
@ -11,6 +10,7 @@ use core_foundation::{
|
||||||
uuid::{CFUUIDGetUUIDBytes, CFUUIDRef},
|
uuid::{CFUUIDGetUUIDBytes, CFUUIDRef},
|
||||||
};
|
};
|
||||||
use core_graphics::display::CGDirectDisplayID;
|
use core_graphics::display::CGDirectDisplayID;
|
||||||
|
use gpui::platform;
|
||||||
use pathfinder_geometry::rect::RectF;
|
use pathfinder_geometry::rect::RectF;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use super::atlas::AtlasAllocator;
|
use super::atlas::AtlasAllocator;
|
||||||
use crate::{
|
use collections::hash_map::Entry;
|
||||||
|
use gpui::{
|
||||||
fonts::{FontId, GlyphId},
|
fonts::{FontId, GlyphId},
|
||||||
geometry::vector::{vec2f, Vector2F, Vector2I},
|
geometry::vector::{vec2f, Vector2F, Vector2I},
|
||||||
platform::{self, RasterizationOptions},
|
platform::{self, RasterizationOptions},
|
||||||
};
|
};
|
||||||
use collections::hash_map::Entry;
|
|
||||||
use metal::{MTLPixelFormat, TextureDescriptor};
|
use metal::{MTLPixelFormat, TextureDescriptor};
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use std::{borrow::Cow, collections::HashMap, sync::Arc};
|
use std::{borrow::Cow, collections::HashMap, sync::Arc};
|
|
@ -1,15 +1,6 @@
|
||||||
use crate::{
|
use crate::appearance::AppearanceFromNative;
|
||||||
geometry::{
|
use crate::event::EventFromNative;
|
||||||
rect::RectF,
|
use crate::{platform::NSViewLayerContentsRedrawDuringViewResize, renderer::Renderer};
|
||||||
vector::{vec2f, Vector2F},
|
|
||||||
},
|
|
||||||
platform::{
|
|
||||||
self,
|
|
||||||
mac::{platform::NSViewLayerContentsRedrawDuringViewResize, renderer::Renderer},
|
|
||||||
Event, FontSystem, WindowBounds,
|
|
||||||
},
|
|
||||||
Scene,
|
|
||||||
};
|
|
||||||
use cocoa::{
|
use cocoa::{
|
||||||
appkit::{NSScreen, NSSquareStatusItemLength, NSStatusBar, NSStatusItem, NSView, NSWindow},
|
appkit::{NSScreen, NSSquareStatusItemLength, NSStatusBar, NSStatusItem, NSView, NSWindow},
|
||||||
base::{id, nil, YES},
|
base::{id, nil, YES},
|
||||||
|
@ -17,6 +8,14 @@ use cocoa::{
|
||||||
};
|
};
|
||||||
use ctor::ctor;
|
use ctor::ctor;
|
||||||
use foreign_types::ForeignTypeRef;
|
use foreign_types::ForeignTypeRef;
|
||||||
|
use gpui::{
|
||||||
|
geometry::{
|
||||||
|
rect::RectF,
|
||||||
|
vector::{vec2f, Vector2F},
|
||||||
|
},
|
||||||
|
platform::{self, Event, FontSystem, WindowBounds},
|
||||||
|
Scene,
|
||||||
|
};
|
||||||
use objc::{
|
use objc::{
|
||||||
class,
|
class,
|
||||||
declare::ClassDecl,
|
declare::ClassDecl,
|
||||||
|
@ -210,7 +209,7 @@ impl platform::Window for StatusItem {
|
||||||
|
|
||||||
fn prompt(
|
fn prompt(
|
||||||
&self,
|
&self,
|
||||||
_: crate::platform::PromptLevel,
|
_: gpui::platform::PromptLevel,
|
||||||
_: &str,
|
_: &str,
|
||||||
_: &[&str],
|
_: &[&str],
|
||||||
) -> postage::oneshot::Receiver<usize> {
|
) -> postage::oneshot::Receiver<usize> {
|
|
@ -1,5 +1,7 @@
|
||||||
use super::{AppVersion, CursorStyle, WindowBounds};
|
use super::{AppVersion, CursorStyle, WindowBounds};
|
||||||
use crate::{
|
use anyhow::{anyhow, Result};
|
||||||
|
use collections::VecDeque;
|
||||||
|
use gpui::{
|
||||||
geometry::{
|
geometry::{
|
||||||
rect::RectF,
|
rect::RectF,
|
||||||
vector::{vec2f, Vector2F},
|
vector::{vec2f, Vector2F},
|
||||||
|
@ -7,8 +9,6 @@ use crate::{
|
||||||
keymap_matcher::KeymapMatcher,
|
keymap_matcher::KeymapMatcher,
|
||||||
Action, ClipboardItem, Menu,
|
Action, ClipboardItem, Menu,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
|
||||||
use collections::VecDeque;
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use postage::oneshot;
|
use postage::oneshot;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -64,7 +64,7 @@ impl super::ForegroundPlatform for ForegroundPlatform {
|
||||||
fn on_resign_active(&self, _: Box<dyn FnMut()>) {}
|
fn on_resign_active(&self, _: Box<dyn FnMut()>) {}
|
||||||
fn on_quit(&self, _: Box<dyn FnMut()>) {}
|
fn on_quit(&self, _: Box<dyn FnMut()>) {}
|
||||||
fn on_reopen(&self, _: Box<dyn FnMut()>) {}
|
fn on_reopen(&self, _: Box<dyn FnMut()>) {}
|
||||||
fn on_event(&self, _: Box<dyn FnMut(crate::platform::Event) -> bool>) {}
|
fn on_event(&self, _: Box<dyn FnMut(gpui::platform::Event) -> bool>) {}
|
||||||
fn on_open_urls(&self, _: Box<dyn FnMut(Vec<String>)>) {}
|
fn on_open_urls(&self, _: Box<dyn FnMut(Vec<String>)>) {}
|
||||||
|
|
||||||
fn run(&self, _on_finish_launching: Box<dyn FnOnce()>) {
|
fn run(&self, _on_finish_launching: Box<dyn FnOnce()>) {
|
||||||
|
@ -136,11 +136,11 @@ impl super::Platform for Platform {
|
||||||
|
|
||||||
fn quit(&self) {}
|
fn quit(&self) {}
|
||||||
|
|
||||||
fn screen_by_id(&self, _id: uuid::Uuid) -> Option<Rc<dyn crate::platform::Screen>> {
|
fn screen_by_id(&self, _id: uuid::Uuid) -> Option<Rc<dyn gpui::platform::Screen>> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn screens(&self) -> Vec<Rc<dyn crate::platform::Screen>> {
|
fn screens(&self) -> Vec<Rc<dyn gpui::platform::Screen>> {
|
||||||
Default::default()
|
Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ impl super::Platform for Platform {
|
||||||
self.active_window_id.lock().clone()
|
self.active_window_id.lock().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_status_item(&self, id: usize) -> Box<dyn crate::platform::Window> {
|
fn add_status_item(&self, id: usize) -> Box<dyn gpui::platform::Window> {
|
||||||
Box::new(Window::new(
|
Box::new(Window::new(
|
||||||
id,
|
id,
|
||||||
vec2f(24., 24.),
|
vec2f(24., 24.),
|
||||||
|
@ -259,7 +259,7 @@ pub struct Window {
|
||||||
id: usize,
|
id: usize,
|
||||||
pub(crate) size: Vector2F,
|
pub(crate) size: Vector2F,
|
||||||
scale_factor: f32,
|
scale_factor: f32,
|
||||||
current_scene: Option<crate::Scene>,
|
current_scene: Option<gpui::Scene>,
|
||||||
event_handlers: Vec<Box<dyn FnMut(super::Event) -> bool>>,
|
event_handlers: Vec<Box<dyn FnMut(super::Event) -> bool>>,
|
||||||
pub(crate) resize_handlers: Vec<Box<dyn FnMut()>>,
|
pub(crate) resize_handlers: Vec<Box<dyn FnMut()>>,
|
||||||
pub(crate) moved_handlers: Vec<Box<dyn FnMut()>>,
|
pub(crate) moved_handlers: Vec<Box<dyn FnMut()>>,
|
||||||
|
@ -316,11 +316,11 @@ impl super::Window for Window {
|
||||||
24.
|
24.
|
||||||
}
|
}
|
||||||
|
|
||||||
fn appearance(&self) -> crate::platform::Appearance {
|
fn appearance(&self) -> gpui::platform::Appearance {
|
||||||
crate::platform::Appearance::Light
|
gpui::platform::Appearance::Light
|
||||||
}
|
}
|
||||||
|
|
||||||
fn screen(&self) -> Rc<dyn crate::platform::Screen> {
|
fn screen(&self) -> Rc<dyn gpui::platform::Screen> {
|
||||||
Rc::new(Screen)
|
Rc::new(Screen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,11 +328,11 @@ impl super::Window for Window {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_input_handler(&mut self, _: Box<dyn crate::platform::InputHandler>) {}
|
fn set_input_handler(&mut self, _: Box<dyn gpui::platform::InputHandler>) {}
|
||||||
|
|
||||||
fn prompt(
|
fn prompt(
|
||||||
&self,
|
&self,
|
||||||
_: crate::platform::PromptLevel,
|
_: gpui::platform::PromptLevel,
|
||||||
_: &str,
|
_: &str,
|
||||||
_: &[&str],
|
_: &[&str],
|
||||||
) -> oneshot::Receiver<usize> {
|
) -> oneshot::Receiver<usize> {
|
||||||
|
@ -359,13 +359,13 @@ impl super::Window for Window {
|
||||||
|
|
||||||
fn zoom(&self) {}
|
fn zoom(&self) {}
|
||||||
|
|
||||||
fn present_scene(&mut self, scene: crate::Scene) {
|
fn present_scene(&mut self, scene: gpui::Scene) {
|
||||||
self.current_scene = Some(scene);
|
self.current_scene = Some(scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_full_screen(&self) {}
|
fn toggle_full_screen(&self) {}
|
||||||
|
|
||||||
fn on_event(&mut self, callback: Box<dyn FnMut(crate::platform::Event) -> bool>) {
|
fn on_event(&mut self, callback: Box<dyn FnMut(gpui::platform::Event) -> bool>) {
|
||||||
self.event_handlers.push(callback);
|
self.event_handlers.push(callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
|
use crate::appearance::AppearanceFromNative;
|
||||||
|
use crate::event::EventFromNative;
|
||||||
use crate::{
|
use crate::{
|
||||||
executor,
|
|
||||||
geometry::{
|
|
||||||
rect::RectF,
|
|
||||||
vector::{vec2f, Vector2F},
|
|
||||||
},
|
|
||||||
keymap_matcher::Keystroke,
|
|
||||||
platform::{
|
|
||||||
self,
|
|
||||||
mac::{
|
|
||||||
platform::NSViewLayerContentsRedrawDuringViewResize, renderer::Renderer, screen::Screen,
|
platform::NSViewLayerContentsRedrawDuringViewResize, renderer::Renderer, screen::Screen,
|
||||||
},
|
|
||||||
Event, InputHandler, KeyDownEvent, ModifiersChangedEvent, MouseButton, MouseButtonEvent,
|
|
||||||
MouseMovedEvent, Scene, WindowBounds, WindowKind,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use block::ConcreteBlock;
|
use block::ConcreteBlock;
|
||||||
use cocoa::{
|
use cocoa::{
|
||||||
|
@ -27,6 +16,19 @@ use cocoa::{
|
||||||
use core_graphics::display::CGRect;
|
use core_graphics::display::CGRect;
|
||||||
use ctor::ctor;
|
use ctor::ctor;
|
||||||
use foreign_types::ForeignTypeRef;
|
use foreign_types::ForeignTypeRef;
|
||||||
|
use gpui::{
|
||||||
|
executor,
|
||||||
|
geometry::{
|
||||||
|
rect::RectF,
|
||||||
|
vector::{vec2f, Vector2F},
|
||||||
|
},
|
||||||
|
keymap_matcher::Keystroke,
|
||||||
|
platform::{
|
||||||
|
self, Event, InputHandler, KeyDownEvent, ModifiersChangedEvent, MouseButton,
|
||||||
|
MouseButtonEvent, MouseMovedEvent, WindowBounds, WindowKind,
|
||||||
|
},
|
||||||
|
Scene,
|
||||||
|
};
|
||||||
use objc::{
|
use objc::{
|
||||||
class,
|
class,
|
||||||
declare::ClassDecl,
|
declare::ClassDecl,
|
|
@ -36,6 +36,7 @@ sum_tree = { path = "../sum_tree" }
|
||||||
text = { path = "../text" }
|
text = { path = "../text" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
util_http = { path = "../util_http" }
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
async-broadcast = "0.4"
|
async-broadcast = "0.4"
|
||||||
|
|
|
@ -46,7 +46,7 @@ use syntax_map::SyntaxSnapshot;
|
||||||
use theme::{SyntaxTheme, Theme};
|
use theme::{SyntaxTheme, Theme};
|
||||||
use tree_sitter::{self, Query};
|
use tree_sitter::{self, Query};
|
||||||
use unicase::UniCase;
|
use unicase::UniCase;
|
||||||
use util::http::HttpClient;
|
use util_http::HttpClient;
|
||||||
use util::{merge_json_value_into, post_inc, ResultExt, TryFutureExt as _, UnwrapFuture};
|
use util::{merge_json_value_into, post_inc, ResultExt, TryFutureExt as _, UnwrapFuture};
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
|
|
|
@ -10,6 +10,7 @@ doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
|
util_http = { path = "../util_http" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
|
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
|
||||||
async-tar = "0.4.2"
|
async-tar = "0.4.2"
|
||||||
|
|
|
@ -11,7 +11,7 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use util::http::HttpClient;
|
use util_http::HttpClient;
|
||||||
|
|
||||||
const VERSION: &str = "v18.15.0";
|
const VERSION: &str = "v18.15.0";
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ settings = { path = "../settings" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
terminal = { path = "../terminal" }
|
terminal = { path = "../terminal" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
util_http = { path = "../util_http" }
|
||||||
|
|
||||||
aho-corasick = "0.7"
|
aho-corasick = "0.7"
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
|
|
@ -75,9 +75,10 @@ use std::{
|
||||||
};
|
};
|
||||||
use terminals::Terminals;
|
use terminals::Terminals;
|
||||||
use util::{
|
use util::{
|
||||||
debug_panic, defer, http::HttpClient, merge_json_value_into,
|
debug_panic, defer, merge_json_value_into,
|
||||||
paths::LOCAL_SETTINGS_RELATIVE_PATH, post_inc, ResultExt, TryFutureExt as _,
|
paths::LOCAL_SETTINGS_RELATIVE_PATH, post_inc, ResultExt, TryFutureExt as _,
|
||||||
};
|
};
|
||||||
|
use util_http::HttpClient;
|
||||||
|
|
||||||
pub use fs::*;
|
pub use fs::*;
|
||||||
pub use worktree::*;
|
pub use worktree::*;
|
||||||
|
@ -681,7 +682,7 @@ impl Project {
|
||||||
) -> ModelHandle<Project> {
|
) -> ModelHandle<Project> {
|
||||||
let mut languages = LanguageRegistry::test();
|
let mut languages = LanguageRegistry::test();
|
||||||
languages.set_executor(cx.background());
|
languages.set_executor(cx.background());
|
||||||
let http_client = util::http::FakeHttpClient::with_404_response();
|
let http_client = util_http::FakeHttpClient::with_404_response();
|
||||||
let client = cx.update(|cx| client::Client::new(http_client.clone(), cx));
|
let client = cx.update(|cx| client::Client::new(http_client.clone(), cx));
|
||||||
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
|
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
|
||||||
let project =
|
let project =
|
||||||
|
|
|
@ -9,7 +9,7 @@ path = "src/util.rs"
|
||||||
doctest = true
|
doctest = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["tempdir", "git2"]
|
test-support = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
@ -17,15 +17,12 @@ backtrace = "0.3"
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
lazy_static.workspace = true
|
lazy_static.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
isahc.workspace = true
|
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
url = "2.2"
|
|
||||||
rand.workspace = true
|
rand.workspace = true
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
tempdir = { workspace = true, optional = true }
|
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
git2 = { version = "0.15", default-features = false, optional = true }
|
|
||||||
dirs = "3.0"
|
dirs = "3.0"
|
||||||
take-until = "0.2.0"
|
take-until = "0.2.0"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
pub mod channel;
|
pub mod channel;
|
||||||
pub mod fs;
|
pub mod fs;
|
||||||
pub mod github;
|
|
||||||
pub mod http;
|
|
||||||
pub mod paths;
|
pub mod paths;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
22
crates/util_http/Cargo.toml
Normal file
22
crates/util_http/Cargo.toml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
[package]
|
||||||
|
name = "util_http"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
isahc.workspace = true
|
||||||
|
anyhow.workspace = true
|
||||||
|
futures.workspace = true
|
||||||
|
serde_json.workspace = true
|
||||||
|
smol.workspace = true
|
||||||
|
serde.workspace = true
|
||||||
|
log.workspace = true
|
||||||
|
url = "2.2"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
test-support = []
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
tempdir.workspace = true
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::http::HttpClient;
|
use crate::HttpClient;
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use futures::AsyncReadExt;
|
use futures::AsyncReadExt;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
|
@ -1,3 +1,5 @@
|
||||||
|
pub mod github;
|
||||||
|
|
||||||
pub use anyhow::{anyhow, Result};
|
pub use anyhow::{anyhow, Result};
|
||||||
use futures::future::BoxFuture;
|
use futures::future::BoxFuture;
|
||||||
use isahc::config::{Configurable, RedirectPolicy};
|
use isahc::config::{Configurable, RedirectPolicy};
|
|
@ -80,7 +80,7 @@ impl View for SharedScreen {
|
||||||
vec2f(frame.width() as f32, frame.height() as f32),
|
vec2f(frame.width() as f32, frame.height() as f32),
|
||||||
);
|
);
|
||||||
let origin = bounds.origin() + (bounds.size() / 2.) - size / 2.;
|
let origin = bounds.origin() + (bounds.size() / 2.) - size / 2.;
|
||||||
scene.push_surface(gpui::platform::mac::Surface {
|
scene.push_surface(gpui::scene::Surface {
|
||||||
bounds: RectF::new(origin, size),
|
bounds: RectF::new(origin, size),
|
||||||
image_buffer: frame.image(),
|
image_buffer: frame.image(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ activity_indicator = { path = "../activity_indicator" }
|
||||||
auto_update = { path = "../auto_update" }
|
auto_update = { path = "../auto_update" }
|
||||||
breadcrumbs = { path = "../breadcrumbs" }
|
breadcrumbs = { path = "../breadcrumbs" }
|
||||||
call = { path = "../call" }
|
call = { path = "../call" }
|
||||||
cli = { path = "../cli" }
|
cli_rpc = { path = "../cli_rpc" }
|
||||||
collab_ui = { path = "../collab_ui" }
|
collab_ui = { path = "../collab_ui" }
|
||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
command_palette = { path = "../command_palette" }
|
command_palette = { path = "../command_palette" }
|
||||||
|
@ -63,9 +63,11 @@ terminal_view = { path = "../terminal_view" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
theme_selector = { path = "../theme_selector" }
|
theme_selector = { path = "../theme_selector" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
util_http = { path = "../util_http" }
|
||||||
vim = { path = "../vim" }
|
vim = { path = "../vim" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
welcome = { path = "../welcome" }
|
welcome = { path = "../welcome" }
|
||||||
|
gpui_mac = {path = "../gpui_mac"}
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
|
async-compression = { version = "0.3", features = ["gzip", "futures-bufread"] }
|
||||||
|
|
|
@ -6,10 +6,10 @@ use smol::fs::{self, File};
|
||||||
use std::{any::Any, path::PathBuf, sync::Arc};
|
use std::{any::Any, path::PathBuf, sync::Arc};
|
||||||
use util::{
|
use util::{
|
||||||
fs::remove_matching,
|
fs::remove_matching,
|
||||||
github::{latest_github_release, GitHubLspBinaryVersion},
|
|
||||||
ResultExt,
|
ResultExt,
|
||||||
};
|
};
|
||||||
|
use util_http::github::{latest_github_release, GitHubLspBinaryVersion};
|
||||||
pub struct CLspAdapter;
|
pub struct CLspAdapter;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|
|
@ -15,10 +15,11 @@ use std::{
|
||||||
};
|
};
|
||||||
use util::{
|
use util::{
|
||||||
fs::remove_matching,
|
fs::remove_matching,
|
||||||
github::{latest_github_release, GitHubLspBinaryVersion},
|
|
||||||
ResultExt,
|
ResultExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use util_http::github::{latest_github_release, GitHubLspBinaryVersion};
|
||||||
pub struct ElixirLspAdapter;
|
pub struct ElixirLspAdapter;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|
|
@ -17,8 +17,8 @@ use std::{
|
||||||
Arc,
|
Arc,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use util::{fs::remove_matching, github::latest_github_release, ResultExt};
|
use util::{fs::remove_matching, ResultExt};
|
||||||
|
use util_http::github::latest_github_release;
|
||||||
fn server_binary_arguments() -> Vec<OsString> {
|
fn server_binary_arguments() -> Vec<OsString> {
|
||||||
vec!["-mode=stdio".into()]
|
vec!["-mode=stdio".into()]
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ use smol::fs;
|
||||||
use std::{any::Any, env::consts, ffi::OsString, path::PathBuf};
|
use std::{any::Any, env::consts, ffi::OsString, path::PathBuf};
|
||||||
use util::{
|
use util::{
|
||||||
async_iife,
|
async_iife,
|
||||||
github::{latest_github_release, GitHubLspBinaryVersion},
|
|
||||||
ResultExt,
|
ResultExt,
|
||||||
};
|
};
|
||||||
|
use util_http::github::{latest_github_release, GitHubLspBinaryVersion};
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct LuaLspAdapter;
|
pub struct LuaLspAdapter;
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,10 @@ use smol::fs::{self, File};
|
||||||
use std::{any::Any, borrow::Cow, env::consts, path::PathBuf, str, sync::Arc};
|
use std::{any::Any, borrow::Cow, env::consts, path::PathBuf, str, sync::Arc};
|
||||||
use util::{
|
use util::{
|
||||||
fs::remove_matching,
|
fs::remove_matching,
|
||||||
github::{latest_github_release, GitHubLspBinaryVersion},
|
|
||||||
ResultExt,
|
ResultExt,
|
||||||
};
|
};
|
||||||
|
use util_http::github::{latest_github_release, GitHubLspBinaryVersion};
|
||||||
|
|
||||||
pub struct RustLspAdapter;
|
pub struct RustLspAdapter;
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,8 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use util::{fs::remove_matching, github::latest_github_release};
|
use util::{fs::remove_matching, ResultExt};
|
||||||
use util::{github::GitHubLspBinaryVersion, ResultExt};
|
use util_http::github::{latest_github_release, GitHubLspBinaryVersion};
|
||||||
|
|
||||||
fn typescript_server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
fn typescript_server_binary_arguments(server_path: &Path) -> Vec<OsString> {
|
||||||
vec![
|
vec![
|
||||||
server_path.into(),
|
server_path.into(),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use backtrace::Backtrace;
|
use backtrace::Backtrace;
|
||||||
use cli::{
|
use cli_rpc::{
|
||||||
ipc::{self, IpcSender},
|
ipc::{self, IpcSender},
|
||||||
CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,
|
CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,
|
||||||
};
|
};
|
||||||
|
@ -45,12 +45,14 @@ use std::{
|
||||||
use sum_tree::Bias;
|
use sum_tree::Bias;
|
||||||
use terminal_view::{get_working_directory, TerminalSettings, TerminalView};
|
use terminal_view::{get_working_directory, TerminalSettings, TerminalView};
|
||||||
use util::{
|
use util::{
|
||||||
http::{self, HttpClient},
|
|
||||||
paths::PathLikeWithPosition,
|
paths::PathLikeWithPosition,
|
||||||
};
|
};
|
||||||
|
use util_http::{self as http, HttpClient};
|
||||||
use welcome::{show_welcome_experience, FIRST_OPEN};
|
use welcome::{show_welcome_experience, FIRST_OPEN};
|
||||||
|
|
||||||
use fs::RealFs;
|
use fs::RealFs;
|
||||||
|
use gpui_mac::{foreground_platform, platform};
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
use staff_mode::StaffMode;
|
use staff_mode::StaffMode;
|
||||||
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
|
||||||
|
@ -59,14 +61,17 @@ use zed::{
|
||||||
assets::Assets, build_window_options, handle_keymap_file_changes, initialize_workspace,
|
assets::Assets, build_window_options, handle_keymap_file_changes, initialize_workspace,
|
||||||
languages, menus,
|
languages, menus,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let http = http::client();
|
let http = http::client();
|
||||||
init_paths();
|
init_paths();
|
||||||
init_logger();
|
init_logger();
|
||||||
|
|
||||||
log::info!("========== starting zed ==========");
|
log::info!("========== starting zed ==========");
|
||||||
let mut app = gpui::App::new(Assets).unwrap();
|
let platform = platform();
|
||||||
|
let foreground =
|
||||||
|
std::rc::Rc::new(gpui::executor::Foreground::platform(platform.dispatcher()).unwrap());
|
||||||
|
let fplatform = foreground_platform(foreground);
|
||||||
|
let mut app = gpui::App::new(Assets, platform, fplatform).unwrap();
|
||||||
|
|
||||||
init_panic_hook(&app);
|
init_panic_hook(&app);
|
||||||
|
|
||||||
|
@ -663,7 +668,7 @@ async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()>
|
||||||
fn connect_to_cli(
|
fn connect_to_cli(
|
||||||
server_name: &str,
|
server_name: &str,
|
||||||
) -> Result<(mpsc::Receiver<CliRequest>, IpcSender<CliResponse>)> {
|
) -> Result<(mpsc::Receiver<CliRequest>, IpcSender<CliResponse>)> {
|
||||||
let handshake_tx = cli::ipc::IpcSender::<IpcHandshake>::connect(server_name.to_string())
|
let handshake_tx = cli_rpc::ipc::IpcSender::<IpcHandshake>::connect(server_name.to_string())
|
||||||
.context("error connecting to cli")?;
|
.context("error connecting to cli")?;
|
||||||
let (request_tx, request_rx) = ipc::channel::<CliRequest>()?;
|
let (request_tx, request_rx) = ipc::channel::<CliRequest>()?;
|
||||||
let (response_tx, response_rx) = ipc::channel::<CliResponse>()?;
|
let (response_tx, response_rx) = ipc::channel::<CliResponse>()?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue