Expand description
Provides a cross-platform clipboard manager for text manipulation.
This module offers a simple, unified interface for interacting with the system clipboard, allowing applications to easily get and set text content. It abstracts platform-specific details, providing a consistent API across different operating systems.
§Key Features
- Set Text: Place a string onto the system clipboard.
- Get Text: Retrieve the current text content from the system clipboard.
- Cross-platform: Uses
arboard
for broad platform support (Windows, macOS, Linux). - Graceful Fallback: On unsupported platforms like Android, operations are no-ops that log a warning, preventing crashes.
§Usage
The main entry point is the Clipboard
struct, which provides methods to interact
with the system clipboard.
use tessera_ui::clipboard::Clipboard;
// Create a new clipboard instance.
let mut clipboard = Clipboard::new();
// Set text to the clipboard.
let text_to_set = "Hello, Tessera!";
clipboard.set_text(text_to_set);
// Get text from the clipboard.
if let Some(text_from_clipboard) = clipboard.get_text() {
assert_eq!(text_from_clipboard, text_to_set);
println!("Clipboard text: {}", text_from_clipboard);
} else {
println!("Could not retrieve text from clipboard.");
}
§Note on Android
Clipboard operations are currently not supported on Android. Any calls to set_text
or
get_text
on Android will result in a warning log and will not perform any action.
Structs§
- Clipboard
- Manages access to the system clipboard for text-based copy and paste operations.