diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-07 02:48:13 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-07 02:48:13 +0300 |
| commit | 5e05460816bbcea61a111bfa57be9907116e8ffc (patch) | |
| tree | 86309a79cd7f49b82e0129de131c6723365a14a1 /src/pane.rs | |
| parent | 06f01df93d895298508173cd59a8cf8eb2dd5bdc (diff) | |
docs: clarify herdr pane split and wait output usage
Diffstat (limited to 'src/pane.rs')
| -rw-r--r-- | src/pane.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/pane.rs b/src/pane.rs index e2afccdc..dcddabf4 100644 --- a/src/pane.rs +++ b/src/pane.rs @@ -345,6 +345,10 @@ impl PaneTerminal { self.ghostty.recent_text(lines) } + fn recent_unwrapped_text(&self, lines: usize) -> String { + self.ghostty.recent_unwrapped_text(lines) + } + fn extract_selection(&self, selection: &crate::selection::Selection) -> Option<String> { self.ghostty.extract_selection(selection) } @@ -648,6 +652,14 @@ impl GhosttyPaneTerminal { .unwrap_or_default() } + fn recent_unwrapped_text(&self, lines: usize) -> String { + self.core + .lock() + .ok() + .and_then(|core| ghostty_recent_text_unwrapped(&core, lines).ok()) + .unwrap_or_default() + } + fn extract_selection(&self, selection: &crate::selection::Selection) -> Option<String> { self.core .lock() @@ -1055,6 +1067,21 @@ fn ghostty_recent_text( Ok(recent_text_from_rows(&rows, lines)) } +fn ghostty_recent_text_unwrapped( + core: &GhosttyPaneCore, + lines: usize, +) -> Result<String, crate::ghostty::Error> { + let total_rows = core.terminal.total_rows()?; + let cols = core.terminal.cols()?; + if total_rows == 0 || cols == 0 { + return Ok(String::new()); + } + let start = total_rows.saturating_sub(lines) as u32; + let end = (total_rows.saturating_sub(1)) as u32; + core.terminal + .read_text_screen((0, start), (cols.saturating_sub(1), end), false) +} + fn ghostty_extract_selection( core: &mut GhosttyPaneCore, selection: &crate::selection::Selection, @@ -1685,6 +1712,10 @@ impl PaneRuntime { self.terminal.recent_text(lines) } + pub fn recent_unwrapped_text(&self, lines: usize) -> String { + self.terminal.recent_unwrapped_text(lines) + } + pub fn extract_selection(&self, selection: &crate::selection::Selection) -> Option<String> { self.terminal.extract_selection(selection) } @@ -1964,6 +1995,17 @@ mod tests { } #[test] + fn recent_unwrapped_text_ignores_soft_wraps() { + let (tx, _rx) = mpsc::channel(4); + let mut terminal = crate::ghostty::Terminal::new(5, 3, 100).unwrap(); + terminal.write(b"ABCDEFGHIJ"); + let pane = GhosttyPaneTerminal::new(terminal, tx).unwrap(); + + assert_eq!(pane.recent_text(3), "ABCDE\nFGHIJ\n"); + assert_eq!(pane.recent_unwrapped_text(3), "ABCDEFGHIJ"); + } + + #[test] fn synchronized_output_suppresses_intermediate_render_requests_until_batch_ends() { let (tx, _rx) = mpsc::channel(4); let terminal = crate::ghostty::Terminal::new(80, 24, 0).unwrap(); |
