style(clipboard): fix formatting
This commit is contained in:
parent
9e3742f273
commit
9202c1189c
|
@ -19,7 +19,10 @@
|
|||
|
||||
mod ffi;
|
||||
|
||||
use std::{ffi::{CStr, CString}, path::PathBuf};
|
||||
use std::{
|
||||
ffi::{CStr, CString},
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
use crate::Clipboard;
|
||||
use anyhow::Result;
|
||||
|
|
|
@ -91,5 +91,7 @@ pub fn get_clipboard(options: ClipboardOptions) -> Result<Box<dyn Clipboard>> {
|
|||
// less efficient
|
||||
|
||||
info!("using WaylandFallbackClipboard");
|
||||
Ok(Box::new(wayland::fallback::WaylandFallbackClipboard::new(options)?))
|
||||
Ok(Box::new(wayland::fallback::WaylandFallbackClipboard::new(
|
||||
options,
|
||||
)?))
|
||||
}
|
|
@ -122,21 +122,31 @@ impl Clipboard for WaylandFallbackClipboard {
|
|||
let mut data = Vec::new();
|
||||
file.read_to_end(&mut data)?;
|
||||
|
||||
self.invoke_command_with_timeout(&mut Command::new("wl-copy").arg("--type").arg("image/png"), &data, "wl-copy")
|
||||
self.invoke_command_with_timeout(
|
||||
&mut Command::new("wl-copy").arg("--type").arg("image/png"),
|
||||
&data,
|
||||
"wl-copy",
|
||||
)
|
||||
}
|
||||
|
||||
fn set_html(&self, html: &str, _fallback_text: Option<&str>) -> anyhow::Result<()> {
|
||||
self.invoke_command_with_timeout(&mut Command::new("wl-copy").arg("--type").arg("text/html"), html.as_bytes(), "wl-copy")
|
||||
self.invoke_command_with_timeout(
|
||||
&mut Command::new("wl-copy").arg("--type").arg("text/html"),
|
||||
html.as_bytes(),
|
||||
"wl-copy",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl WaylandFallbackClipboard {
|
||||
fn invoke_command_with_timeout(&self, command: &mut Command, data: &[u8], name: &str) -> Result<()> {
|
||||
fn invoke_command_with_timeout(
|
||||
&self,
|
||||
command: &mut Command,
|
||||
data: &[u8],
|
||||
name: &str,
|
||||
) -> Result<()> {
|
||||
let timeout = std::time::Duration::from_millis(self.command_timeout);
|
||||
match command
|
||||
.stdin(Stdio::piped())
|
||||
.spawn()
|
||||
{
|
||||
match command.stdin(Stdio::piped()).spawn() {
|
||||
Ok(mut child) => {
|
||||
if let Some(stdin) = child.stdin.as_mut() {
|
||||
stdin.write_all(data)?;
|
||||
|
|
|
@ -17,7 +17,11 @@
|
|||
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::{ffi::{CStr, CString}, io::Read, path::PathBuf};
|
||||
use std::{
|
||||
ffi::{CStr, CString},
|
||||
io::Read,
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
use crate::Clipboard;
|
||||
use anyhow::Result;
|
||||
|
@ -67,9 +71,7 @@ impl Clipboard for X11NativeClipboard {
|
|||
let mut data = Vec::new();
|
||||
file.read_to_end(&mut data)?;
|
||||
|
||||
let native_result = unsafe {
|
||||
ffi::clipboard_x11_set_image(data.as_ptr(), data.len() as i32)
|
||||
};
|
||||
let native_result = unsafe { ffi::clipboard_x11_set_image(data.as_ptr(), data.len() as i32) };
|
||||
|
||||
if native_result > 0 {
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue
Block a user