mirror of
https://github.com/nushell/reedline.git
synced 2024-09-11 15:55:50 +03:00
Replace clipboard with arboard, which is actively maintained (#705)
This commit is contained in:
parent
ef7b96c157
commit
dc27ed8ff4
815
Cargo.lock
generated
815
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -13,11 +13,11 @@ version = "0.28.0"
|
||||
doctest = true
|
||||
|
||||
[dependencies]
|
||||
arboard = { version = "3.3.0", optional = true, default-features = false, features = ["wayland-data-control"] }
|
||||
chrono = { version = "0.4.19", default-features = false, features = [
|
||||
"clock",
|
||||
"serde",
|
||||
] }
|
||||
clipboard = { version = "0.5.0", optional = true }
|
||||
crossbeam = { version = "0.8.2", optional = true }
|
||||
crossterm = { version = "0.27.0", features = ["serde"] }
|
||||
fd-lock = "3.0.3"
|
||||
@ -44,7 +44,7 @@ bashisms = []
|
||||
external_printer = ["crossbeam"]
|
||||
sqlite = ["rusqlite/bundled", "serde_json"]
|
||||
sqlite-dynlib = ["rusqlite", "serde_json"]
|
||||
system_clipboard = ["clipboard"]
|
||||
system_clipboard = ["arboard"]
|
||||
|
||||
[[example]]
|
||||
name = "cwd_aware_hinter"
|
||||
|
@ -76,20 +76,20 @@ pub fn get_default_clipboard() -> LocalClipboard {
|
||||
#[cfg(feature = "system_clipboard")]
|
||||
mod system_clipboard {
|
||||
use super::*;
|
||||
use clipboard::{ClipboardContext, ClipboardProvider};
|
||||
use arboard::Clipboard as Arboard;
|
||||
|
||||
/// Wrapper around [`clipboard`](https://docs.rs/clipboard) crate
|
||||
///
|
||||
/// Requires that the feature `system_clipboard` is enabled
|
||||
pub struct SystemClipboard {
|
||||
cb: ClipboardContext,
|
||||
cb: Arboard,
|
||||
local_copy: String,
|
||||
mode: ClipboardMode,
|
||||
}
|
||||
|
||||
impl SystemClipboard {
|
||||
pub fn new() -> Self {
|
||||
let cb = ClipboardProvider::new().unwrap();
|
||||
let cb = Arboard::new().unwrap();
|
||||
SystemClipboard {
|
||||
cb,
|
||||
local_copy: String::new(),
|
||||
@ -101,12 +101,12 @@ mod system_clipboard {
|
||||
impl Clipboard for SystemClipboard {
|
||||
fn set(&mut self, content: &str, mode: ClipboardMode) {
|
||||
self.local_copy = content.to_owned();
|
||||
let _ = self.cb.set_contents(content.to_owned());
|
||||
let _ = self.cb.set_text(content);
|
||||
self.mode = mode;
|
||||
}
|
||||
|
||||
fn get(&mut self) -> (String, ClipboardMode) {
|
||||
let system_content = self.cb.get_contents().unwrap_or_default();
|
||||
let system_content = self.cb.get_text().unwrap_or_default();
|
||||
if system_content == self.local_copy {
|
||||
// We assume the content was yanked inside the line editor and the last yank determined the mode.
|
||||
(system_content, self.mode)
|
||||
|
Loading…
Reference in New Issue
Block a user