diff options
| author | akbash <akbash@herdr.dev> | 2026-08-08 02:15:56 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-08 02:15:56 +0300 |
| commit | 6f311498aeeb27c0973781961ef94e8d0016ed17 (patch) | |
| tree | 7aee2363b21b830fdbcf8dca9a7eda57a3393fb5 /src/ghostty/mod.rs | |
| parent | 50ddc06f00ec69ede35fd5488a260dec2b74e98a (diff) | |
fix: forward pane terminal bells (#2498)
refs #2453
Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
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) } |
