diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-25 15:36:50 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-25 15:36:50 +0300 |
| commit | d4a5e02e8433db156b9dabe2b81ddd1d2aca9ea6 (patch) | |
| tree | f94ebdfc2bf1e54b3d110052269c67b6ba5f6fb8 /src/terminal | |
| parent | a1543f3e248f8f5266322014ccd853e478b1dcd6 (diff) | |
feat: hand off ptys during updates
Diffstat (limited to 'src/terminal')
| -rw-r--r-- | src/terminal/runtime.rs | 59 | ||||
| -rw-r--r-- | src/terminal/runtime_registry.rs | 33 |
2 files changed, 92 insertions, 0 deletions
diff --git a/src/terminal/runtime.rs b/src/terminal/runtime.rs index 2aa49b68..13ce75c9 100644 --- a/src/terminal/runtime.rs +++ b/src/terminal/runtime.rs @@ -19,6 +19,61 @@ impl TerminalRuntime { self.0.shutdown(); } + #[cfg(unix)] + pub fn duplicate_handoff_fd(&self) -> std::io::Result<std::os::fd::RawFd> { + self.0.duplicate_handoff_fd() + } + + #[cfg(unix)] + pub fn preserve_for_handoff(self) { + self.0.preserve_for_handoff() + } + + #[cfg(unix)] + pub fn assume_handoff_ownership(&mut self) { + self.0.assume_handoff_ownership(); + } + + #[cfg(unix)] + pub fn set_handoff_reader_paused(&self, paused: bool) { + self.0.set_handoff_reader_paused(paused); + } + + #[cfg(unix)] + pub fn pause_handoff_reader(&self, timeout: std::time::Duration) -> std::io::Result<()> { + self.0.pause_handoff_reader(timeout) + } + + #[cfg(unix)] + pub fn handoff_pane(&self, pane_id: u32) -> crate::server::handoff::HandoffPane { + self.0.handoff_pane(pane_id) + } + + #[cfg(unix)] + pub fn handoff_history_ansi(&self) -> Option<String> { + self.0.handoff_history_ansi() + } + + #[cfg(unix)] + pub fn from_handoff_fd( + import: crate::pane::PaneRuntimeImport, + scrollback_limit_bytes: usize, + host_terminal_theme: crate::terminal_theme::TerminalTheme, + events: mpsc::Sender<AppEvent>, + render_notify: Arc<Notify>, + render_dirty: Arc<AtomicBool>, + ) -> std::io::Result<Self> { + crate::pane::PaneRuntime::from_handoff_fd( + import, + scrollback_limit_bytes, + host_terminal_theme, + events, + render_notify, + render_dirty, + ) + .map(Self) + } + pub fn spawn( pane_id: PaneId, rows: u16, @@ -172,6 +227,10 @@ impl TerminalRuntime { self.0.resize(rows, cols, cell_width_px, cell_height_px); } + pub fn nudge_child_redraw_after_handoff(&self) { + self.0.nudge_child_redraw_after_handoff(); + } + pub fn scroll_up(&self, lines: usize) { self.0.scroll_up(lines); } diff --git a/src/terminal/runtime_registry.rs b/src/terminal/runtime_registry.rs index d1aeeae2..a909985e 100644 --- a/src/terminal/runtime_registry.rs +++ b/src/terminal/runtime_registry.rs @@ -37,10 +37,43 @@ impl TerminalRuntimeRegistry { self.runtimes.values() } + #[cfg(unix)] + pub(crate) fn iter(&self) -> impl Iterator<Item = (&TerminalId, &TerminalRuntime)> { + self.runtimes.iter() + } + + #[cfg(unix)] + pub(crate) fn set_handoff_readers_paused(&self, paused: bool) { + for runtime in self.runtimes.values() { + runtime.set_handoff_reader_paused(paused); + } + } + + #[cfg(unix)] + pub(crate) fn assume_handoff_ownership(&mut self) { + for runtime in self.runtimes.values_mut() { + runtime.assume_handoff_ownership(); + } + } + pub(crate) fn len(&self) -> usize { self.runtimes.len() } + #[cfg(unix)] + pub(crate) fn nudge_child_redraw_after_handoff(&self) { + for runtime in self.runtimes.values() { + runtime.nudge_child_redraw_after_handoff(); + } + } + + #[cfg(unix)] + pub(crate) fn drain_for_handoff( + &mut self, + ) -> impl Iterator<Item = (TerminalId, TerminalRuntime)> + '_ { + self.runtimes.drain() + } + #[cfg(test)] pub(crate) fn drain(&mut self) -> impl Iterator<Item = (TerminalId, TerminalRuntime)> + '_ { self.runtimes.drain() |
