Crate copypasta_ext

Source
Expand description

A clipboard library providing useful extensions for the copypasta library.

Here are some of these additions:

§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-paste to access clipboard.
x11_bin
Invokes xclip/xsel to access clipboard.
x11_fork
Like x11_clipboard, but forks to set contents.

Structs§

CombinedClipboardContext
Combined, use different clipboard context for getting & setting.

Traits§

ClipboardProviderExt
Extension trait for clipboard access

Functions§

try_context
Try to get clipboard context.

Type Aliases§

ClipResult
Copypasta result type, for your convenience.