mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 13:52:55 +03:00
window: fixup clipboard on macos
This commit is contained in:
parent
2b795aa08d
commit
c03eda1279
@ -57,6 +57,7 @@ memmap = {version="0.7", optional=true}
|
||||
[target.'cfg(target_os="macos")'.dependencies]
|
||||
cocoa = "0.20"
|
||||
objc = "0.2"
|
||||
clipboard = "0.5"
|
||||
core-foundation = "0.7"
|
||||
core-graphics = "0.19"
|
||||
cgl = { version = "0.3", optional = true }
|
||||
|
@ -222,14 +222,10 @@ pub trait WindowOps {
|
||||
R: Send + 'static;
|
||||
|
||||
/// Initiate textual transfer from the clipboard
|
||||
fn get_clipboard(&self) -> Future<String> {
|
||||
Future::err(failure::err_msg("no clip"))
|
||||
}
|
||||
fn get_clipboard(&self) -> Future<String>;
|
||||
|
||||
/// Set some text in the clipboard
|
||||
fn set_clipboard(&self, _text: String) -> Future<()> {
|
||||
Future::err(failure::err_msg("no clip"))
|
||||
}
|
||||
fn set_clipboard(&self, text: String) -> Future<()>;
|
||||
}
|
||||
|
||||
pub trait WindowOpsMut {
|
||||
|
@ -463,6 +463,24 @@ impl WindowOps for Window {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn get_clipboard(&self) -> Future<String> {
|
||||
use clipboard::ClipboardProvider;
|
||||
Future::result(
|
||||
clipboard::ClipboardContext::new()
|
||||
.and_then(|mut ctx| ctx.get_contents())
|
||||
.map_err(|e| failure::format_err!("Failed to get clipboard: {}", e)),
|
||||
)
|
||||
}
|
||||
|
||||
fn set_clipboard(&self, text: String) -> Future<()> {
|
||||
use clipboard::ClipboardProvider;
|
||||
Future::result(
|
||||
clipboard::ClipboardContext::new()
|
||||
.and_then(|mut ctx| ctx.set_contents(text))
|
||||
.map_err(|e| failure::format_err!("Failed to set clipboard: {}", e)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert from a macOS screen coordinate with the origin in the bottom left
|
||||
|
Loading…
Reference in New Issue
Block a user