Created
November 23, 2020 21:58
-
-
Save sigmaSd/9e97a9d9499c59263a213bd4aa1ba8d0 to your computer and use it in GitHub Desktop.
https://crates.io/crates/leptess https://github.com/emersion/grim https://github.com/emersion/slurp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn copy_region() -> Result<()> { | |
let region = std::process::Command::new("slurp").output()?; | |
let mut region = String::from_utf8(region.stdout)?; | |
region.pop(); // remove \n | |
std::process::Command::new("grim") | |
.args(&["-g", ®ion]) | |
.arg(std::env::temp_dir().join("select.png")) | |
.spawn()? | |
.wait()?; | |
let mut lt = leptess::LepTess::new(None, "eng").unwrap(); | |
lt.set_image(std::env::temp_dir().join("select.png"))?; | |
let mut stdout = std::io::stdout(); | |
write!(stdout, "{}", lt.get_utf8_text()?)?; | |
stdout.flush()?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment