#clipboard

copypasta-ext

A clipboard library providing useful extensions for copypasta

5 releases

new 0.3.4 Feb 23, 2021
0.3.3 Feb 23, 2021
0.3.2 Oct 13, 2020
0.3.1 Oct 11, 2020
0.3.0 May 28, 2020

#7 in #clipboard

Download history 676/week @ 2020-11-07 72/week @ 2020-11-14 66/week @ 2020-11-21 61/week @ 2020-11-28 91/week @ 2020-12-05 110/week @ 2020-12-12 110/week @ 2020-12-19 76/week @ 2020-12-26 73/week @ 2021-01-02 363/week @ 2021-01-09 91/week @ 2021-01-16 76/week @ 2021-01-23 715/week @ 2021-01-30 95/week @ 2021-02-06 185/week @ 2021-02-13 180/week @ 2021-02-20

727 downloads per month
Used in 3 crates

MIT/Apache

43KB
552 lines

Build status on GitLab CI Newest release on crates.io Documentation Number of downloads on crates.io Project license

copypasta-ext

A clipboard library providing useful extensions for the copypasta library.

I had a growing annoyance with copypasta, because the clipboard is cleared on the Linux/X11 platform when your application exists as per X11 design. The crate maintainer didn't want to implement workarounds (for valid reasons). This copypasta-ext crate provides additional clipboard contexts that solve this, along with a few other additions.

Here are some of these additions:

This crate should work with the latest copypasta. Feel free to open an issue or pull request otherwise. The copypasta crate is exposed as copypasta_ext::copypasta.

Example

Get and set clipboard contents. Keeps contents in X11 clipboard after exit by forking the process. 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;

fn main() {
    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;

fn main() {
    let mut ctx = ClipboardContext::new().unwrap();
    println!("{:?}", ctx.get_contents());
    ctx.set_contents("some string".into()).unwrap();
}

Requirements

  • Rust 1.41 or above
  • Same requirements as copypasta
  • Requirements noted in specific clipboard context modules

Special thanks

  • to the maintainers/contributors of rust-clipboard and copypasta
  • to everyone involved in all crate dependencies used

License

This project is dual-licensed under the MIT and Apache2 license.

Dependencies

~16–300KB