diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-05 04:27:49 +0300 |
|---|---|---|
| committer | Can Celik <ogulcancelik@gmail.com> | 2026-04-05 15:37:01 +0300 |
| commit | 46c65725036f1778a059f9dbf3939bc3be8c27c4 (patch) | |
| tree | ffef5a05d26eb250d79227ec24698ffc0cdd65d8 /src/ghostty | |
| parent | 26ec677193ef7e207feaec19c3ed1504d6f23029 (diff) | |
fix: prevent ghostty pane redraw corruption on wide cells
Diffstat (limited to 'src/ghostty')
| -rw-r--r-- | src/ghostty/mod.rs | 47 |
1 files changed, 47 insertions, 0 deletions
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<dyn FnMut(&[u8]) + Send>, } @@ -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<ffi::GhosttyCell, Error> { + 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<CellWide, Error> { + 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<CellStyle, Error> { let mut style = ffi::GhosttyStyle { size: mem::size_of::<ffi::GhosttyStyle>(), |
