on master help sign in
clipboard: add logging and healthcheck (#3271)
fe3a9a8Amit Beka
helix-term/src/health.rs+3
@@ -4,6 +4,7 @@ use crossterm::{
4};
4};
5use helix_core::config::{default_syntax_loader, user_syntax_loader};
5use helix_core::config::{default_syntax_loader, user_syntax_loader};
6use helix_loader::grammar::load_runtime_file;
6use helix_loader::grammar::load_runtime_file;
7+use helix_view::clipboard::get_clipboard_provider;
7use std::io::Write;
8use std::io::Write;
8
9
9#[derive(Copy, Clone)]
10#[derive(Copy, Clone)]
@@ -52,6 +53,7 @@ pub fn general() -> std::io::Result<()> {
52 let lang_file = helix_loader::lang_config_file();
53 let lang_file = helix_loader::lang_config_file();
53 let log_file = helix_loader::log_file();
54 let log_file = helix_loader::log_file();
54 let rt_dir = helix_loader::runtime_dir();
55 let rt_dir = helix_loader::runtime_dir();
56+ let clipboard_provider = get_clipboard_provider();
55
57
56 if config_file.exists() {
58 if config_file.exists() {
57 writeln!(stdout, "Config file: {}", config_file.display())?;
59 writeln!(stdout, "Config file: {}", config_file.display())?;
@@ -76,6 +78,7 @@ pub fn general() -> std::io::Result<()> {
76 if rt_dir.read_dir().ok().map(|it| it.count()) == Some(0) {
78 if rt_dir.read_dir().ok().map(|it| it.count()) == Some(0) {
77 writeln!(stdout, "{}", "Runtime directory is empty.".red())?;
79 writeln!(stdout, "{}", "Runtime directory is empty.".red())?;
78 }
80 }
81+ writeln!(stdout, "Clipboard provider: {}", clipboard_provider.name())?;
79
82
80 Ok(())
83 Ok(())
81}
84}
helix-view/src/clipboard.rs+12
@@ -17,6 +17,10 @@ pub trait ClipboardProvider: std::fmt::Debug {
17#[cfg(not(windows))]
17#[cfg(not(windows))]
18macro_rules! command_provider {
18macro_rules! command_provider {
19 (paste => $get_prg:literal $( , $get_arg:literal )* ; copy => $set_prg:literal $( , $set_arg:literal )* ; ) => {{
19 (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+ );
20 Box::new(provider::command::Provider {
24 Box::new(provider::command::Provider {
21 get_cmd: provider::command::Config {
25 get_cmd: provider::command::Config {
22 prg: $get_prg,
26 prg: $get_prg,
@@ -36,6 +40,10 @@ macro_rules! command_provider {
36 primary_paste => $pr_get_prg:literal $( , $pr_get_arg:literal )* ;
40 primary_paste => $pr_get_prg:literal $( , $pr_get_arg:literal )* ;
37 primary_copy => $pr_set_prg:literal $( , $pr_set_arg:literal )* ;
41 primary_copy => $pr_set_prg:literal $( , $pr_set_arg:literal )* ;
38 ) => {{
42 ) => {{
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+ );
39 Box::new(provider::command::Provider {
47 Box::new(provider::command::Provider {
40 get_cmd: provider::command::Config {
48 get_cmd: provider::command::Config {
41 prg: $get_prg,
49 prg: $get_prg,
@@ -146,6 +154,9 @@ mod provider {
146 #[cfg(not(target_os = "windows"))]
154 #[cfg(not(target_os = "windows"))]
147 impl NopProvider {
155 impl NopProvider {
148 pub fn new() -> Self {
156 pub fn new() -> Self {
157+ log::warn!(
158+ "No clipboard provider found! Yanking and pasting will be internal to Helix"
159+ );
149 Self {
160 Self {
150 buf: String::new(),
161 buf: String::new(),
151 primary_buf: String::new(),
162 primary_buf: String::new(),
@@ -184,6 +195,7 @@ mod provider {
184 #[cfg(target_os = "windows")]
195 #[cfg(target_os = "windows")]
185 impl ClipboardProvider for WindowsProvider {
196 impl ClipboardProvider for WindowsProvider {
186 fn name(&self) -> Cow<str> {
197 fn name(&self) -> Cow<str> {
198+ log::info!("Using clipboard-win to interact with the system clipboard");
187 Cow::Borrowed("clipboard-win")
199 Cow::Borrowed("clipboard-win")
188 }
200 }
189
201