Crates.io | copypasta-ext |
lib.rs | copypasta-ext |
version | 0.4.4 |
source | src |
created_at | 2020-05-28 17:20:29.703448 |
updated_at | 2023-02-23 09:00:02.302381 |
description | A clipboard library providing useful extensions for copypasta. |
homepage | |
repository | https://gitlab.com/timvisee/copypasta-ext |
max_upload_size | |
id | 247099 |
size | 65,846 |
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 exits 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:
X11ForkClipboardProvider
:
forks process and sets clipboard, keeps contents after exitX11BinClipboardProvider
:
invokes xclip
/xsel
to set clipboard, keeps contents after exitOsc52ClipboardContext
:
use OSC 52 escape sequence to set clipboard contentsCombinedClipboardProvider
:
combine two providers, use different for getting/setting clipboardTo guess at runtime what clipboard provider is best used see the DisplayServer
class.
Enable all desired compiler feature flags for clipboard systems to support, and
use DisplayServer::select().try_context()
to obtain a clipboard context.
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
.
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();
}
copypasta
rust-clipboard
and copypasta
This project is dual-licensed under the MIT and Apache2 license.