uncurses/ansi/iterm2.rs
1//! OSC 1337 payload framing.
2//!
3//! ## Category
4//!
5//! This module emits a generic OSC 1337 string with an application-defined
6//! payload. The payload is not parsed or escaped.
7//!
8//! ## OSC framing
9//!
10//! The writer emits `ESC ] 1337 ; <payload> BEL` using the 7-bit OSC introducer
11//! and BEL terminator.
12//!
13//! ## Mode interaction
14//!
15//! OSC 1337 payloads are not gated by an ANSI or DEC mode. Unsupported terminals
16//! may ignore the string control.
17
18use std::io::{self, Write};
19
20/// Send a generic OSC 1337 message with `ESC ] 1337 ; <payload> BEL`.
21///
22/// `payload` is emitted verbatim; callers are responsible for avoiding embedded OSC terminators.
23pub fn write_iterm2<W: Write>(w: &mut W, payload: &str) -> io::Result<()> {
24 write!(w, "\x1b]1337;{payload}\x07")
25}