diff options
Diffstat (limited to 'src/ghostty')
| -rw-r--r-- | src/ghostty/mod.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/ghostty/mod.rs b/src/ghostty/mod.rs index 297b0e6b..55bafebc 100644 --- a/src/ghostty/mod.rs +++ b/src/ghostty/mod.rs @@ -461,11 +461,27 @@ impl Terminal { end: (u16, u32), rectangle: bool, ) -> Result<String, Error> { - let selection = GhosttyTerminalSelection { + self.read_text_selection(GhosttyTerminalSelection { start: ghostty_viewport_point(start.0, start.1), end: ghostty_viewport_point(end.0, end.1), rectangle, - }; + }) + } + + pub fn read_text_screen( + &self, + start: (u16, u32), + end: (u16, u32), + rectangle: bool, + ) -> Result<String, Error> { + self.read_text_selection(GhosttyTerminalSelection { + start: ghostty_screen_point(start.0, start.1), + end: ghostty_screen_point(end.0, end.1), + rectangle, + }) + } + + fn read_text_selection(&self, selection: GhosttyTerminalSelection) -> Result<String, Error> { let mut out_ptr = ptr::null_mut(); let mut out_len = 0usize; unsafe { @@ -570,6 +586,15 @@ fn ghostty_viewport_point(x: u16, y: u32) -> ffi::GhosttyPoint { } } +fn ghostty_screen_point(x: u16, y: u32) -> ffi::GhosttyPoint { + ffi::GhosttyPoint { + tag: ffi::GhosttyPointTag_GHOSTTY_POINT_TAG_SCREEN, + value: ffi::GhosttyPointValue { + coordinate: ffi::GhosttyPointCoordinate { x, y }, + }, + } +} + pub struct RenderState { raw: ffi::GhosttyRenderState_ptr, } |
