rusty_bubbletea/xterm.rs
1//! Cleanroom Rust port of upstream Go source file: `xterm.go`
2//! Upstream Target Tag / Version: `v2.0.8`
3//!
4//! <public-docs>
5//! # XTerm Commands & Messages
6//!
7//! Terminal version queries (`request_terminal_version`) and responses (`TerminalVersionMsg`).
8//! </public-docs>
9
10use crate::model::Cmd;
11use std::fmt;
12
13/// TerminalVersionMsg represents the terminal version (XTVERSION).
14#[derive(Debug, Clone, PartialEq, Eq)]
15pub struct TerminalVersionMsg {
16 /// Terminal version string name.
17 pub name: String,
18}
19
20impl fmt::Display for TerminalVersionMsg {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 write!(f, "{}", self.name)
23 }
24}
25
26/// RequestTerminalVersionMsg is sent internally to request terminal version.
27#[derive(Debug, Clone, Copy, PartialEq, Eq)]
28pub struct RequestTerminalVersionMsg;
29
30/// RequestTerminalVersion is a command that queries the terminal for its
31/// version using XTVERSION. Note that some terminals may not support this
32/// command.
33pub fn request_terminal_version() -> Cmd {
34 Some(Box::new(|| Some(Box::new(RequestTerminalVersionMsg))))
35}