Skip to content

Commit

Permalink
Merge pull request #40 from ChurchTao/feature/macos
Browse files Browse the repository at this point in the history
macOS替换为objc2
  • Loading branch information
ChurchTao authored Aug 18, 2024
2 parents e004724 + 0b4e9d7 commit ed0b1da
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 392 deletions.
14 changes: 13 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ image = "0.25.2"
clipboard-win = { version = "5.4.0", features = ["monitor"] }

[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.25.0"
# cocoa = "0.26.0"
objc2 = { version = "0.5.2" }
objc2-foundation = { version = "0.2.2", features = [
"NSArray",
"NSString",
"NSEnumerator",
] }
objc2-app-kit = { version = "0.2.2", features = [
"NSPasteboard",
"NSPasteboardItem",
"NSImage",
] }


[target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="ios", target_os="emscripten"))))'.dependencies]
x11rb = { version = "0.13.0", features = ["xfixes"] }
2 changes: 1 addition & 1 deletion examples/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ fn main() {
let has = ctx.has(ContentFormat::Files);
println!("has_files={}", has);

let files = ctx.get_files().unwrap_or(vec![]);
let files = ctx.get_files().unwrap_or_default();
println!("{:?}", files);
}
5 changes: 3 additions & 2 deletions examples/watch_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl ClipboardHandler for Manager {
fn on_clipboard_change(&mut self) {
println!(
"on_clipboard_change, txt = {}",
self.ctx.get_text().unwrap()
self.ctx.get_text().unwrap_or("".to_string())
);
}
}
Expand All @@ -28,7 +28,8 @@ fn main() {

let mut watcher = ClipboardWatcherContext::new().unwrap();

let watcher_shutdown = watcher.add_handler(manager).get_shutdown_channel();
let watcher_shutdown: clipboard_rs::WatcherShutdown =
watcher.add_handler(manager).get_shutdown_channel();

thread::spawn(move || {
thread::sleep(Duration::from_secs(5));
Expand Down
Loading

0 comments on commit ed0b1da

Please sign in to comment.