1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Clipboard access for system clipboard operations.
//!
//! This module provides the [`ClipboardApi`] trait for direct system clipboard I/O.
//! Commands and operators use this to explicitly interact with the OS clipboard.
//!
//! # Design (#515)
//!
//! Decoupled from [`RegisterApi`](super::RegisterApi): registers (`a-z`, `""`, `0-9`)
//! are pure per-client storage. Clipboard (`+`, `*`) is a separate shared OS resource
//! accessed through this trait.
//!
//! # Example
//!
//! ```ignore
//! use reovim_driver_session::api::{ClipboardApi, RegisterApi, RegisterContent};
//!
//! fn yank_to_clipboard<S: RegisterApi + ClipboardApi>(
//! session: &mut S,
//! register: Option<char>,
//! text: &str,
//! ) {
//! let content = RegisterContent::characterwise(text);
//! session.set_register(register, content);
//!
//! // Explicitly sync to OS clipboard for + and *
//! match register {
//! Some('+') => { session.copy_to_clipboard(text); }
//! Some('*') => { session.copy_to_selection(text); }
//! _ => {}
//! }
//! }
//! ```
/// System clipboard access for copy/paste operations.
///
/// Provides direct access to the OS clipboard (`+` register) and
/// selection clipboard (`*` register, X11 primary selection).
///
/// # Graceful Degradation
///
/// All methods return `bool`/`Option` rather than `Result` because
/// clipboard unavailability (headless, SSH, Wayland without clipboard
/// manager) is a normal condition, not an error.
///
/// # Shared Resource
///
/// The clipboard is an OS-level shared resource. All clients in a session
/// share the same clipboard. Per-client register storage (`+`/`*` in
/// `RegisterBank`) provides a local fallback when the clipboard is
/// unavailable.