Skip to main content

uncurses/ansi/
urxvt.rs

1//! OSC 777 extension-message framing.
2//!
3//! ## Category
4//!
5//! This module writes a generic OSC 777 extension invocation: extension name plus
6//! optional semicolon-separated parameters.
7//!
8//! ## OSC framing
9//!
10//! The emitted format is `ESC ] 777 ; <extension> [;param...] BEL`. Parameters
11//! are written verbatim in the order supplied.
12//!
13//! ## Mode interaction
14//!
15//! OSC 777 messages are not controlled by ANSI or DEC modes. Unsupported
16//! terminals ignore the OSC string.
17
18use std::io::{self, Write};
19
20/// Invoke an OSC 777 extension with `ESC ] 777 ; <extension> [;param...] BEL`.
21///
22/// `extension` and each parameter are emitted verbatim as semicolon-separated fields.
23pub fn write_urxvt_ext<W: Write>(w: &mut W, extension: &str, params: &[&str]) -> io::Result<()> {
24    write!(w, "\x1b]777;{extension}")?;
25    for p in params {
26        write!(w, ";{p}")?;
27    }
28    w.write_all(b"\x07")
29}