Skip to main content

par_term_terminal/terminal/
clipboard.rs

1use super::TerminalManager;
2pub use par_term_emu_core_rust::terminal::{ClipboardEntry, ClipboardSlot};
3
4impl TerminalManager {
5    /// Get clipboard history for a specific slot
6    pub fn get_clipboard_history(&self, slot: ClipboardSlot) -> Vec<ClipboardEntry> {
7        let pty = self.pty_session.lock();
8        let terminal = pty.terminal();
9        let term = terminal.lock();
10        term.get_clipboard_history(slot)
11    }
12
13    /// Get the most recent clipboard entry for a slot
14    #[allow(dead_code)]
15    pub fn get_latest_clipboard(&self, slot: ClipboardSlot) -> Option<ClipboardEntry> {
16        let pty = self.pty_session.lock();
17        let terminal = pty.terminal();
18        let term = terminal.lock();
19        term.get_latest_clipboard(slot)
20    }
21
22    /// Search clipboard history across all slots or a specific slot
23    #[allow(dead_code)]
24    pub fn search_clipboard_history(
25        &self,
26        query: &str,
27        slot: Option<ClipboardSlot>,
28    ) -> Vec<ClipboardEntry> {
29        let pty = self.pty_session.lock();
30        let terminal = pty.terminal();
31        let term = terminal.lock();
32        term.search_clipboard_history(query, slot)
33    }
34
35    /// Add content to clipboard history
36    pub fn add_to_clipboard_history(
37        &self,
38        slot: ClipboardSlot,
39        content: String,
40        label: Option<String>,
41    ) {
42        let pty = self.pty_session.lock();
43        let terminal = pty.terminal();
44        let mut term = terminal.lock();
45        term.add_to_clipboard_history(slot, content, label);
46    }
47
48    /// Clear clipboard history for a specific slot
49    pub fn clear_clipboard_history(&self, slot: ClipboardSlot) {
50        let pty = self.pty_session.lock();
51        let terminal = pty.terminal();
52        let mut term = terminal.lock();
53        term.clear_clipboard_history(slot);
54    }
55
56    /// Clear all clipboard history
57    pub fn clear_all_clipboard_history(&self) {
58        let pty = self.pty_session.lock();
59        let terminal = pty.terminal();
60        let mut term = terminal.lock();
61        term.clear_all_clipboard_history();
62    }
63
64    /// Set maximum clipboard sync events retained
65    pub fn set_max_clipboard_sync_events(&self, max: usize) {
66        let pty = self.pty_session.lock();
67        let terminal = pty.terminal();
68        let mut term = terminal.lock();
69        term.set_max_clipboard_sync_events(max);
70    }
71
72    /// Set maximum bytes cached per clipboard event
73    pub fn set_max_clipboard_event_bytes(&self, max_bytes: usize) {
74        let pty = self.pty_session.lock();
75        let terminal = pty.terminal();
76        let mut term = terminal.lock();
77        term.set_max_clipboard_event_bytes(max_bytes);
78    }
79
80    /// Set maximum clipboard history entries per slot
81    #[allow(dead_code)]
82    pub fn set_max_clipboard_sync_history(&self, max: usize) {
83        let pty = self.pty_session.lock();
84        let terminal = pty.terminal();
85        let mut term = terminal.lock();
86        term.set_max_clipboard_sync_history(max);
87    }
88}