use crate::app_state::with_app_state;
pub fn clipboard_copy(text: &str) {
with_app_state(|app| {
*app.clipboard.borrow_mut() = Some(text.to_string());
app.outgoing_clipboard.set(text.to_string());
});
}
pub fn take_clipboard_change() -> Option<String> {
with_app_state(|app| app.outgoing_clipboard.take())
}
pub fn clipboard_paste() -> Option<String> {
with_app_state(|app| {
app.system_clipboard
.borrow()
.clone()
.or_else(|| app.clipboard.borrow().clone())
})
}
pub fn clipboard_has_content() -> bool {
with_app_state(|app| {
app.system_clipboard.borrow().is_some() || app.clipboard.borrow().is_some()
})
}
pub fn set_system_clipboard(text: String) {
with_app_state(|app| *app.system_clipboard.borrow_mut() = Some(text));
}
pub fn clear_system_clipboard() {
with_app_state(|app| *app.system_clipboard.borrow_mut() = None);
}
pub fn primary_copy(text: &str) {
with_app_state(|app| {
*app.primary.borrow_mut() = Some(text.to_string());
app.outgoing_primary.set(text.to_string());
});
}
pub(crate) fn take_primary_change() -> Option<String> {
with_app_state(|app| app.outgoing_primary.take())
}
pub fn primary_paste() -> Option<String> {
with_app_state(|app| {
app.system_primary
.borrow()
.clone()
.or_else(|| app.primary.borrow().clone())
})
}
pub(crate) fn set_system_primary(text: Option<String>) {
with_app_state(|app| *app.system_primary.borrow_mut() = text);
}