feat(core): improve clipboard backend handling on macOS
This commit is contained in:
		
							parent
							
								
									4068f5ac66
								
							
						
					
					
						commit
						a40125715f
					
				| 
						 | 
					@ -19,7 +19,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use std::path::PathBuf;
 | 
					use std::path::PathBuf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use espanso_inject::{Injector, keys::Key};
 | 
					use espanso_inject::{InjectionOptions, Injector, keys::Key};
 | 
				
			||||||
use espanso_clipboard::Clipboard;
 | 
					use espanso_clipboard::Clipboard;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::engine::{dispatch::HtmlInjector, dispatch::{ImageInjector, TextInjector}};
 | 
					use crate::engine::{dispatch::HtmlInjector, dispatch::{ImageInjector, TextInjector}};
 | 
				
			||||||
| 
						 | 
					@ -41,8 +41,24 @@ impl <'a> ClipboardInjectorAdapter<'a> {
 | 
				
			||||||
    // TODO: handle delay duration
 | 
					    // TODO: handle delay duration
 | 
				
			||||||
    std::thread::sleep(std::time::Duration::from_millis(100));
 | 
					    std::thread::sleep(std::time::Duration::from_millis(100));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let combination = if cfg!(target_os = "macos") {
 | 
				
			||||||
 | 
					      &[Key::Meta, Key::V]
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      &[Key::Control, Key::V]
 | 
				
			||||||
 | 
					    }; // TODO: handle case of custom combination
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // TODO: handle user-specified delays
 | 
				
			||||||
 | 
					    let paste_combination_delay = if cfg!(target_os = "macos") {
 | 
				
			||||||
 | 
					      5
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      InjectionOptions::default().delay
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO: handle options
 | 
					    // TODO: handle options
 | 
				
			||||||
    self.injector.send_key_combination(&[Key::Control, Key::V], Default::default())?;
 | 
					    self.injector.send_key_combination(combination, InjectionOptions {
 | 
				
			||||||
 | 
					      delay: paste_combination_delay,
 | 
				
			||||||
 | 
					      ..Default::default()
 | 
				
			||||||
 | 
					    })?;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Ok(())
 | 
					    Ok(())
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user