-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
10 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
use clippers::{Clipboard, ClipperData}; | ||
use arboard::Clipboard; | ||
|
||
use crate::error::{Error, Result}; | ||
use crate::error::Result; | ||
|
||
/// Gets the clipboard content (text) | ||
pub fn get_content() -> Result<String> { | ||
let mut clipboard = Clipboard::get(); | ||
let mut clipboard = Clipboard::new()?; | ||
|
||
if let Some(ClipperData::Text(text)) = clipboard.read() { | ||
Ok(text.to_string()) | ||
} else { | ||
Err(Error::Clipboard( | ||
"Pasted in Something which isn't Text, f.e. a picture".to_string(), | ||
)) | ||
} | ||
Ok(clipboard.get_text()?) | ||
} | ||
|
||
/// Sets the clipboard content | ||
pub fn set_content(content: String) -> Result<()> { | ||
let mut clipboard = Clipboard::get(); | ||
let mut clipboard = Clipboard::new()?; | ||
|
||
Ok(clipboard.write_text(content)?) | ||
Ok(clipboard.set_text(content)?) | ||
} |
This file contains 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