aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-03-03 07:48:51 +0000
committerBlaž Hrastnik2022-03-03 07:52:41 +0000
commitadf97e088e38c12eb6c363f674aab5dca1962bbe (patch)
tree94f344fa9dad4f27ee2f3f2ad871ac34da68b01b
parent68bad148a58cb580333cc545376b7bc6c2c5abd4 (diff)
Simplify get_clipboard_provider by defining one per host
-rw-r--r--helix-view/src/clipboard.rs41
1 files changed, 17 insertions, 24 deletions
diff --git a/helix-view/src/clipboard.rs b/helix-view/src/clipboard.rs
index a492652d..63e2272c 100644
--- a/helix-view/src/clipboard.rs
+++ b/helix-view/src/clipboard.rs
@@ -56,16 +56,29 @@ macro_rules! command_provider {
}};
}
+#[cfg(windows)]
pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
- // TODO: support for user-defined provider, probably when we have plugin support by setting a
- // variable?
+ Box::new(provider::WindowsProvider::default())
+}
+#[cfg(target_os = "macos")]
+pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
if exists("pbcopy") && exists("pbpaste") {
command_provider! {
paste => "pbpaste";
copy => "pbcopy";
}
- } else if env_var_is_set("WAYLAND_DISPLAY") && exists("wl-copy") && exists("wl-paste") {
+ } else {
+ Box::new(provider::NopProvider::new())
+ }
+}
+
+#[cfg(not(any(windows, target_os = "macos")))]
+pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
+ // TODO: support for user-defined provider, probably when we have plugin support by setting a
+ // variable?
+
+ if env_var_is_set("WAYLAND_DISPLAY") && exists("wl-copy") && exists("wl-paste") {
command_provider! {
paste => "wl-paste", "--no-newline";
copy => "wl-copy", "--type", "text/plain";
@@ -88,22 +101,6 @@ pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
primary_paste => "xsel", "-o";
primary_copy => "xsel", "-i";
}
- } else if exists("lemonade") {
- command_provider! {
- paste => "lemonade", "paste";
- copy => "lemonade", "copy";
- }
- } else if exists("doitclient") {
- command_provider! {
- paste => "doitclient", "wclip", "-r";
- copy => "doitclient", "wclip";
- }
- } else if exists("win32yank.exe") {
- // FIXME: does it work within WSL?
- command_provider! {
- paste => "win32yank.exe", "-o", "--lf";
- copy => "win32yank.exe", "-i", "--crlf";
- }
} else if exists("termux-clipboard-set") && exists("termux-clipboard-get") {
command_provider! {
paste => "termux-clipboard-get";
@@ -115,11 +112,7 @@ pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> {
copy => "tmux", "load-buffer", "-";
}
} else {
- #[cfg(target_os = "windows")]
- return Box::new(provider::WindowsProvider::default());
-
- #[cfg(not(target_os = "windows"))]
- return Box::new(provider::NopProvider::new());
+ Box::new(provider::NopProvider::new())
}
}