on master help sign in
clipboard: add logging and healthcheck (#3271)

* add logging to clipboard setup * healthcheck: add clipboard provider name Co-authored-by: amitbeka <--->

commitfe3a9a868ea944a17f5a70e892bd8b985d6485e9 authorAmit Beka <amitbeka@users.noreply.github.com> dateSun 31 Jul 2022, 11:05 (4 years ago) parente405e88
2 files changed+15
helix-term/src/health.rs+3 helix-view/src/clipboard.rs+12
helix-term/src/health.rs+3
@@ -4,6 +4,7 @@ use crossterm::{
44};
55use helix_core::config::{default_syntax_loader, user_syntax_loader};
66use helix_loader::grammar::load_runtime_file;
7+use helix_view::clipboard::get_clipboard_provider;
78use std::io::Write;
89
910#[derive(Copy, Clone)]
@@ -52,6 +53,7 @@ pub fn general() -> std::io::Result<()> {
5253 let lang_file = helix_loader::lang_config_file();
5354 let log_file = helix_loader::log_file();
5455 let rt_dir = helix_loader::runtime_dir();
56+ let clipboard_provider = get_clipboard_provider();
5557
5658 if config_file.exists() {
5759 writeln!(stdout, "Config file: {}", config_file.display())?;
@@ -76,6 +78,7 @@ pub fn general() -> std::io::Result<()> {
7678 if rt_dir.read_dir().ok().map(|it| it.count()) == Some(0) {
7779 writeln!(stdout, "{}", "Runtime directory is empty.".red())?;
7880 }
81+ writeln!(stdout, "Clipboard provider: {}", clipboard_provider.name())?;
7982
8083 Ok(())
8184}
helix-view/src/clipboard.rs+12
@@ -17,6 +17,10 @@ pub trait ClipboardProvider: std::fmt::Debug {
1717#[cfg(not(windows))]
1818macro_rules! command_provider {
1919 (paste => $get_prg:literal $( , $get_arg:literal )* ; copy => $set_prg:literal $( , $set_arg:literal )* ; ) => {{
20+ log::info!(
21+ "Using {} to interact with the system clipboard",
22+ if $set_prg != $get_prg { format!("{}+{}", $set_prg, $get_prg)} else { $set_prg.to_string() }
23+ );
2024 Box::new(provider::command::Provider {
2125 get_cmd: provider::command::Config {
2226 prg: $get_prg,
@@ -36,6 +40,10 @@ macro_rules! command_provider {
3640 primary_paste => $pr_get_prg:literal $( , $pr_get_arg:literal )* ;
3741 primary_copy => $pr_set_prg:literal $( , $pr_set_arg:literal )* ;
3842 ) => {{
43+ log::info!(
44+ "Using {} to interact with the system and selection (primary) clipboard",
45+ if $set_prg != $get_prg { format!("{}+{}", $set_prg, $get_prg)} else { $set_prg.to_string() }
46+ );
3947 Box::new(provider::command::Provider {
4048 get_cmd: provider::command::Config {
4149 prg: $get_prg,
@@ -146,6 +154,9 @@ mod provider {
146154 #[cfg(not(target_os = "windows"))]
147155 impl NopProvider {
148156 pub fn new() -> Self {
157+ log::warn!(
158+ "No clipboard provider found! Yanking and pasting will be internal to Helix"
159+ );
149160 Self {
150161 buf: String::new(),
151162 primary_buf: String::new(),
@@ -184,6 +195,7 @@ mod provider {
184195 #[cfg(target_os = "windows")]
185196 impl ClipboardProvider for WindowsProvider {
186197 fn name(&self) -> Cow<str> {
198+ log::info!("Using clipboard-win to interact with the system clipboard");
187199 Cow::Borrowed("clipboard-win")
188200 }
189201