aboutsummaryrefslogtreecommitdiff
path: root/src/selection.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-04-10 14:29:41 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-04-10 14:32:07 +0300
commit4a3b8f2fcf7f13ea611636c802398f7e8d79fbca (patch)
tree68ace12d157640d53da4588fbdf6b325b436ec98 /src/selection.rs
parent6c62dba44e6679e37e1626f07c830c81469a0f57 (diff)
fix: forward pane osc 52 clipboard writes
Diffstat (limited to 'src/selection.rs')
-rw-r--r--src/selection.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/selection.rs b/src/selection.rs
index fab687e5..050964fd 100644
--- a/src/selection.rs
+++ b/src/selection.rs
@@ -165,22 +165,27 @@ fn clamp_to_pane(screen_col: u16, screen_row: u16, pane_inner: Rect) -> (u16, u1
(clamped_row - pane_inner.y, clamped_col - pane_inner.x)
}
-/// Write text to the system clipboard via OSC 52.
+/// Write clipboard bytes to the system clipboard via OSC 52.
///
/// OSC 52 format: `ESC ] 52 ; c ; <base64> BEL`
///
/// The terminal emulator (Ghostty, kitty, etc.) intercepts this
/// and sets the system clipboard. Ghostty has `clipboard-write = allow`
/// by default.
-pub fn write_osc52(text: &str) {
+pub fn write_osc52_bytes(bytes: &[u8]) {
use base64::Engine;
- let encoded = base64::engine::general_purpose::STANDARD.encode(text);
+ let encoded = base64::engine::general_purpose::STANDARD.encode(bytes);
// Use ST (ESC \) terminator — more widely supported than BEL in some terminals
let sequence = format!("\x1b]52;c;{encoded}\x1b\\");
let _ = std::io::stdout().write_all(sequence.as_bytes());
let _ = std::io::stdout().flush();
}
+/// Write text to the system clipboard via OSC 52.
+pub fn write_osc52(text: &str) {
+ write_osc52_bytes(text.as_bytes());
+}
+
#[cfg(test)]
mod tests {
use super::*;