Skip to content

Commit

Permalink
[Fix] copy not working on Linux (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistricky authored Jul 8, 2024
1 parent daa3d1e commit 06bba0f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions generator/src/copy_ascii.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::cmp::max;

use crate::{
code::{calc_max_line_number_length, calc_wh},
config::TakeSnapshotParams,
};
use arboard::Clipboard;
#[cfg(target_os = "linux")]
use arboard::SetExtLinux;
use nvim_oxi::Result;
use std::cmp::max;

const SPACE_BOTH_SIDE: usize = 2;

Expand Down Expand Up @@ -59,6 +60,17 @@ pub fn copy_ascii(params: TakeSnapshotParams) -> Result<()> {
);
let ascii_snapshot = format!("{top_frame}{breadcrumbs}{code}{bottom_frame}");

#[cfg(target_os = "linux")]
std::thread::spawn(move || {
Clipboard::new()
.unwrap()
.set()
.wait()
.text(ascii_snapshot)
.unwrap();
});

#[cfg(not(target_os = "linux"))]
Clipboard::new().unwrap().set_text(ascii_snapshot).unwrap();

Ok(())
Expand Down

0 comments on commit 06bba0f

Please sign in to comment.