From 73dba97521f5a0e3104518ef48b775a178998f52 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Fri, 15 May 2026 20:53:34 +0300 Subject: fix: forward pane cursor shape fixes #116 --- src/ghostty/mod.rs | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/ghostty') diff --git a/src/ghostty/mod.rs b/src/ghostty/mod.rs index a0ff3226..ef03716a 100644 --- a/src/ghostty/mod.rs +++ b/src/ghostty/mod.rs @@ -203,6 +203,31 @@ pub struct KittyPlacementRenderInfo { pub source_height: u32, } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum CursorVisualStyle { + Bar, + Block, + Underline, + BlockHollow, +} + +impl CursorVisualStyle { + fn from_raw(value: ffi::GhosttyRenderStateCursorVisualStyle) -> Self { + match value { + ffi::GhosttyRenderStateCursorVisualStyle_GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_BLOCK => { + Self::Block + } + ffi::GhosttyRenderStateCursorVisualStyle_GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_UNDERLINE => { + Self::Underline + } + ffi::GhosttyRenderStateCursorVisualStyle_GHOSTTY_RENDER_STATE_CURSOR_VISUAL_STYLE_BLOCK_HOLLOW => { + Self::BlockHollow + } + _ => Self::Bar, + } + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ActiveScreen { Primary, @@ -1278,6 +1303,24 @@ impl RenderState { self.get_bool(ffi::GhosttyRenderStateData_GHOSTTY_RENDER_STATE_DATA_CURSOR_VISIBLE) } + pub fn cursor_blinking(&self) -> Result { + self.get_bool(ffi::GhosttyRenderStateData_GHOSTTY_RENDER_STATE_DATA_CURSOR_BLINKING) + } + + pub fn cursor_visual_style(&self) -> Result { + let mut out: ffi::GhosttyRenderStateCursorVisualStyle = 0; + // SAFETY: out points to the matching enum storage for the requested data kind. + unsafe { + ffi::ghostty_render_state_get( + self.raw, + ffi::GhosttyRenderStateData_GHOSTTY_RENDER_STATE_DATA_CURSOR_VISUAL_STYLE, + (&mut out as *mut ffi::GhosttyRenderStateCursorVisualStyle).cast(), + ) + .into_result()?; + } + Ok(CursorVisualStyle::from_raw(out)) + } + pub fn cursor_viewport(&self) -> Result, Error> { if !self.get_bool( ffi::GhosttyRenderStateData_GHOSTTY_RENDER_STATE_DATA_CURSOR_VIEWPORT_HAS_VALUE, -- cgit v1.2.3