From 4a3b8f2fcf7f13ea611636c802398f7e8d79fbca Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Fri, 10 Apr 2026 14:29:41 +0300 Subject: fix: forward pane osc 52 clipboard writes --- src/selection.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/selection.rs') 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 ; 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::*; -- cgit v1.2.3