From 46c65725036f1778a059f9dbf3939bc3be8c27c4 Mon Sep 17 00:00:00 2001 From: Can Celik Date: Sun, 5 Apr 2026 04:27:49 +0300 Subject: fix: prevent ghostty pane redraw corruption on wide cells --- src/ghostty/mod.rs | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/ghostty') diff --git a/src/ghostty/mod.rs b/src/ghostty/mod.rs index fe76d00d..c5214472 100644 --- a/src/ghostty/mod.rs +++ b/src/ghostty/mod.rs @@ -199,6 +199,26 @@ pub struct RenderColors { pub foreground: RgbColor, } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum CellWide { + Narrow, + Wide, + SpacerTail, + SpacerHead, +} + +impl CellWide { + fn from_raw(value: ffi::GhosttyCellWide) -> Self { + match value { + ffi::GhosttyCellWide_GHOSTTY_CELL_WIDE_NARROW => Self::Narrow, + ffi::GhosttyCellWide_GHOSTTY_CELL_WIDE_WIDE => Self::Wide, + ffi::GhosttyCellWide_GHOSTTY_CELL_WIDE_SPACER_TAIL => Self::SpacerTail, + ffi::GhosttyCellWide_GHOSTTY_CELL_WIDE_SPACER_HEAD => Self::SpacerHead, + _ => Self::Narrow, + } + } +} + struct WritePtyCallbackState { callback: Box, } @@ -917,6 +937,33 @@ impl<'a> RowCellIter<'a> { unsafe { ffi::ghostty_render_state_row_cells_select(self.cells.raw, x).into_result() } } + fn raw_cell(&self) -> Result { + let mut raw = ffi::GhosttyCell::default(); + unsafe { + ffi::ghostty_render_state_row_cells_get( + self.cells.raw, + ffi::GhosttyRenderStateRowCellsData_GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_RAW, + (&mut raw as *mut ffi::GhosttyCell).cast(), + ) + .into_result()?; + } + Ok(raw) + } + + pub fn wide(&self) -> Result { + let raw = self.raw_cell()?; + let mut wide = ffi::GhosttyCellWide_GHOSTTY_CELL_WIDE_NARROW; + unsafe { + ffi::ghostty_cell_get( + raw, + ffi::GhosttyCellData_GHOSTTY_CELL_DATA_WIDE, + (&mut wide as *mut ffi::GhosttyCellWide).cast(), + ) + .into_result()?; + } + Ok(CellWide::from_raw(wide)) + } + pub fn style(&self) -> Result { let mut style = ffi::GhosttyStyle { size: mem::size_of::(), -- cgit v1.2.3