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/terminal_effects.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/terminal_effects.rs')
| -rw-r--r-- | src/terminal_effects.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/terminal_effects.rs b/src/terminal_effects.rs new file mode 100644 index 00000000..88fcf55f --- /dev/null +++ b/src/terminal_effects.rs @@ -0,0 +1,27 @@ +use std::io::{self, Write}; + +const BELL_CHUNK: [u8; 64] = [b'\x07'; 64]; + +pub(crate) fn write_terminal_bells<W: Write>(writer: &mut W, count: u16) -> io::Result<()> { + let full_chunks = usize::from(count) / BELL_CHUNK.len(); + let remainder = usize::from(count) % BELL_CHUNK.len(); + for _ in 0..full_chunks { + writer.write_all(&BELL_CHUNK)?; + } + writer.write_all(&BELL_CHUNK[..remainder])?; + writer.flush() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn writes_exact_terminal_bell_count() { + let mut output = Vec::new(); + + write_terminal_bells(&mut output, 130).unwrap(); + + assert_eq!(output, vec![b'\x07'; 130]); + } +} |
