mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Handle get_clipboard_contents and set_clipboard_contents in libsimpleservo capi
This commit is contained in:
parent
caaa2a425c
commit
02d55885c8
1 changed files with 13 additions and 2 deletions
|
@ -351,10 +351,21 @@ impl HostTrait for HostCallbacks {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_clipboard_contents(&self) -> Option<String> {
|
fn get_clipboard_contents(&self) -> Option<String> {
|
||||||
unimplemented!()
|
debug!("get_clipboard_contents");
|
||||||
|
let raw_contents = (self.0.get_clipboard_contents)();
|
||||||
|
if raw_contents.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let c_str = unsafe { CStr::from_ptr(raw_contents) };
|
||||||
|
let contents_str = c_str.to_str().expect("Can't create str");
|
||||||
|
Some(contents_str.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_clipboard_contents(&self, contents: String) {
|
fn set_clipboard_contents(&self, contents: String) {
|
||||||
unimplemented!()
|
debug!("set_clipboard_contents");
|
||||||
|
let contents = CString::new(contents).expect("Can't create string");
|
||||||
|
let contents_ptr = contents.as_ptr();
|
||||||
|
mem::forget(contents);
|
||||||
|
(self.0.set_clipboard_contents)(contents_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue