diff options
| author | JJ Liebig <jonathan.liebig@gmail.com> | 2026-08-07 18:24:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-07 19:24:56 +0300 |
| commit | 00f04ac65cedf882f9785c0aa20831523c554dd0 (patch) | |
| tree | c3bcfd7d563931e23e927a18633f8346343a3e5a /src/ghostty | |
| parent | b0723b7906998dbe5314aaf05d18c047fd288dd0 (diff) | |
fix: avoid redundant Windows recent-history snapshots (#2474)
refs #962
Co-authored-by: Can Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/ghostty')
| -rw-r--r-- | src/ghostty/mod.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/ghostty/mod.rs b/src/ghostty/mod.rs index ef67b86f..04ad87af 100644 --- a/src/ghostty/mod.rs +++ b/src/ghostty/mod.rs @@ -768,6 +768,9 @@ pub fn encode_focus(event: FocusEvent) -> Result<Vec<u8>, Error> { pub struct Terminal { raw: ffi::GhosttyTerminal, + max_scrollback: usize, + #[cfg(windows)] + tracked_row: ffi::GhosttyTrackedGridRef, callback_state: Box<TerminalCallbackState>, kitty_fingerprints: Mutex<HashMap<u32, KittyImageFingerprintEntry>>, kitty_empty_generation: Cell<Option<u64>>, @@ -788,6 +791,9 @@ impl Terminal { let mut terminal = Self { raw, + max_scrollback, + #[cfg(windows)] + tracked_row: ptr::null_mut(), callback_state: Box::new(TerminalCallbackState { size_report: ffi::GhosttySizeReportSize { rows, @@ -1033,6 +1039,10 @@ impl Terminal { self.get_usize(ffi::GhosttyTerminalData_GHOSTTY_TERMINAL_DATA_SCROLLBACK_ROWS) } + pub fn max_scrollback(&self) -> usize { + self.max_scrollback + } + pub fn scrollbar(&self) -> Result<TerminalScrollbar, Error> { let mut out = ffi::GhosttyTerminalScrollbar::default(); unsafe { @@ -1050,6 +1060,22 @@ impl Terminal { }) } + #[cfg(windows)] + pub(crate) fn track_row(&mut self, y: u32) -> Option<usize> { + let mut point = ffi::GhosttyPointCoordinate::default(); + let tag = ffi::GhosttyPointTag_GHOSTTY_POINT_TAG_SCREEN; + let result = + unsafe { ffi::ghostty_tracked_grid_ref_point(self.tracked_row, tag, &mut point) }; + let terminal = self.raw; + let target = ghostty_viewport_point(0, y); + unsafe { + ffi::ghostty_tracked_grid_ref_free(self.tracked_row); + self.tracked_row = ptr::null_mut(); + let _ = ffi::ghostty_terminal_grid_ref_track(terminal, target, &mut self.tracked_row); + } + (result == ffi::GhosttyResult_GHOSTTY_SUCCESS).then_some(point.y as usize) + } + pub fn screen_cell(&self, x: u16, y: u32) -> Result<(CellWide, Vec<u32>), Error> { let grid_ref = self.grid_ref(ghostty_screen_point(x, y))?; let wide = grid_ref_wide(&grid_ref)?; @@ -1834,6 +1860,8 @@ impl Drop for Terminal { fn drop(&mut self) { // SAFETY: freeing a null or live handle is allowed by the C API. unsafe { + #[cfg(windows)] + ffi::ghostty_tracked_grid_ref_free(self.tracked_row); ffi::ghostty_terminal_free(self.raw); } } |
