pub struct Clipboard {
pub getter: Context,
pub setter: Arc<Context>,
/* private fields */
}
Expand description
X11 Clipboard
Fields§
§getter: Context
§setter: Arc<Context>
Implementations§
Source§impl Clipboard
impl Clipboard
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Create Clipboard.
Examples found in repository?
examples/paste.rs (line 8)
7fn main() {
8 let clipboard = Clipboard::new().unwrap();
9 let val =
10 clipboard.load(
11 clipboard.setter.atoms.clipboard,
12 clipboard.setter.atoms.utf8_string,
13 clipboard.setter.atoms.property,
14 Duration::from_secs(3)
15 )
16 .unwrap();
17 let val = String::from_utf8(val).unwrap();
18
19 print!("{}", val);
20}
More examples
examples/wait_copy_event.rs (line 6)
5fn main() {
6 let clipboard = Clipboard::new().unwrap();
7
8 loop {
9 let val = clipboard
10 .load_wait(
11 clipboard.setter.atoms.clipboard,
12 clipboard.setter.atoms.string,
13 clipboard.setter.atoms.property,
14 )
15 .unwrap();
16
17 let val = String::from_utf8(val).unwrap();
18
19 println!("{}", val);
20 }
21}
examples/monitor_primary_selection.rs (line 7)
6fn main() {
7 let clipboard = Clipboard::new().unwrap();
8 let mut last = String::new();
9
10 println!("Waiting for selection...");
11
12 loop {
13 if let Ok(curr) = clipboard.load_wait(
14 clipboard.getter.atoms.primary,
15 clipboard.getter.atoms.utf8_string,
16 clipboard.getter.atoms.property
17 ) {
18 let curr = String::from_utf8_lossy(&curr);
19 let curr = curr
20 .trim_matches('\u{0}')
21 .trim();
22 if !curr.is_empty() && last != curr {
23 last = curr.to_owned();
24 println!("Contents of primary selection: {}", last);
25 println!("Waiting for selection...");
26 }
27 }
28 }
29}
Sourcepub fn load<T>(
&self,
selection: Atom,
target: Atom,
property: Atom,
timeout: T,
) -> Result<Vec<u8>, Error>
pub fn load<T>( &self, selection: Atom, target: Atom, property: Atom, timeout: T, ) -> Result<Vec<u8>, Error>
load value.
Examples found in repository?
examples/paste.rs (lines 10-15)
7fn main() {
8 let clipboard = Clipboard::new().unwrap();
9 let val =
10 clipboard.load(
11 clipboard.setter.atoms.clipboard,
12 clipboard.setter.atoms.utf8_string,
13 clipboard.setter.atoms.property,
14 Duration::from_secs(3)
15 )
16 .unwrap();
17 let val = String::from_utf8(val).unwrap();
18
19 print!("{}", val);
20}
Sourcepub fn load_wait(
&self,
selection: Atom,
target: Atom,
property: Atom,
) -> Result<Vec<u8>, Error>
pub fn load_wait( &self, selection: Atom, target: Atom, property: Atom, ) -> Result<Vec<u8>, Error>
wait for a new value and load it
Examples found in repository?
examples/wait_copy_event.rs (lines 10-14)
5fn main() {
6 let clipboard = Clipboard::new().unwrap();
7
8 loop {
9 let val = clipboard
10 .load_wait(
11 clipboard.setter.atoms.clipboard,
12 clipboard.setter.atoms.string,
13 clipboard.setter.atoms.property,
14 )
15 .unwrap();
16
17 let val = String::from_utf8(val).unwrap();
18
19 println!("{}", val);
20 }
21}
More examples
examples/monitor_primary_selection.rs (lines 13-17)
6fn main() {
7 let clipboard = Clipboard::new().unwrap();
8 let mut last = String::new();
9
10 println!("Waiting for selection...");
11
12 loop {
13 if let Ok(curr) = clipboard.load_wait(
14 clipboard.getter.atoms.primary,
15 clipboard.getter.atoms.utf8_string,
16 clipboard.getter.atoms.property
17 ) {
18 let curr = String::from_utf8_lossy(&curr);
19 let curr = curr
20 .trim_matches('\u{0}')
21 .trim();
22 if !curr.is_empty() && last != curr {
23 last = curr.to_owned();
24 println!("Contents of primary selection: {}", last);
25 println!("Waiting for selection...");
26 }
27 }
28 }
29}
Auto Trait Implementations§
impl !Freeze for Clipboard
impl RefUnwindSafe for Clipboard
impl Send for Clipboard
impl Sync for Clipboard
impl Unpin for Clipboard
impl UnwindSafe for Clipboard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more