Expand description
A clipboard library providing useful extensions for the
copypasta library.
Here are some of these additions:
X11ForkClipboardProvider: forks process and sets clipboard on X11, keeps contents after exitX11BinClipboardProvider: invokesxclip/xselto set clipboard on X11, keeps contents after exitWaylandBinClipboardProvider: invokeswl-copy/wl-pasteto set clipboard on WaylandOsc52ClipboardContext: use OSC 52 escape sequence to set clipboard contentsCombinedClipboardProvider: combine two providers, use different for getting/setting clipboard
§Example
Get and set clipboard contents. Tries to select the correct clipboard context at runtime using
try_context. Useful if you just want quick access to the clipboard, and if you don’t want to
implement any clipboard context selecting logic yourself.
let mut ctx = copypasta_ext::try_context().expect("failed to get clipboard context");
println!("{:?}", ctx.get_contents());
ctx.set_contents("some string".into()).unwrap();Get and set clipboard contents. Keeps contents in X11 clipboard after exit by forking the
process (which normally doesn’t work with copypasta’s X11ClipboardContext). Falls back to
standard clipboard provider on non X11 platforms. See
x11_fork module for
details.
use copypasta_ext::prelude::*;
use copypasta_ext::x11_fork::ClipboardContext;
let mut ctx = ClipboardContext::new().unwrap();
println!("{:?}", ctx.get_contents());
ctx.set_contents("some string".into()).unwrap();Get and set clipboard contents. Keeps contents in X11 clipboard after exit by
invoking xclip/xsel. Falls back to standard clipboard provider on non X11
platforms. See x11_bin
module for details.
use copypasta_ext::prelude::*;
use copypasta_ext::x11_bin::ClipboardContext;
let mut ctx = ClipboardContext::new().unwrap();
println!("{:?}", ctx.get_contents());
ctx.set_contents("some string".into()).unwrap();§Requirements
- Rust 1.47 or above
- Same requirements as
copypasta - Requirements noted in specific clipboard context modules
Re-exports§
pub use copypasta;
Modules§
- display
- Display server management.
- osc52
- OSC 52 escape sequence to set clipboard contents.
- prelude
- Trait prelude.
- wayland_
bin - Invokes
wl-copy/wl-pasteto access clipboard. - x11_bin
- Invokes
xclip/xselto access clipboard. - x11_
fork - Like
x11_clipboard, but forks to set contents.
Structs§
- Combined
Clipboard Context - Combined, use different clipboard context for getting & setting.
Traits§
- Clipboard
Provider Ext - Extension trait for clipboard access
Functions§
- try_
context - Try to get clipboard context.
Type Aliases§
- Clip
Result - Copypasta result type, for your convenience.