diff --git a/CHANGELOG.md b/CHANGELOG.md index edaa029..66877bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## v0.2.1 (2024-08-26) [released] + +### zh: + +- 增加 X11 启动参数,自定义读取的超时时间 [issues#45](https://github.com/ChurchTao/clipboard-rs/issues/45) + +### en: + +- Add X11 startup parameters to customize the timeout for reading [issues#45](https://github.com/ChurchTao/clipboard-rs/issues/45) + ## v0.2.0 (2024-08-25) [released] ### zh: diff --git a/Cargo.toml b/Cargo.toml index 7d3d31f..a2d292c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clipboard-rs" -version = "0.2.0" +version = "0.2.1" authors = ["ChurchTao "] description = "Cross-platform clipboard API (text | image | rich text | html | files | monitoring changes) | 跨平台剪贴板 API(文本|图片|富文本|html|文件|监听变化) Windows,MacOS,Linux" repository = "https://github.com/ChurchTao/clipboard-rs" diff --git a/README.md b/README.md index e87cc3d..481de7e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Add the following content to your `Cargo.toml`: ```toml [dependencies] -clipboard-rs = "0.2.0" +clipboard-rs = "0.2.1" ``` ## [CHANGELOG](CHANGELOG.md) @@ -175,7 +175,7 @@ fn main() { ## X11 - Clipboard Read Timeout -By default, in X11 clipboard-rs implements a read timeout of 500 ms. You can override or disable this timeout by creating **ClipboardContext** using `new_with_options`: +By default, in X11 clipboard-rs implements a read timeout of 500 ms. You can override or disable this timeout by creating **ClipboardContext** using `new_with_options`: ```rust #[cfg(unix)] diff --git a/README_ZH.md b/README_ZH.md index c1da22d..5274916 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -23,7 +23,7 @@ clipboard-rs 是一个用 Rust 语言编写的跨平台库,用于获取和设 ```toml [dependencies] -clipboard-rs = "0.2.0" +clipboard-rs = "0.2.1" ``` ## [更新日志](CHANGELOG.md) @@ -166,6 +166,22 @@ fn main() { ``` +## X11 - 读取超时设定 + +默认读取超时时间为 500ms,但是遇到大图片,等数据流比较大的东西时,有可能就读取中断失败了。你可以通过 **ClipboardContext** `new_with_options` 重设超时时间: + +```rust +#[cfg(unix)] +fn setup_clipboard() -> ClipboardContext { + ClipboardContext::new_with_options(ClipboardContextX11Options { read_timeout: None }).unwrap() +} + +#[cfg(not(unix))] +fn setup_clipboard(ctx: &mut ClipboardContext) -> ClipboardContext{ + ClipboardContext::new().unwrap() +} +``` + ## 贡献 欢迎提交 PR 和 issue,为项目贡献你的代码或者想法。由于本人水平有限,库也可能会有 bug,欢迎大家指出,我会第一时间修改。