aboutsummaryrefslogtreecommitdiff
path: root/src/pane/terminal.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-07-22 18:59:01 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-07-22 18:59:01 +0300
commit1d238bc9a365d9dd1297b4e11fe775cd656aebd0 (patch)
treea12551ab3dc80d36ef15549aee1db08b467606b8 /src/pane/terminal.rs
parentc234f221f9be698bc0501c60459e1ae8e67df6c3 (diff)
refactor: replace pane mouse and clipboard internals
replaces contributions from othavi0
Diffstat (limited to 'src/pane/terminal.rs')
-rw-r--r--src/pane/terminal.rs42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/pane/terminal.rs b/src/pane/terminal.rs
index 2c83f8f2..261f7025 100644
--- a/src/pane/terminal.rs
+++ b/src/pane/terminal.rs
@@ -31,7 +31,7 @@ use super::{
maybe_filter_primary_screen_scrollback_clear, parse_reported_cwd,
restore_host_terminal_theme_if_needed, write_host_terminal_theme_selective,
AgentOscStateTracker, DefaultColorEvent, DefaultColorEventTracker, DefaultColorOscTracker,
- DefaultColorQuery, DefaultColorTrackedEvent, Osc52Forwarder, OscDebugTracker,
+ DefaultColorQuery, DefaultColorTrackedEvent, OscDebugTracker,
},
xtgettcap::{XtgettcapQueryTracker, XtgettcapResponse},
};
@@ -161,7 +161,6 @@ pub(crate) struct GhosttyPaneCore {
pub default_color_event_tracker: DefaultColorEventTracker,
pub child_default_foreground_changed: bool,
pub child_default_background_changed: bool,
- pub osc52_forwarder: Osc52Forwarder,
pub osc_debug_tracker: OscDebugTracker,
pub agent_osc_state: AgentOscStateTracker,
pub xtgettcap_query_tracker: XtgettcapQueryTracker,
@@ -915,7 +914,6 @@ impl GhosttyPaneTerminal {
default_color_event_tracker: DefaultColorEventTracker::default(),
child_default_foreground_changed: false,
child_default_background_changed: false,
- osc52_forwarder: Osc52Forwarder::default(),
osc_debug_tracker: OscDebugTracker::default(),
agent_osc_state: AgentOscStateTracker::default(),
xtgettcap_query_tracker: XtgettcapQueryTracker::default(),
@@ -1049,6 +1047,9 @@ impl GhosttyPaneTerminal {
};
let _ = core.terminal.take_pwd_changes();
+ // Restored history may have exercised terminal callbacks before this live PTY write.
+ // Those writes must not be delivered as live pane output.
+ let _ = core.terminal.take_clipboard_writes();
let default_color_observation = core.default_color_tracker.observe(bytes);
if shell_pid > 0 && default_color_observation {
if let Some(owner_pgid) = current_transient_default_color_owner(shell_pid) {
@@ -1060,8 +1061,6 @@ impl GhosttyPaneTerminal {
}
}
- core.osc52_forwarder.observe(bytes);
- let clipboard_writes = core.osc52_forwarder.drain_pending();
core.osc_debug_tracker.observe(bytes);
for event in core.osc_debug_tracker.drain_pending() {
debug!(
@@ -1116,6 +1115,7 @@ impl GhosttyPaneTerminal {
xtgettcap_responses,
&mut terminal_responses,
);
+ let clipboard_writes = core.terminal.take_clipboard_writes();
let reported_cwd = core
.terminal
.take_pwd_changes()
@@ -3222,6 +3222,38 @@ mod tests {
}
#[test]
+ fn process_pty_bytes_surfaces_clipboard_writes_without_other_results() {
+ let (tx, _rx) = mpsc::channel(4);
+ let terminal = crate::ghostty::Terminal::new(80, 24, 100).unwrap();
+ let pane = GhosttyPaneTerminal::new(terminal, tx.clone()).unwrap();
+
+ let result = pane.process_pty_bytes(
+ PaneId::from_raw(1),
+ 0,
+ b"output\x1b]52;c;Y2xpcGJvYXJk\x07",
+ &tx,
+ );
+
+ assert!(result.request_render);
+ assert_eq!(result.render_delay, None);
+ assert_eq!(result.clipboard_writes, vec![b"clipboard".to_vec()]);
+ assert_eq!(result.reported_cwd, None);
+ assert!(result.terminal_responses.is_empty());
+ }
+
+ #[test]
+ fn seeded_history_clipboard_write_does_not_leak_into_live_output() {
+ let (tx, _rx) = mpsc::channel(4);
+ let terminal = crate::ghostty::Terminal::new(80, 24, 100).unwrap();
+ let pane = GhosttyPaneTerminal::new(terminal, tx.clone()).unwrap();
+ pane.seed_history_ansi("\x1b]52;c;c3RhbGU=\x07");
+
+ let result = pane.process_pty_bytes(PaneId::from_raw(1), 0, b"live output", &tx);
+
+ assert!(result.clipboard_writes.is_empty());
+ }
+
+ #[test]
fn seeded_history_pwd_does_not_leak_into_live_output() {
let (tx, _rx) = mpsc::channel(4);
let terminal = crate::ghostty::Terminal::new(80, 24, 100).unwrap();