diff options
Diffstat (limited to 'src/pane')
| -rw-r--r-- | src/pane/terminal.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pane/terminal.rs b/src/pane/terminal.rs index 0bb7632a..ba1dbea8 100644 --- a/src/pane/terminal.rs +++ b/src/pane/terminal.rs @@ -33,6 +33,13 @@ pub struct ScrollMetrics { } #[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct TerminalCursorState { + pub x: u16, + pub y: u16, + pub visible: bool, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct InputState { pub alternate_screen: bool, pub application_cursor: bool, @@ -118,6 +125,10 @@ impl PaneTerminal { self.ghostty.input_state() } + pub fn cursor_state(&self) -> Option<TerminalCursorState> { + self.ghostty.cursor_state() + } + pub fn visible_text(&self) -> String { self.ghostty.visible_text() } @@ -455,6 +466,22 @@ impl GhosttyPaneTerminal { }) } + pub fn cursor_state(&self) -> Option<TerminalCursorState> { + let mut core = self.core.lock().ok()?; + let GhosttyPaneCore { + terminal, + render_state, + .. + } = &mut *core; + render_state.update(terminal).ok()?; + let cursor = render_state.cursor_viewport().ok()??; + Some(TerminalCursorState { + x: cursor.x, + y: cursor.y, + visible: render_state.cursor_visible().ok()?, + }) + } + pub fn encode_terminal_key( &self, key: crate::input::TerminalKey, |
