diff --git a/Cargo.lock b/Cargo.lock index 634ef452a369b142c983302bcb471c00395e1a19..e12e49184d914a49f057d8d8c6ffc039c883b5c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -750,6 +750,21 @@ dependencies = [ "winx", ] +[[package]] +name = "capture" +version = "0.1.0" +dependencies = [ + "block", + "cocoa", + "core-foundation", + "core-graphics", + "foreign-types", + "gpui", + "log", + "objc", + "simplelog", +] + [[package]] name = "castaway" version = "0.1.2" diff --git a/crates/capture/Cargo.toml b/crates/capture/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..4dc975353fc4e12106f0ba284b4fbf5dc6f74e0a --- /dev/null +++ b/crates/capture/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "capture" +version = "0.1.0" +edition = "2021" +description = "An example of screen capture" + +[package.metadata.bundle] +name = "Capture" +identifier = "dev.zed.Capture" + +[dependencies] +gpui = { path = "../gpui" } + +block = "0.1" +cocoa = "0.24" +core-foundation = "0.9.3" +core-graphics = "0.22.3" +foreign-types = "0.3" +log = { version = "0.4.16", features = ["kv_unstable_serde"] } +objc = "0.2" +simplelog = "0.9" diff --git a/crates/capture/build.rs b/crates/capture/build.rs new file mode 100644 index 0000000000000000000000000000000000000000..5aa9032376979b9fbaf773a6b31cff089c964e8c --- /dev/null +++ b/crates/capture/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rustc-link-lib=framework=ScreenCaptureKit"); +} diff --git a/crates/capture/script/capture b/crates/capture/script/capture new file mode 100755 index 0000000000000000000000000000000000000000..0e6cf1f409ad0f2aa0eae0a6aefc86c2fe203416 --- /dev/null +++ b/crates/capture/script/capture @@ -0,0 +1,5 @@ +#!/bin/bash + +cargo bundle +TTY=`tty` +open ../../target/debug/bundle/osx/Capture.app --stdout $TTY --stderr $TTY diff --git a/crates/gpui/examples/capture.rs b/crates/capture/src/main.rs similarity index 88% rename from crates/gpui/examples/capture.rs rename to crates/capture/src/main.rs index 27bb843ab983790cfb2e008b730a5be281043526..6bad5bb7f3f33f494f7517f6df4d9256375d0144 100644 --- a/crates/gpui/examples/capture.rs +++ b/crates/capture/src/main.rs @@ -33,10 +33,12 @@ fn main() { unsafe { let block = ConcreteBlock::new(move |content: id, error: id| { - println!("got response with shareable content"); - dbg!(content); - dbg!(error); - dbg!(string_from_objc(msg_send![error, localizedDescription])); + println!( + "got response with shareable content {:?} {:?} {:?}", + content, + error, + string_from_objc(msg_send![error, localizedDescription]), + ) }); let _: id = msg_send![ diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 255e85a5272c1fae46e4bc81f7e0e169ff065bd1..08c32135fb5170644033232e20ae9859128e81b2 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -12,11 +12,6 @@ doctest = false [features] test-support = ["backtrace", "dhat", "env_logger", "collections/test-support"] -[package.metadata.bundle.example.capture] -name = "Capture" -identifier = "rs.gpui.examples.Capture" -description = "An example of screen capture" - [dependencies] collections = { path = "../collections" } gpui_macros = { path = "../gpui_macros" } diff --git a/crates/gpui/build.rs b/crates/gpui/build.rs index 1c6cc11de0057bf9d12d40bb4f900e2843e493ee..836d586c26bea742d7b31832d0b17b64d0295a05 100644 --- a/crates/gpui/build.rs +++ b/crates/gpui/build.rs @@ -9,9 +9,6 @@ fn main() { compile_context_predicate_parser(); compile_metal_shaders(); generate_shader_bindings(); - - // Support screen capture - println!("cargo:rustc-link-lib=framework=ScreenCaptureKit"); } fn generate_dispatch_bindings() { diff --git a/crates/gpui/script/capture b/crates/gpui/script/capture deleted file mode 100755 index 753e5108e7f91093686c0b0e481b9b5380dcec4e..0000000000000000000000000000000000000000 --- a/crates/gpui/script/capture +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -cargo bundle --example capture -open ../../target/debug/examples/bundle/osx/Capture.app