Merge branch 'master' into menus
This commit is contained in:
@@ -2,12 +2,12 @@ use super::{BoolExt as _, Dispatcher, FontSystem, Window};
|
||||
use crate::{executor, platform};
|
||||
use anyhow::Result;
|
||||
use cocoa::{
|
||||
appkit::{NSApplication, NSOpenPanel, NSModalResponse},
|
||||
appkit::{NSApplication, NSModalResponse, NSOpenPanel, NSPasteboard, NSPasteboardTypeString},
|
||||
base::nil,
|
||||
foundation::{NSArray, NSString, NSURL},
|
||||
foundation::{NSArray, NSData, NSString, NSURL},
|
||||
};
|
||||
use objc::{msg_send, sel, sel_impl};
|
||||
use std::{path::PathBuf, rc::Rc, sync::Arc};
|
||||
use std::{ffi::c_void, path::PathBuf, rc::Rc, sync::Arc};
|
||||
|
||||
pub struct App {
|
||||
dispatcher: Arc<Dispatcher>,
|
||||
@@ -84,4 +84,17 @@ impl platform::App for App {
|
||||
let _: () = msg_send![app, terminate: nil];
|
||||
}
|
||||
}
|
||||
|
||||
fn copy(&self, text: &str) {
|
||||
unsafe {
|
||||
let data = NSData::dataWithBytes_length_(
|
||||
nil,
|
||||
text.as_ptr() as *const c_void,
|
||||
text.len() as u64,
|
||||
);
|
||||
let pasteboard = NSPasteboard::generalPasteboard(nil);
|
||||
pasteboard.clearContents();
|
||||
pasteboard.setData_forType(data, NSPasteboardTypeString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ pub trait App {
|
||||
fn prompt_for_paths(&self, options: PathPromptOptions) -> Option<Vec<PathBuf>>;
|
||||
fn fonts(&self) -> Arc<dyn FontSystem>;
|
||||
fn quit(&self);
|
||||
fn copy(&self, text: &str);
|
||||
}
|
||||
|
||||
pub trait Dispatcher: Send + Sync {
|
||||
|
||||
@@ -52,6 +52,8 @@ impl super::App for App {
|
||||
fn prompt_for_paths(&self, _: super::PathPromptOptions) -> Option<Vec<std::path::PathBuf>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn copy(&self, _: &str) {}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
||||
Reference in New Issue
Block a user