diff options
Diffstat (limited to 'src/ghostty/mod.rs')
| -rw-r--r-- | src/ghostty/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ghostty/mod.rs b/src/ghostty/mod.rs index 04ad87af..93efbd76 100644 --- a/src/ghostty/mod.rs +++ b/src/ghostty/mod.rs @@ -470,12 +470,22 @@ const MAX_CLIPBOARD_BYTES: usize = 192 * 1024; #[derive(Default)] struct TerminalCallbackState { write_pty: Option<Box<WritePtyCallback>>, + bell_count: u16, pwd_changes: Vec<Vec<u8>>, clipboard_writes: Vec<Vec<u8>>, size_report: ffi::GhosttySizeReportSize, color_scheme: Option<ColorScheme>, } +unsafe extern "C" fn bell_trampoline(_terminal: ffi::GhosttyTerminal, userdata: *mut c_void) { + if userdata.is_null() { + return; + } + // SAFETY: userdata is the TerminalCallbackState installed with this terminal. + let state = unsafe { &mut *userdata.cast::<TerminalCallbackState>() }; + state.bell_count = state.bell_count.saturating_add(1); +} + unsafe extern "C" fn color_scheme_trampoline( _terminal: ffi::GhosttyTerminal, userdata: *mut c_void, @@ -822,6 +832,12 @@ impl Terminal { .into_result()?; ffi::ghostty_terminal_set( terminal.raw, + ffi::GhosttyTerminalOption_GHOSTTY_TERMINAL_OPT_BELL, + (bell_trampoline as *const ()).cast(), + ) + .into_result()?; + ffi::ghostty_terminal_set( + terminal.raw, ffi::GhosttyTerminalOption_GHOSTTY_TERMINAL_OPT_PWD_CHANGED, (pwd_changed_trampoline as *const ()).cast(), ) @@ -979,6 +995,10 @@ impl Terminal { mem::replace(&mut self.callback_state.color_scheme, color_scheme) } + pub fn take_bell_count(&mut self) -> u16 { + mem::take(&mut self.callback_state.bell_count) + } + pub fn take_pwd_changes(&mut self) -> Vec<Vec<u8>> { mem::take(&mut self.callback_state.pwd_changes) } |
