copypasta-0.10.1/.builds/freebsd.yml000064400000000000000000000012001046102023000153740ustar 00000000000000image: freebsd/latest packages: - lang/python3 - lang/gcc - x11/libxcb - x11/libxkbcommon sources: - https://github.com/alacritty/copypasta environment: PATH: /home/build/.cargo/bin:/bin:/usr/bin:/usr/local/bin RUSTFLAGS: -L /usr/local/lib tasks: - rustup: | curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal - test: | cd copypasta cargo test - clippy: | cd copypasta rustup component add clippy cargo clippy --all-targets - oldstable: | cd copypasta rustup toolchain install --profile minimal 1.66.0 cargo +1.66.0 test copypasta-0.10.1/.builds/linux.yml000064400000000000000000000012331046102023000151270ustar 00000000000000image: archlinux packages: - libxcb - libxkbcommon sources: - https://github.com/alacritty/copypasta environment: PATH: /home/build/.cargo/bin:/usr/bin/ tasks: - rustup: | curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable --profile minimal - test: | cd copypasta cargo test - rustfmt: | cd copypasta rustup toolchain install nightly -c rustfmt cargo +nightly fmt -- --check - clippy: | cd copypasta rustup component add clippy cargo clippy --all-targets - oldstable: | cd copypasta rustup toolchain install --profile minimal 1.66.0 cargo +1.66.0 test copypasta-0.10.1/.cargo_vcs_info.json0000644000000001360000000000100131160ustar { "git": { "sha1": "a7b0b21443551f24331a6e3730380ed0beb50ab4" }, "path_in_vcs": "" }copypasta-0.10.1/.github/workflows/ci.yml000064400000000000000000000007661046102023000164320ustar 00000000000000name: CI on: [push, pull_request] env: CARGO_TERM_COLOR: always jobs: build: strategy: matrix: os: [windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - name: Stable run: cargo test - name: Clippy run: | rustup component add clippy cargo clippy --all-targets - name: Oldstable run: | rustup default 1.65.0 cargo clean cargo test copypasta-0.10.1/.gitignore000064400000000000000000000000231046102023000136710ustar 00000000000000/target Cargo.lock copypasta-0.10.1/CHANGELOG.md000064400000000000000000000025331046102023000135220ustar 00000000000000# Changelog All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## 0.10.1 ### Packaging - Minimum rust version was bumped to `1.66.0` - `x11_clipboard` was bumped to `0.9.1` ## 0.10.0 ### Changed - Use `String` in `ClipboardProvider::set_contents` for trait to be *object-safe* ## 0.9.0 - Bump minimum supported Rust version to `1.65.0` - Change `ClipboardProvider::set_contents` parameter type to `AsRef` - Prefer file's path over text on macOS ## 0.8.2 ### Packaging - Minimum rust version was bumped to `1.60.0` ### Fixed - `x11_clipboard` was bumped to `0.7.0` droping `quick-xml` from the deps tree ## 0.8.1 ### Fixed - Crash on use-after-free on macOS ## 0.8.0 ### Packaging - Minimum rust version was bumped to `1.57.0` ### Fixed - Memory leak on macOS ## 0.7.1 ### Changed - Updated `smithay-clipboard` to 0.6.0 ## 0.7.0 ### Packaging - Minimum rust version was bumped to `1.41.0` ### Removed - Ability to create a Wayland clipboard from Display type directly using `create_clipboard` ## 0.6.3 ### Added - Features `x11` and `wayland` for picking the linux backends ## 0.6.2 ### Fixed - Compilation on iOS, using the no-op clipboard copypasta-0.10.1/Cargo.lock0000644000000426270000000000100111040ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "block" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" [[package]] name = "calloop" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b50b5a44d59a98c55a9eeb518f39bf7499ba19fd98ee7d22618687f3f10adbf" dependencies = [ "bitflags 2.4.0", "log", "polling", "rustix", "slab", "thiserror", ] [[package]] name = "calloop-wayland-source" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" dependencies = [ "calloop", "rustix", "wayland-backend", "wayland-client", ] [[package]] name = "cc" version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clipboard-win" version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fdf5e01086b6be750428ba4a40619f847eb2e95756eee84b18e06e5f0b50342" dependencies = [ "lazy-bytes-cast", "winapi", ] [[package]] name = "concurrent-queue" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" dependencies = [ "crossbeam-utils", ] [[package]] name = "copypasta" version = "0.10.1" dependencies = [ "clipboard-win", "objc", "objc-foundation", "objc_id", "smithay-clipboard", "x11-clipboard", ] [[package]] name = "crossbeam-utils" version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if", ] [[package]] name = "cursor-icon" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "740bb192a8e2d1350119916954f4409ee7f62f149b536911eeb78ba5a20526bf" [[package]] name = "dlib" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ "libloading", ] [[package]] name = "downcast-rs" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "errno" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" dependencies = [ "libc", "windows-sys", ] [[package]] name = "gethostname" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818" dependencies = [ "libc", "windows-targets", ] [[package]] name = "lazy-bytes-cast" version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10257499f089cd156ad82d0a9cd57d9501fa2c989068992a97eb3c27836f206b" [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" dependencies = [ "cfg-if", "windows-sys", ] [[package]] name = "linux-raw-sys" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "malloc_buf" version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" dependencies = [ "libc", ] [[package]] name = "memchr" version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "memmap2" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "deaba38d7abf1d4cca21cc89e932e542ba2b9258664d2a9ef0e61512039c9375" dependencies = [ "libc", ] [[package]] name = "memoffset" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ "autocfg", ] [[package]] name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "nix" version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", "memoffset", ] [[package]] name = "nom" version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ "memchr", "minimal-lexical", ] [[package]] name = "objc" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" dependencies = [ "malloc_buf", ] [[package]] name = "objc-foundation" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" dependencies = [ "block", "objc", "objc_id", ] [[package]] name = "objc_id" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" dependencies = [ "objc", ] [[package]] name = "once_cell" version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "pin-project-lite" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pkg-config" version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "polling" version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62a79e457c9898100b4298d57d69ec53d06f9a6ed352431ce5f377e082d2e846" dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite", "rustix", "tracing", "windows-sys", ] [[package]] name = "proc-macro2" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] [[package]] name = "quick-xml" version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" dependencies = [ "memchr", ] [[package]] name = "quote" version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] [[package]] name = "rustix" version = "0.38.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" dependencies = [ "bitflags 2.4.0", "errno", "libc", "linux-raw-sys", "windows-sys", ] [[package]] name = "scoped-tls" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "slab" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "smithay-client-toolkit" version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60e3d9941fa3bacf7c2bf4b065304faa14164151254cd16ce1b1bc8fc381600f" dependencies = [ "bitflags 2.4.0", "calloop", "calloop-wayland-source", "cursor-icon", "libc", "log", "memmap2", "rustix", "thiserror", "wayland-backend", "wayland-client", "wayland-csd-frame", "wayland-cursor", "wayland-protocols", "wayland-protocols-wlr", "wayland-scanner", "xkeysym", ] [[package]] name = "smithay-clipboard" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb62b280ce5a5cba847669933a0948d00904cf83845c944eae96a4738cea1a6" dependencies = [ "libc", "smithay-client-toolkit", "wayland-backend", ] [[package]] name = "syn" version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "thiserror" version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tracing" version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "wayland-backend" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19152ddd73f45f024ed4534d9ca2594e0ef252c1847695255dae47f34df9fbe4" dependencies = [ "cc", "downcast-rs", "nix", "scoped-tls", "smallvec", "wayland-sys", ] [[package]] name = "wayland-client" version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca7d52347346f5473bf2f56705f360e8440873052e575e55890c4fa57843ed3" dependencies = [ "bitflags 2.4.0", "nix", "wayland-backend", "wayland-scanner", ] [[package]] name = "wayland-csd-frame" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ "bitflags 2.4.0", "cursor-icon", "wayland-backend", ] [[package]] name = "wayland-cursor" version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44aa20ae986659d6c77d64d808a046996a932aa763913864dc40c359ef7ad5b" dependencies = [ "nix", "wayland-client", "xcursor", ] [[package]] name = "wayland-protocols" version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e253d7107ba913923dc253967f35e8561a3c65f914543e46843c88ddd729e21c" dependencies = [ "bitflags 2.4.0", "wayland-backend", "wayland-client", "wayland-scanner", ] [[package]] name = "wayland-protocols-wlr" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" dependencies = [ "bitflags 2.4.0", "wayland-backend", "wayland-client", "wayland-protocols", "wayland-scanner", ] [[package]] name = "wayland-scanner" version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb8e28403665c9f9513202b7e1ed71ec56fde5c107816843fb14057910b2c09c" dependencies = [ "proc-macro2", "quick-xml", "quote", ] [[package]] name = "wayland-sys" version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" dependencies = [ "dlib", "log", "once_cell", "pkg-config", ] [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "x11-clipboard" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613c2be3e772af2bbb57c5a94413675f5ec668bac00a71ada2ced28c420ef087" dependencies = [ "libc", "x11rb", ] [[package]] name = "x11rb" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8f25ead8c7e4cba123243a6367da5d3990e0d3affa708ea19dce96356bd9f1a" dependencies = [ "gethostname", "rustix", "x11rb-protocol", ] [[package]] name = "x11rb-protocol" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e63e71c4b8bd9ffec2c963173a4dc4cbde9ee96961d4fcb4429db9929b606c34" [[package]] name = "xcursor" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7" dependencies = [ "nom", ] [[package]] name = "xkeysym" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" copypasta-0.10.1/Cargo.toml0000644000000032720000000000100111200ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.65.0" name = "copypasta" version = "0.10.1" authors = ["Christian Duerr "] exclude = ["/.travis.yml"] description = "copypasta is a cross-platform library for getting and setting the contents of the OS-level clipboard." documentation = "https://docs.rs/copypasta" readme = "README.md" keywords = ["clipboard"] license = "MIT / Apache-2.0" repository = "https://github.com/alacritty/copypasta" [features] default = [ "x11", "wayland", ] wayland = ["smithay-clipboard"] x11 = ["x11-clipboard"] [target."cfg(all(unix, not(any(target_os=\"macos\", target_os=\"android\", target_os=\"ios\", target_os=\"emscripten\"))))".dependencies.smithay-clipboard] version = "0.7.0" optional = true [target."cfg(all(unix, not(any(target_os=\"macos\", target_os=\"android\", target_os=\"ios\", target_os=\"emscripten\"))))".dependencies.x11-clipboard] version = "0.9.1" optional = true [target."cfg(target_os = \"macos\")".dependencies.objc] version = "0.2" [target."cfg(target_os = \"macos\")".dependencies.objc-foundation] version = "0.1" [target."cfg(target_os = \"macos\")".dependencies.objc_id] version = "0.1" [target."cfg(windows)".dependencies.clipboard-win] version = "3.0.2" copypasta-0.10.1/Cargo.toml.orig000064400000000000000000000017151046102023000146010ustar 00000000000000[package] name = "copypasta" version = "0.10.1" authors = ["Christian Duerr "] description = "copypasta is a cross-platform library for getting and setting the contents of the OS-level clipboard." repository = "https://github.com/alacritty/copypasta" documentation = "https://docs.rs/copypasta" readme = "README.md" license = "MIT / Apache-2.0" keywords = ["clipboard"] exclude = ["/.travis.yml"] edition = "2021" rust-version = "1.65.0" [features] default = ["x11", "wayland"] x11 = ["x11-clipboard"] wayland = ["smithay-clipboard"] [target.'cfg(windows)'.dependencies] clipboard-win = "3.0.2" [target.'cfg(target_os = "macos")'.dependencies] objc = "0.2" objc_id = "0.1" objc-foundation = "0.1" [target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="ios", target_os="emscripten"))))'.dependencies] x11-clipboard = { version = "0.9.1", optional = true } smithay-clipboard = { version = "0.7.0", optional = true } copypasta-0.10.1/LICENSE.apache2000064400000000000000000000260731046102023000142250ustar 00000000000000Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.copypasta-0.10.1/LICENSE.mit000064400000000000000000000020451046102023000135040ustar 00000000000000Copyright (c) 2017 Avraham Weinstock Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. copypasta-0.10.1/README.md000064400000000000000000000021661046102023000131720ustar 00000000000000# copypasta copypasta is a [rust-clipboard](https://github.com/aweinstock314/rust-clipboard) fork, adding support for the Wayland clipboard. rust-clipboard is a cross-platform library for getting and setting the contents of the OS-level clipboard. ## Example ```rust extern crate copypasta; use copypasta::{ClipboardContext, ClipboardProvider}; fn main() { let mut ctx = ClipboardContext::new().unwrap(); let msg = "Hello, world!"; ctx.set_contents(msg.to_owned()).unwrap(); let content = ctx.get_contents().unwrap(); println!("{}", content); } ``` ## API The `ClipboardProvider` trait has the following functions: ```rust fn get_contents(&mut self) -> Result>; fn set_contents(&mut self, String) -> Result<(), Box>; ``` `ClipboardContext` is a type alias for one of {`WindowsClipboardContext`, `OSXClipboardContext`, `X11ClipboardContext`, `NopClipboardContext`}, all of which implement `ClipboardProvider`. Which concrete type is chosen for `ClipboardContext` depends on the OS (via conditional compilation). ## License `rust-clipboard` is dual-licensed under MIT and Apache2. copypasta-0.10.1/examples/hello_world.rs000064400000000000000000000004261046102023000164060ustar 00000000000000use copypasta::{ClipboardContext, ClipboardProvider}; fn main() { let mut ctx = ClipboardContext::new().unwrap(); let msg = "Hello, world!"; ctx.set_contents(msg.to_owned()).unwrap(); let content = ctx.get_contents().unwrap(); println!("{}", content); } copypasta-0.10.1/examples/primary_selection.rs000064400000000000000000000007251046102023000176260ustar 00000000000000#[cfg(target_os = "linux")] use copypasta::x11_clipboard::{Primary, X11ClipboardContext}; #[cfg(target_os = "linux")] use copypasta::ClipboardProvider; #[cfg(target_os = "linux")] fn main() { let mut ctx = X11ClipboardContext::::new().unwrap(); let the_string = "Hello, world!"; ctx.set_contents(the_string.to_owned()).unwrap(); } #[cfg(not(target_os = "linux"))] fn main() { println!("Primary selection is only available under linux!"); } copypasta-0.10.1/rustfmt.toml000064400000000000000000000005461046102023000143140ustar 00000000000000format_code_in_doc_comments = true match_block_trailing_comma = true condense_wildcard_suffixes = true use_field_init_shorthand = true overflow_delimited_expr = true use_small_heuristics = "Max" normalize_comments = true reorder_impl_items = true use_try_shorthand = true newline_style = "Unix" format_strings = true wrap_comments = true comment_width = 100 copypasta-0.10.1/src/common.rs000064400000000000000000000020411046102023000143300ustar 00000000000000// Copyright 2016 Avraham Weinstock // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use std::error::Error; pub type Result = std::result::Result>; // TODO: come up with some platform-agnostic API for richer types /// Trait for clipboard access pub trait ClipboardProvider: Send { /// Method to get the clipboard contents as a String fn get_contents(&mut self) -> Result; /// Method to set the clipboard contents as a String fn set_contents(&mut self, _: String) -> Result<()>; } copypasta-0.10.1/src/lib.rs000064400000000000000000000041771046102023000136220ustar 00000000000000// Copyright 2016 Avraham Weinstock // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #![deny(clippy::all, clippy::if_not_else, clippy::enum_glob_use)] mod common; pub use crate::common::ClipboardProvider; #[cfg(all( unix, not(any( target_os = "macos", target_os = "android", target_os = "ios", target_os = "emscripten" )) ))] #[cfg(feature = "wayland")] pub mod wayland_clipboard; #[cfg(all( unix, not(any( target_os = "macos", target_os = "android", target_os = "ios", target_os = "emscripten" )) ))] #[cfg(feature = "x11")] pub mod x11_clipboard; #[cfg(windows)] pub mod windows_clipboard; #[cfg(target_os = "macos")] pub mod osx_clipboard; pub mod nop_clipboard; #[cfg(all( unix, not(any( target_os = "macos", target_os = "android", target_os = "ios", target_os = "emscripten" )) ))] #[cfg(feature = "x11")] pub type ClipboardContext = x11_clipboard::X11ClipboardContext; #[cfg(windows)] pub type ClipboardContext = windows_clipboard::WindowsClipboardContext; #[cfg(target_os = "macos")] pub type ClipboardContext = osx_clipboard::OSXClipboardContext; #[cfg(target_os = "android")] pub type ClipboardContext = nop_clipboard::NopClipboardContext; // TODO: implement AndroidClipboardContext #[cfg(target_os = "ios")] pub type ClipboardContext = nop_clipboard::NopClipboardContext; // TODO: implement IOSClipboardContext #[cfg(not(any( unix, windows, target_os = "macos", target_os = "android", target_os = "ios", target_os = "emscripten" )))] pub type ClipboardContext = nop_clipboard::NopClipboardContext; copypasta-0.10.1/src/nop_clipboard.rs000064400000000000000000000024541046102023000156630ustar 00000000000000// Copyright 2016 Avraham Weinstock // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use crate::common::{ClipboardProvider, Result}; pub struct NopClipboardContext; impl NopClipboardContext { pub fn new() -> Result { Ok(NopClipboardContext) } } impl ClipboardProvider for NopClipboardContext { fn get_contents(&mut self) -> Result { println!( "Attempting to get the contents of the clipboard, which hasn't yet been implemented \ on this platform." ); Ok("".to_string()) } fn set_contents(&mut self, _: String) -> Result<()> { println!( "Attempting to set the contents of the clipboard, which hasn't yet been implemented \ on this platform." ); Ok(()) } } copypasta-0.10.1/src/osx_clipboard.rs000064400000000000000000000065351046102023000157040ustar 00000000000000// Copyright 2016 Avraham Weinstock // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use objc::rc::autoreleasepool; use objc::runtime::{Class, Object, BOOL, NO, YES}; use objc::{class, msg_send, sel, sel_impl}; use objc_foundation::{INSArray, INSString}; use objc_foundation::{NSArray, NSString}; use objc_id::Id; use crate::common::*; pub struct OSXClipboardContext { pasteboard: Id, } // required to bring NSPasteboard into the path of the class-resolver #[link(name = "AppKit", kind = "framework")] extern "C" { pub static NSPasteboardTypeFileURL: *mut Object; pub static NSPasteboardTypeString: *mut Object; } impl OSXClipboardContext { pub fn new() -> Result { let cls = Class::get("NSPasteboard").ok_or("Class::get(\"NSPasteboard\")")?; let pasteboard: *mut Object = unsafe { msg_send![cls, generalPasteboard] }; if pasteboard.is_null() { return Err("NSPasteboard#generalPasteboard returned null".into()); } let pasteboard: Id = unsafe { Id::from_ptr(pasteboard) }; Ok(OSXClipboardContext { pasteboard }) } } impl ClipboardProvider for OSXClipboardContext { fn get_contents(&mut self) -> Result { autoreleasepool(|| unsafe { let types: *mut NSArray<*mut NSString> = msg_send![self.pasteboard, types]; let has_file: BOOL = msg_send![types, containsObject: NSPasteboardTypeFileURL]; let has_str: BOOL = msg_send![types, containsObject: NSPasteboardTypeString]; if has_str == NO { return Err("NSPasteboard#types doesn't contain NSPasteboardTypeString".into()); } let text = if has_file == YES { let file_url_string: *mut NSString = msg_send![self.pasteboard, stringForType: NSPasteboardTypeFileURL]; let file_url: *mut Object = msg_send![class!(NSURL), URLWithString: file_url_string]; let text: *mut NSString = msg_send![file_url, path]; text } else { let text: *mut NSString = msg_send![self.pasteboard, stringForType: NSPasteboardTypeString]; text }; if text.is_null() { return Err(("NSPasteboard#stringForType returned null").into()); } Ok((*text).as_str().to_owned()) }) } fn set_contents(&mut self, data: String) -> Result<()> { let string_array = NSArray::from_vec(vec![NSString::from_str(&data)]); let _: usize = unsafe { msg_send![self.pasteboard, clearContents] }; let success: bool = unsafe { msg_send![self.pasteboard, writeObjects: string_array] }; if success { Ok(()) } else { Err("NSPasteboard#writeObjects: returned false".into()) } } } copypasta-0.10.1/src/wayland_clipboard.rs000064400000000000000000000036111046102023000165220ustar 00000000000000// Copyright 2017 Avraham Weinstock // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use std::ffi::c_void; use std::sync::{Arc, Mutex}; use smithay_clipboard::Clipboard as WaylandClipboard; use crate::common::{ClipboardProvider, Result}; pub struct Clipboard { context: Arc>, } pub struct Primary { context: Arc>, } /// Create new clipboard from a raw display pointer. /// /// # Safety /// /// Since the type of the display is a raw pointer, it's the responsibility of the callee to make /// sure that the passed pointer is a valid Wayland display. pub unsafe fn create_clipboards_from_external(display: *mut c_void) -> (Primary, Clipboard) { let context = Arc::new(Mutex::new(WaylandClipboard::new(display))); (Primary { context: context.clone() }, Clipboard { context }) } impl ClipboardProvider for Clipboard { fn get_contents(&mut self) -> Result { Ok(self.context.lock().unwrap().load()?) } fn set_contents(&mut self, data: String) -> Result<()> { self.context.lock().unwrap().store(data); Ok(()) } } impl ClipboardProvider for Primary { fn get_contents(&mut self) -> Result { Ok(self.context.lock().unwrap().load_primary()?) } fn set_contents(&mut self, data: String) -> Result<()> { self.context.lock().unwrap().store_primary(data); Ok(()) } } copypasta-0.10.1/src/windows_clipboard.rs000064400000000000000000000021271046102023000165560ustar 00000000000000// Copyright 2016 Avraham Weinstock // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use clipboard_win::{get_clipboard_string, set_clipboard_string}; use crate::common::{ClipboardProvider, Result}; pub struct WindowsClipboardContext; impl WindowsClipboardContext { pub fn new() -> Result { Ok(WindowsClipboardContext) } } impl ClipboardProvider for WindowsClipboardContext { fn get_contents(&mut self) -> Result { Ok(get_clipboard_string()?) } fn set_contents(&mut self, data: String) -> Result<()> { Ok(set_clipboard_string(&data)?) } } copypasta-0.10.1/src/x11_clipboard.rs000064400000000000000000000035171046102023000155010ustar 00000000000000// Copyright 2017 Avraham Weinstock // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use std::marker::PhantomData; use std::time::Duration; use x11_clipboard::Atom; use x11_clipboard::{Atoms, Clipboard as X11Clipboard}; use crate::common::*; pub trait Selection: Send { fn atom(atoms: &Atoms) -> Atom; } pub struct Primary; impl Selection for Primary { fn atom(atoms: &Atoms) -> Atom { atoms.primary } } pub struct Clipboard; impl Selection for Clipboard { fn atom(atoms: &Atoms) -> Atom { atoms.clipboard } } pub struct X11ClipboardContext(X11Clipboard, PhantomData) where S: Selection; impl X11ClipboardContext where S: Selection, { pub fn new() -> Result> { Ok(X11ClipboardContext(X11Clipboard::new()?, PhantomData)) } } impl ClipboardProvider for X11ClipboardContext where S: Selection, { fn get_contents(&mut self) -> Result { Ok(String::from_utf8(self.0.load( S::atom(&self.0.getter.atoms), self.0.getter.atoms.utf8_string, self.0.getter.atoms.property, Duration::from_secs(3), )?)?) } fn set_contents(&mut self, data: String) -> Result<()> { Ok(self.0.store(S::atom(&self.0.setter.atoms), self.0.setter.atoms.utf8_string, data)?) } }