Compare commits

..

24 Commits

Author SHA1 Message Date
7ed5ad78db adds categories of control functions 2023-04-08 01:59:10 +02:00
2da6eb2337 adds the LICENSE.txt file to the files published in this crate 2023-04-02 03:36:42 +02:00
29707b465c updates to version 0.0.2 2023-04-02 03:27:52 +02:00
e4b2c20c37 adds a README.md to this crate 2023-04-02 03:26:52 +02:00
d9e5b5b869 updates the documentation of modes 2023-04-02 03:17:34 +02:00
8b0f1bf33c added functions for control strings 2023-04-02 00:43:58 +02:00
48ea74c685 updates keywords of the library 2023-04-01 23:40:48 +02:00
41c8154a3a changes repository url to ansi-control-codes 2023-04-01 23:38:45 +02:00
b6a6e55156 fixes documentation errors in c0.rs 2023-04-01 23:34:22 +02:00
32682a2d08 renames crate from ansi to ansi-control-codes 2023-04-01 23:05:20 +02:00
d1caad00cc updates crate keywords 2023-04-01 22:18:56 +02:00
6b81631b85 removes unused variante ControlFunctionType::ControlString 2023-04-01 17:58:49 +02:00
2010dabf57 prepares the library for an initial release to crates.io 2023-04-01 17:58:28 +02:00
c285678d26 fixes ambiguous unicode characters 2023-04-01 04:41:51 +02:00
138e15c763 adds git repository to Cargo.toml 2023-04-01 04:36:02 +02:00
ad9146075b implements From<ControlFunction> for String 2023-04-01 04:33:45 +02:00
59bdca5c50 improves the documentation of module independent_control_functions 2023-04-01 03:57:07 +02:00
6e503b96c8 improves documentation in module control_sequences 2023-04-01 03:52:18 +02:00
dceb34a9a9 improves documentation in module c1 2023-04-01 02:41:25 +02:00
4e4052b74c improves documentation in module c0 2023-04-01 02:15:30 +02:00
f297692e64 adds tests to lib.rs 2023-04-01 01:48:15 +02:00
30906d2075 adds default traits to ControlFunctionType 2023-04-01 01:48:15 +02:00
ef555cbe05 adds more documentation to lib.rs 2023-04-01 01:48:15 +02:00
52a2be9a1a implements Debug for ControlFunction 2023-04-01 01:48:07 +02:00
10 changed files with 1337 additions and 359 deletions

View File

@@ -1,16 +1,18 @@
[package] [package]
name = "ansi" name = "ansi-control-codes"
description = "This library contains all ANSI Escape Codes that are defined in the ISO 6429 Standard" description = "This library contains all ANSI Escape Codes that are defined in the ISO 6429 Standard"
version = "0.1.0" version = "0.0.2"
edition = "2021" edition = "2021"
authors = ["Frank Zechert <rust.frank@zechert.net>"] authors = ["Frank Zechert <rust.frank@zechert.net>"]
repository = "" repository = "https://git.zechert.net/fzechert/ansi-control-codes.git"
license = "MIT" license = "MIT"
# crates.io # crates.io
publish = false publish = true
keywords = ["ansi", "escape codes", "ISO 6429", "ECMA 48", "ANSI X3.64"] keywords = ["ansi", "escape-codes", "control-codes", "ISO-6429", "ECMA-48"]
categories = ["command-line-interface"] categories = ["command-line-interface"]
include = ["**/*.rs", "Cargo.toml", "README.md", "LICENSE.txt"]
readme = "README.md"
[dependencies] [dependencies]

43
README.md Normal file
View File

@@ -0,0 +1,43 @@
# ANSI Escape Code Library
ANSI escape sequences are a standard for in-band signalling to control cursor location, color, font styling, and
other options on video text terminals and terminal emulators.
This library contains all ANSI Escape Codes that are defined in the [ISO 6429 Standard][iso-6429]. ISO 6429 is
the international standard that followed from the efforts of aligning the european [ECMA-48 Standard][ecma-48] and
the american [ANSI X3.64 Standard][ansi-x364].
## Documentation
Find the latest documentation of this crate at <https://docs.rs/crate/ansi-control-codes/latest>.
## Source Code Repository
The source code for this library is hosted at <https://git.zechert.net/fzechert/ansi-control-codes>.
## Contribution
Contributions are welcome. Please keep in mind that the source code is not at github, but on my own git server.
If you want to contribute, feel free to contact me.
## Development / Maintenance Status
This crate is under active development and maintenance.
## Source Material
The second, and newer, editions of the [ECMA-48 Standard][ecma-48] are based on the text of the
[ISO 6429 Standard][iso-6429] and are technically identical with it. Since the [ISO 6429 Standard][iso-6429] is not
freely available on the internet, this implementation is based on the publicly available documents of the
[ECMA-48 Standard][ecma-48]. In particular on edition 5 of the [ECMA-48 Standard][ecma-48], which is identical to
the third edition of [ISO-6429][iso-6429].
The [ANSI X3.64 Standard][ansi-x364] has been withdrawn by ANSI in 1994 in favour of the international standard.
You can read more about the history of the standards on [Wikipedia: ANSI escape code][wikipedia-ansi].
[ansi-x364]: https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub86.pdf
[ascii-table]: https://en.wikipedia.org/wiki/ASCII#/media/File:USASCII_code_chart.png
[ecma-48]: https://www.ecma-international.org/publications-and-standards/standards/ecma-48/
[iso-6429]: https://www.iso.org/standard/12782.html
[wikipedia-ansi]: https://en.wikipedia.org/wiki/ANSI_escape_code

138
src/c0.rs
View File

@@ -5,8 +5,20 @@
//! The 3-character escape sequence designating and invoking this C0 set is `ESC 02/01 04/00`, //! The 3-character escape sequence designating and invoking this C0 set is `ESC 02/01 04/00`,
//! see [`ANNOUNCER_SEQUENCE`]. //! see [`ANNOUNCER_SEQUENCE`].
//! //!
//! It is assumed that even with no invoked C0 set, the control character `ESCAPE` (`ESC`) is always available, and is //! It is assumed that even with no invoked C0 set, the control character `ESCAPE` ([`ESC`]) is always available, and is
//! represented by bit combination `01/00`. //! represented by bit combination `01/11`.
//!
//! ## Usage
//!
//! You can use the Elements of the C0 set inside normal strings, format them with the `format!()` macro, or print
//! them with the `print!()` and `println!()` macros.
//!
//! For example, designate the C0 set, then ring the bell.
//!
//! ```
//! use ansi_control_codes::c0::{ANNOUNCER_SEQUENCE, BEL};
//! println!("{}{}", ANNOUNCER_SEQUENCE, BEL);
//! ```
//! //!
//! ## Overview of the C0 Set //! ## Overview of the C0 Set
//! //!
@@ -36,7 +48,7 @@ macro_rules! c0 {
}; };
} }
/// Announcer Sequence for C0. /// Announcer Sequence for Control Set C0.
/// ///
/// Designate the C0 set of control functions as the active set of control functions. /// Designate the C0 set of control functions as the active set of control functions.
/// ///
@@ -46,7 +58,7 @@ macro_rules! c0 {
/// ///
/// ## Note 2 /// ## Note 2
/// ///
/// It is assumed that even with no invoked C0 set, the control character `ESCAPE` (`ESC`) is available, and is /// It is assumed that even with no invoked C0 set, the control character ESCAPE (`ESC`) is available, and is
/// represented by the bit combination `01/11`. /// represented by the bit combination `01/11`.
pub const ANNOUNCER_SEQUENCE: &'static str = ascii!(01 / 11, 02 / 01, 04 / 00); pub const ANNOUNCER_SEQUENCE: &'static str = ascii!(01 / 11, 02 / 01, 04 / 00);
@@ -54,7 +66,9 @@ pub const ANNOUNCER_SEQUENCE: &'static str = ascii!(01 / 11, 02 / 01, 04 / 00);
/// ///
/// `ACK` is transmitted by a receiver as an affirmative response to the sender. /// `ACK` is transmitted by a receiver as an affirmative response to the sender.
/// ///
/// The use of `ACK` is defined in ISO 1745. /// The use of `ACK` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const ACK: ControlFunction = c0!(00 / 06); pub const ACK: ControlFunction = c0!(00 / 06);
/// Bell. /// Bell.
@@ -68,7 +82,7 @@ pub const BEL: ControlFunction = c0!(00 / 07);
/// opposite to that of the implicit movement. /// opposite to that of the implicit movement.
/// ///
/// The direction of the implicit movement depends on the parameter value of Select Implicit Movement Direction /// The direction of the implicit movement depends on the parameter value of Select Implicit Movement Direction
/// (`SIMD`). /// ([`SIMD`][crate::control_sequences::SIMD]).
pub const BS: ControlFunction = c0!(00 / 08); pub const BS: ControlFunction = c0!(00 / 08);
/// Cancel. /// Cancel.
@@ -80,24 +94,30 @@ pub const CAN: ControlFunction = c0!(01 / 08);
/// Carriage Return. /// Carriage Return.
/// ///
/// The effect of `CR` depends on the setting of the DEVICE COMPONENT SELECT MODE (`DCSM`) and on the parameter value of /// The effect of `CR` depends on the setting of the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) and
/// SELECT IMPLICIT MOVEMENT DIRECTION (`SIMD`). /// on the parameter value of SELECT IMPLICIT MOVEMENT DIRECTION ([`SIMD`][crate::control_sequences::SIMD]).
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION and with the parameter value of `SIMD` equal to /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION and with the parameter
/// `0`, `CR` causes the active presentation position to be moved to the line home position of the same line in the /// value of [`SIMD`][crate::control_sequences::SIMD] equal to
/// presentation component. The line home position is established by the parameter value of SET LINE HOME (`SLH`). /// [`Normal`][crate::control_sequences::MovementDirection::Normal], `CR` causes the active presentation position to be
/// moved to the line home position of the same line in the presentation component. The line home position is
/// established by the parameter value of SET LINE HOME ([`SLH`][crate::control_sequences::SLH]).
/// ///
/// With a parameter value of `SIMD` equal to `1`, `CR` causes the active presentation position to be moved to the line /// With a parameter value of [`SIMD`][crate::control_sequences::SIMD] equal to
/// limit position of the same line in the presentation component. The line limit position is established by the /// [`Opposite`][crate::control_sequences::MovementDirection::Opposite], `CR` causes the active presentation position to
/// parameter value of SET LINE LIMIT (`SSL`). /// be moved to the line limit position of the same line in the presentation component. The line limit position is
/// established by the parameter value of SET LINE LIMIT ([`SLL`][crate::control_sequences::SLL]).
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA and with a parameter of `SIMD` equal to `0`, `CR` causes /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA and with a parameter of
/// the active data position to be moved to the line home position of the same line in the data component. The line home /// [`SIMD`][crate::control_sequences::SIMD] equal to [`Normal`][crate::control_sequences::MovementDirection::Normal],
/// position is established by the parameter value of SET LINE HOME (`SLH`). /// `CR` causes the active data position to be moved to the line home position of the same line in the data component.
/// The line home position is established by the parameter value of SET LINE HOME
/// ([`SLH`][crate::control_sequences::SLH]).
/// ///
/// With a parameter value of `SIMD` equal to `1`, `CR` causes the active data position to be moved to the line limit /// With a parameter value of [`SIMD`][crate::control_sequences::SIMD] equal to
/// position of the same line in the data component. The line limit position is established by the parameter value of /// [`Opposite`][crate::control_sequences::MovementDirection::Opposite], `CR` causes the active data position to be
/// SET LINE LIMIT (`SSL`). /// moved to the line limit position of the same line in the data component. The line limit position is established by
/// the parameter value of SET LINE LIMIT ([`SLL`][crate::control_sequences::SLL]).
pub const CR: ControlFunction = c0!(00 / 13); pub const CR: ControlFunction = c0!(00 / 13);
/// Device Control One. /// Device Control One.
@@ -135,7 +155,9 @@ pub const DC4: ControlFunction = c0!(01 / 04);
/// ///
/// `DLE` is used exclusively to provide supplementary transmission control functions. /// `DLE` is used exclusively to provide supplementary transmission control functions.
/// ///
/// The use of `DLE` is defined in ISO 1745. /// The use of `DLE` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const DLE: ControlFunction = c0!(01 / 00); pub const DLE: ControlFunction = c0!(01 / 00);
/// End Of Medium. /// End Of Medium.
@@ -148,14 +170,18 @@ pub const EM: ControlFunction = c0!(01 / 09);
/// ///
/// `ENQ` is transmitted by a sender as a request for a response from a receiver. /// `ENQ` is transmitted by a sender as a request for a response from a receiver.
/// ///
/// The use of `EOT` is defined in ISO 1745. /// The use of `ENQ` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const ENQ: ControlFunction = c0!(00 / 05); pub const ENQ: ControlFunction = c0!(00 / 05);
/// End Of Transmission. /// End Of Transmission.
/// ///
/// `EOT` is used to indicate the conclusion of the transmission of one or more texts. /// `EOT` is used to indicate the conclusion of the transmission of one or more texts.
/// ///
/// The use of `EOT` is defined in ISO 1745. /// The use of `EOT` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const EOT: ControlFunction = c0!(00 / 04); pub const EOT: ControlFunction = c0!(00 / 04);
/// Escape. /// Escape.
@@ -163,7 +189,9 @@ pub const EOT: ControlFunction = c0!(00 / 04);
/// `ESC` is used for code extension purposes. It causes the meanings of a limited number of bit combinations following /// `ESC` is used for code extension purposes. It causes the meanings of a limited number of bit combinations following
/// it in the data stream to be changed. /// it in the data stream to be changed.
/// ///
/// The use of `ESC` is defined in Standard ECMA-35. /// The use of `ESC` is defined in Standard [ECMA-35][ecma-35].
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const ESC: ControlFunction = c0!(01 / 11); pub const ESC: ControlFunction = c0!(01 / 11);
/// End Of Transmission Block. /// End Of Transmission Block.
@@ -171,21 +199,25 @@ pub const ESC: ControlFunction = c0!(01 / 11);
/// `ETB` is used to indicate the end of a block of data where the data are divided into such blocks for transmission /// `ETB` is used to indicate the end of a block of data where the data are divided into such blocks for transmission
/// purposes. /// purposes.
/// ///
/// The use of `ETB` is defined in ISO 1745. /// The use of `ETB` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const ETB: ControlFunction = c0!(01 / 07); pub const ETB: ControlFunction = c0!(01 / 07);
/// End Of Text. /// End Of Text.
/// ///
/// `ETX` is used to indicate the end of a text. /// `ETX` is used to indicate the end of a text.
/// ///
/// The use of `ETX` is defined in ISO 1745. /// The use of `ETX` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const ETX: ControlFunction = c0!(00 / 03); pub const ETX: ControlFunction = c0!(00 / 03);
/// Form Feed. /// Form Feed.
/// ///
/// `FF` causes the active presentation position to be moved to the corresponding character position of the line at the /// `FF` causes the active presentation position to be moved to the corresponding character position of the line at the
/// page home position of the next form or page in the presentation component. The page home position is established by /// page home position of the next form or page in the presentation component. The page home position is established by
/// the parameter value of SET PAGE HOME (`SPH`). /// the parameter value of SET PAGE HOME ([`SPH`][crate::control_sequences::SPH]).
pub const FF: ControlFunction = c0!(00 / 12); pub const FF: ControlFunction = c0!(00 / 12);
/// Character Tabulation. /// Character Tabulation.
@@ -193,11 +225,12 @@ pub const FF: ControlFunction = c0!(00 / 12);
/// `HT` causes the active presentation position to be moved to the following character tabulation stop in the /// `HT` causes the active presentation position to be moved to the following character tabulation stop in the
/// presentation component. /// presentation component.
/// ///
/// In addition, if that following character tabulation stop has been set by TABULATION ALIGN CENTRE (`TAC`), TABULATION /// In addition, if that following character tabulation stop has been set by TABULATION ALIGN CENTRE
/// ALIGN LEADING EDGE (`TALE`), TABULATION ALIGN TRAILING EDGE (`TATE`) or TABULATION CENTERED ON CHARACTER (`TCC`), /// ([`TAC`][crate::control_sequences::TAC]), TABULATION ALIGN LEADING EDGE ([`TALE`][crate::control_sequences::TALE]),
/// `HT` indicates the beginning of a string of text which is to be positioned within a line according to the properties /// TABULATION ALIGN TRAILING EDGE ([`TATE`][crate::control_sequences::TATE]) or TABULATION CENTRED ON CHARACTER
/// of that tabulation stop. The end of the string is indicated by the next occurrence of `HT` or CARRIAGE RETURN /// ([`TCC`][crate::control_sequences::TCC]), `HT` indicates the beginning of a string of text which is to be positioned
/// ([`CR`]) or NEXT LINE ([`NEL`][crate::c1::NEL]) in the data stream. /// within a line according to the properties of that tabulation stop. The end of the string is indicated by the next
/// occurrence of `HT` or CARRIAGE RETURN ([`CR`]) or NEXT LINE ([`NEL`][crate::c1::NEL]) in the data stream.
pub const HT: ControlFunction = c0!(00 / 09); pub const HT: ControlFunction = c0!(00 / 09);
/// Information Separator One (US - Unit Separator). /// Information Separator One (US - Unit Separator).
@@ -226,11 +259,12 @@ pub const IS4: ControlFunction = c0!(01 / 12);
/// Line Feed. /// Line Feed.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `LF` causes the active presentation position /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `LF` causes the active
/// to be moved to the corresponding character position of the following line in the presentation component. /// presentation position to be moved to the corresponding character position of the following line in the presentation
/// component.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `LF` causes the active data position to be moved to the /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `LF` causes the active data
/// corresponding character position of the following line in the data component. /// position to be moved to the corresponding character position of the following line in the data component.
pub const LF: ControlFunction = c0!(00 / 10); pub const LF: ControlFunction = c0!(00 / 10);
/// Locking-Shift Zero. /// Locking-Shift Zero.
@@ -250,18 +284,22 @@ pub const LS0: ControlFunction = c0!(00 / 15);
/// `LS1` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data /// `LS1` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `LS1` is defined in Standard ECMA-35. /// The use of `LS1` is defined in Standard [ECMA-35][ecma-35].
/// ///
/// ## Note /// ## Note
/// ///
/// `LS1` is used in 8-bit environments only; in 7-bit environments SHIFT-OUT ([`SO`]) is used instead. /// `LS1` is used in 8-bit environments only; in 7-bit environments SHIFT-OUT ([`SO`]) is used instead.
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const LS1: ControlFunction = c0!(00 / 14); pub const LS1: ControlFunction = c0!(00 / 14);
/// Negative Acknowledge. /// Negative Acknowledge.
/// ///
/// `NAK` is transmitted by a receiver as a negative response to the sender. /// `NAK` is transmitted by a receiver as a negative response to the sender.
/// ///
/// The use of `NAK` is defined in ISO 1745. /// The use of `NAK` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const NAK: ControlFunction = c0!(01 / 05); pub const NAK: ControlFunction = c0!(01 / 05);
/// Null. /// Null.
@@ -276,11 +314,13 @@ pub const NUL: ControlFunction = c0!(00 / 00);
/// `SI` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data /// `SI` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `SI` is defined in Standard ECMA-35. /// The use of `SI` is defined in Standard [ECMA-35][ecma-35].
/// ///
/// ## Note /// ## Note
/// ///
/// `SI` is used in 7-bit environments only; in 8-bit environments LOCKING-SHIFT ZERO (`LS0`) is used instead. /// `SI` is used in 7-bit environments only; in 8-bit environments LOCKING-SHIFT ZERO ([`LS0`]) is used instead.
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const SI: ControlFunction = c0!(00 / 15); pub const SI: ControlFunction = c0!(00 / 15);
/// Shift-Out. /// Shift-Out.
@@ -288,25 +328,31 @@ pub const SI: ControlFunction = c0!(00 / 15);
/// `SO` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data /// `SO` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `SI` is defined in Standard ECMA-35. /// The use of `SI` is defined in Standard [ECMA-35][ecma-35].
/// ///
/// ## Note /// ## Note
/// ///
/// `SO` is used in 7-bit environments only; in 8-bit environments LOCKING-SHIFT ONE (`LS1`) is used instead. /// `SO` is used in 7-bit environments only; in 8-bit environments LOCKING-SHIFT ONE ([`LS1`]) is used instead.
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const SO: ControlFunction = c0!(00 / 14); pub const SO: ControlFunction = c0!(00 / 14);
/// Start of Heading. /// Start of Heading.
/// ///
/// `SOH` is used to indicate the beginning of a heading. /// `SOH` is used to indicate the beginning of a heading.
/// ///
/// The use of `SOH` is defined in ISO 1745. /// The use of `SOH` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const SOH: ControlFunction = c0!(00 / 01); pub const SOH: ControlFunction = c0!(00 / 01);
/// Start of Text. /// Start of Text.
/// ///
/// `STX` is used to indicate the beginning of a text and the ned of a heading. /// `STX` is used to indicate the beginning of a text and the ned of a heading.
/// ///
/// The use of `STX` is defined in ISO 1745. /// The use of `STX` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const STX: ControlFunction = c0!(00 / 02); pub const STX: ControlFunction = c0!(00 / 02);
/// Substitute. /// Substitute.
@@ -320,7 +366,9 @@ pub const SUB: ControlFunction = c0!(01 / 10);
/// `SYN` is used by a synchronous transmission system in the absence of any other character (idle condition) to provide /// `SYN` is used by a synchronous transmission system in the absence of any other character (idle condition) to provide
/// a signal from which synchronism may be achieved or retained between data terminal equipment. /// a signal from which synchronism may be achieved or retained between data terminal equipment.
/// ///
/// The use of `SYN` is defined in ISO 1745. /// The use of `SYN` is defined in [ISO 1745][iso-1745].
///
/// [iso-1745]: https://www.ecma-international.org/wp-content/uploads/ECMA-16_2nd_edition_june_1973.pdf
pub const SYN: ControlFunction = c0!(01 / 06); pub const SYN: ControlFunction = c0!(01 / 06);
/// Line Tabulation. /// Line Tabulation.

131
src/c1.rs
View File

@@ -8,6 +8,18 @@
//! The 3-character escape sequence designating and invoking this c1 set is `ESC 02/06 04/00` and `ESC 02/02 F`. //! The 3-character escape sequence designating and invoking this c1 set is `ESC 02/06 04/00` and `ESC 02/02 F`.
//! see [`ANNOUNCER_SEQUENCE`], and [`ALTERNATIVE_ANNOUNCER_SEQUENCE`]. //! see [`ANNOUNCER_SEQUENCE`], and [`ALTERNATIVE_ANNOUNCER_SEQUENCE`].
//! //!
//! ## Usage
//!
//! You can use the Elements of the C1 set inside normal strings, format them with the `format!()` macro, or print
//! them with the `print!()` and `println!()` macros.
//!
//! For example, designate the C1 set, then set a character tabulation stop.
//!
//! ```
//! use ansi_control_codes::c1::{ANNOUNCER_SEQUENCE, HTS};
//! println!("{}{}", ANNOUNCER_SEQUENCE, HTS);
//! ```
//!
//! ## Overview of the C1 Set //! ## Overview of the C1 Set
//! //!
//! | Row Number | Column `04` | Column `05` | //! | Row Number | Column `04` | Column `05` |
@@ -43,7 +55,7 @@ macro_rules! c1 {
/// ///
/// ## Note /// ## Note
/// ///
/// The use of this escape sequence implies that all control function of this c1 set must be implemented. /// The use of this escape sequence implies that all control function of this C1 set must be implemented.
pub const ANNOUNCER_SEQUENCE: &'static str = ascii!(01 / 11, 02 / 06, 04 / 00); pub const ANNOUNCER_SEQUENCE: &'static str = ascii!(01 / 11, 02 / 06, 04 / 00);
/// Alternative Announcer Sequence for C1. /// Alternative Announcer Sequence for C1.
@@ -52,14 +64,14 @@ pub const ANNOUNCER_SEQUENCE: &'static str = ascii!(01 / 11, 02 / 06, 04 / 00);
/// ///
/// ## Note /// ## Note
/// ///
/// The use of this escape sequence implies that all control function of this c1 set must be implemented. /// The use of this escape sequence implies that all control function of this C1 set must be implemented.
pub const ALTERNATIVE_ANNOUNCER_SEQUENCE: &'static str = ascii!(01 / 11, 02 / 02, 04 / 06); pub const ALTERNATIVE_ANNOUNCER_SEQUENCE: &'static str = ascii!(01 / 11, 02 / 02, 04 / 06);
/// Application Program Command. /// Application Program Command.
/// ///
/// `APC` is used as the opening delimiter of a control string for application program use. The command string following /// `APC` is used as the opening delimiter of a control string for application program use. The command string following
/// may consist of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control string is closed /// may consist of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control string is closed
/// by the terminating delimiter String Terminator (`ST`). The interpretation of the command string depends on the /// by the terminating delimiter String Terminator ([`ST`]). The interpretation of the command string depends on the
/// relevant application program. /// relevant application program.
pub const APC: ControlFunction = c1!(05 / 15); pub const APC: ControlFunction = c1!(05 / 15);
@@ -88,25 +100,27 @@ pub const CSI: ControlFunction = c1!(05 / 11);
/// ///
/// `DCS` is used as the opening delimiter of a control string for device control use. The command string following may /// `DCS` is used as the opening delimiter of a control string for device control use. The command string following may
/// consist of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control string is closed by /// consist of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control string is closed by
/// the terminating delimiter STRING TERMINATOR (`ST`). /// the terminating delimiter STRING TERMINATOR ([`ST`]).
/// ///
/// The command string represents either one or more commands for the receiving device, or one or more status reports /// The command string represents either one or more commands for the receiving device, or one or more status reports
/// from the sending device. The purpose and the format of the command string are specified by the most recent /// from the sending device. The purpose and the format of the command string are specified by the most recent
/// occurrence of IDENTIFY DEVICE CONTROL STRING (`IDCS`), if any, or depend on the sending and/or the receiving device. /// occurrence of IDENTIFY DEVICE CONTROL STRING ([`IDCS`][crate::control_sequences::IDCS]), if any, or depend on the
/// sending and/or the receiving device.
pub const DCS: ControlFunction = c1!(05 / 00); pub const DCS: ControlFunction = c1!(05 / 00);
/// End Of Guarded Area. /// End Of Guarded Area.
/// ///
/// `EPA` is used to indicate that the active presentation position is the last of a string of character positions in /// `EPA` is used to indicate that the active presentation position is the last of a string of character positions in
/// the presentation component, the contents of which are protected against manual alteration, are guarded against /// the presentation component, the contents of which are protected against manual alteration, are guarded against
/// transmission or transfer, depending on the setting of GUARDED AREA TRANSFER MODE (`GATM`), and may be protected /// transmission or transfer, depending on the setting of GUARDED AREA TRANSFER MODE ([`GATM`][crate::modes::GATM]),
/// against erasure, depending on the setting of the ERASURE MODE (`ERM`). The beginning of this string is indicated /// and may be protected against erasure, depending on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
/// by START OF GUARDED AREA ([`SPA`]). /// The beginning of this string is indicated by START OF GUARDED AREA ([`SPA`]).
/// ///
/// ## Note /// ## Note
/// ///
/// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`], /// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`],
/// [`SSA`]) should not be used within an `SRS` string or an `SDS` string. /// [`SSA`]) should not be used within an [`SRS`][crate::control_sequences::SRS] string or an
/// [`SDS`][crate::control_sequences::SDS] string.
pub const EPA: ControlFunction = c1!(05 / 07); pub const EPA: ControlFunction = c1!(05 / 07);
/// End Of Selected Area. /// End Of Selected Area.
@@ -119,7 +133,8 @@ pub const EPA: ControlFunction = c1!(05 / 07);
/// ## Note /// ## Note
/// ///
/// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`], /// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`],
/// [`SSA`]) should not be used within an `SRS` string or an `SDS` string. /// [`SSA`]) should not be used within an [`SRS`][crate::control_sequences::SRS] string or an
/// [`SDS`][crate::control_sequences::SDS] string.
pub const ESA: ControlFunction = c1!(04 / 07); pub const ESA: ControlFunction = c1!(04 / 07);
/// Character Tabulation With Justification. /// Character Tabulation With Justification.
@@ -135,48 +150,54 @@ pub const HTJ: ControlFunction = c1!(04 / 09);
/// `HTS` causes a character tabulation stop to be set at the active presentation position in the presentation /// `HTS` causes a character tabulation stop to be set at the active presentation position in the presentation
/// component. /// component.
/// ///
/// The number of liens affected depends on the setting of the TABULATION STOP MODE (`TSM`). /// The number of liens affected depends on the setting of the TABULATION STOP MODE ([`TSM`][crate::modes::TSM]).
pub const HTS: ControlFunction = c1!(04 / 08); pub const HTS: ControlFunction = c1!(04 / 08);
/// Message Waiting. /// Message Waiting.
/// ///
/// `MW` is used to set a message waiting indicator in the receiving device. An appropriate acknowledgement to the /// `MW` is used to set a message waiting indicator in the receiving device. An appropriate acknowledgement to the
/// receipt of `MW` may be given by using DEVICE STATUS REPORT (`DSR`). /// receipt of `MW` may be given by using DEVICE STATUS REPORT ([`DSR`][crate::control_sequences::DSR]).
pub const MW: ControlFunction = c1!(05 / 05); pub const MW: ControlFunction = c1!(05 / 05);
/// No Break Here. /// No Break Here.
/// ///
/// `NBH` is used to indicate a point where a line break shall not occur when text is formatted. `NBH` may occur between /// `NBH` is used to indicate a point where a line break shall not occur when text is formatted. `NBH` may occur between
/// two graphic characters either or both of which may be SPACE. /// two graphic characters either or both of which may be `SPACE`.
pub const NBH: ControlFunction = c1!(04 / 03); pub const NBH: ControlFunction = c1!(04 / 03);
/// Next Line. /// Next Line.
/// ///
/// The effect of `NEL` depends on the setting of the DEVICE COMPONENT SELECT MODE (`DCSM`) and on the parameter value /// The effect of `NEL` depends on the setting of the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) and on
/// of SELECT IMPLICIT MOVEMENT DIRECTION (`SIMD`). /// the parameter value of SELECT IMPLICIT MOVEMENT DIRECTION ([`SIMD`][crate::control_sequences::SIMD]).
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION and with a parameter value of `SIMD` equal to /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION and with a parameter value
/// `0`, `NEL` causes the active presentation position to be moved to the line home position of the following line in /// of [`SIMD`][crate::control_sequences::SIMD] equal to
/// the presentation component. The line home position is established by the parameter value of SET LINE HOME (`SLH`). /// [`Normal`][crate::control_sequences::MovementDirection::Normal], `NEL` causes the active presentation position to be
/// moved to the line home position of the following line in the presentation component. The line home position is
/// established by the parameter value of SET LINE HOME ([`SLH`][crate::control_sequences::SLH]).
/// ///
/// With a parameter value of `SIMD` equal to `1`, `NEL` causes the active presentation position to be moved to the line /// With a parameter value of [`SIMD`][crate::control_sequences::SIMD] equal to
/// limit position of the following line in the presentation component. The line limit position is established by the /// [`Opposite`][crate::control_sequences::MovementDirection::Opposite], `NEL` causes the active presentation position
/// parameter value of SET LINE LIMIT (`SLL`). /// to be moved to the line limit position of the following line in the presentation component. The line limit position
/// is established by the parameter value of SET LINE LIMIT ([`SLL`][crate::control_sequences::SLL]).
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA and with a parameter value of `SIMD` equal to `0`, `NEL` /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA and with a parameter value of
/// causes the active data position to be moved to the line home position of the following line in the data component. /// [`SIMD`][crate::control_sequences::SIMD] equal to [`Normal`][crate::control_sequences::MovementDirection::Normal],
/// The line home position is established by the parameter value of SET LINE HOME (`SLH`). /// `NEL` causes the active data position to be moved to the line home position of the following line in the data
/// component. The line home position is established by the parameter value of SET LINE HOME
/// ([`SLH`][crate::control_sequences::SLH]).
/// ///
/// With a parameter value of `SIMD` equal to `1`, `NEL` causes the active data position to be moved to the line limit /// With a parameter value of [`SIMD`][crate::control_sequences::SIMD] equal to
/// position of the following line in the data component. The line limit position is established by the parameter value /// [`Opposite`][crate::control_sequences::MovementDirection::Opposite], `NEL` causes the active data position to be
/// of SET LINE LIMIT (`SLL`). /// moved to the line limit position of the following line in the data component. The line limit position is established
/// by the parameter value of SET LINE LIMIT ([`SLL`][crate::control_sequences::SLL]).
pub const NEL: ControlFunction = c1!(04 / 05); pub const NEL: ControlFunction = c1!(04 / 05);
/// Operating System Command /// Operating System Command
/// ///
/// `OSC` is used as the opening delimiter of a control string for operating system use. The command string following /// `OSC` is used as the opening delimiter of a control string for operating system use. The command string following
/// may consist of a sequence of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control /// may consist of a sequence of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control
/// string is closed by the terminating delimiter STRING TERMINATOR (`ST`). The interpretation of the command string /// string is closed by the terminating delimiter STRING TERMINATOR ([`ST`]). The interpretation of the command string
/// depends on the relevant operating system. /// depends on the relevant operating system.
pub const OSC: ControlFunction = c1!(05 / 13); pub const OSC: ControlFunction = c1!(05 / 13);
@@ -185,10 +206,10 @@ pub const OSC: ControlFunction = c1!(05 / 13);
/// `PLD` causes the active presentation position to be moved in the presentation component to the corresponding /// `PLD` causes the active presentation position to be moved in the presentation component to the corresponding
/// position of an imaginary line with a partial offset in the direction of the line progression. This offset should be /// position of an imaginary line with a partial offset in the direction of the line progression. This offset should be
/// sufficient either to image following characters as subscripts until the first following occurrence of PARTIAL LINE /// sufficient either to image following characters as subscripts until the first following occurrence of PARTIAL LINE
/// BACKWARD (`PLU`) in the data stream, or, if preceding characters were imaged as superscripts, to restore imaging /// BACKWARD ([`PLU`]) in the data stream, or, if preceding characters were imaged as superscripts, to restore imaging
/// of following characters to the active line (the line that contains the active presentation position). /// of following characters to the active line (the line that contains the active presentation position).
/// ///
/// Any interactions between `PLD` and format effectors other than `PLU` are not defined. /// Any interactions between `PLD` and format effectors other than [`PLU`] are not defined.
pub const PLD: ControlFunction = c1!(04 / 11); pub const PLD: ControlFunction = c1!(04 / 11);
/// Partial Line Backwards. /// Partial Line Backwards.
@@ -196,18 +217,18 @@ pub const PLD: ControlFunction = c1!(04 / 11);
/// `PLU` causes the active presentation position to be moved in the presentation component to the corresponding /// `PLU` causes the active presentation position to be moved in the presentation component to the corresponding
/// position of an imaginary line with a partial offset in the direction opposite to that of the line progression. This /// position of an imaginary line with a partial offset in the direction opposite to that of the line progression. This
/// offset should be sufficient either to image following characters as superscripts until the first following /// offset should be sufficient either to image following characters as superscripts until the first following
/// occurrence of PARTIAL LINE FORWARD (`PLD`) in the data stream, or, if preceding characters were imaged as /// occurrence of PARTIAL LINE FORWARD ([`PLD`]) in the data stream, or, if preceding characters were imaged as
/// subscripts, to restore imaging of following characters to the active line (the line that contains the active /// subscripts, to restore imaging of following characters to the active line (the line that contains the active
/// presentation position). /// presentation position).
/// ///
/// Any interactions between `PLU` and format effectors other than `PLD` are not defined. /// Any interactions between `PLU` and format effectors other than [`PLD`] are not defined.
pub const PLU: ControlFunction = c1!(04 / 12); pub const PLU: ControlFunction = c1!(04 / 12);
/// Privacy Message. /// Privacy Message.
/// ///
/// `PM` is used as the opening delimiter of a control string for privacy message use. The command string following may /// `PM` is used as the opening delimiter of a control string for privacy message use. The command string following may
/// consist of a sequence of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control string /// consist of a sequence of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control string
/// is closed by the terminating delimiter STRING TERMINATOR (`ST`). The interpretation of the command string depends /// is closed by the terminating delimiter STRING TERMINATOR ([`ST`]). The interpretation of the command string depends
/// on the relevant privacy discipline. /// on the relevant privacy discipline.
pub const PM: ControlFunction = c1!(05 / 14); pub const PM: ControlFunction = c1!(05 / 14);
@@ -225,11 +246,12 @@ pub const PU2: ControlFunction = c1!(05 / 02);
/// Reverse Line Feed. /// Reverse Line Feed.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `RI` causes the active presentation position to /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `RI` causes the active
/// be moved in the presentation component to the corresponding character position of the preceding line feed. /// presentation position to be moved in the presentation component to the corresponding character position of the
/// preceding line feed.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `RI` causes the active data position to be moved in the /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `RI` causes the active data
/// data component to the corresponding character position of the preceding line. /// position to be moved in the data component to the corresponding character position of the preceding line.
pub const RI: ControlFunction = c1!(04 / 13); pub const RI: ControlFunction = c1!(04 / 13);
/// Single Character Introducer. /// Single Character Introducer.
@@ -242,8 +264,8 @@ pub const SCI: ControlFunction = c1!(05 / 10);
/// Start of String. /// Start of String.
/// ///
/// `SOS` is used as the opening delimiter of a control string. The character string following may consist of any bit /// `SOS` is used as the opening delimiter of a control string. The character string following may consist of any bit
/// combination, except those representing `SOS` or STRING TERMINATOR (`ST`). The control string is closed by the /// combination, except those representing `SOS` or STRING TERMINATOR ([`ST`]). The control string is closed by the
/// terminating delimiter STRING TERMINATOR (`ST`). The interpretation of the character string depends on the /// terminating delimiter STRING TERMINATOR ([`ST`]). The interpretation of the character string depends on the
/// application. /// application.
pub const SOS: ControlFunction = c1!(05 / 08); pub const SOS: ControlFunction = c1!(05 / 08);
@@ -251,21 +273,22 @@ pub const SOS: ControlFunction = c1!(05 / 08);
/// ///
/// `SPA` is used to indicate that the active presentation position is the first of a string of character positions in /// `SPA` is used to indicate that the active presentation position is the first of a string of character positions in
/// the presentation component, the contents of which are protected against manual alteration, are guarded against /// the presentation component, the contents of which are protected against manual alteration, are guarded against
/// transmission or transfer, depending on the setting of the GUARDED AREA TRANSFER MODE (`GATM`) and may be protected /// transmission or transfer, depending on the setting of the GUARDED AREA TRANSFER MODE ([`GATM`][crate::modes::GATM])
/// against erasure, depending on the setting of the ERASURE MODE (`ERM`). The end of this string is indicated by /// and may be protected against erasure, depending on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
/// END OF GUARDED AREA (`EPA`). /// The end of this string is indicated by END OF GUARDED AREA (`EPA`).
/// ///
/// ## Note /// ## Note
/// ///
/// The control functions for area definition (`DAQ`, `EPA`, `ESA`, `SPA`, `SSA`) should not be used within an `SRS` /// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`],
/// string or an `SDS` string. /// [`SSA`]) should not be used within an [`SRS`][crate::control_sequences::SRS] string or an
/// [`SDS`][crate::control_sequences::SDS] string.
pub const SPA: ControlFunction = c1!(05 / 06); pub const SPA: ControlFunction = c1!(05 / 06);
/// Start of Selected Area. /// Start of Selected Area.
/// ///
/// `SSA` is used to indicate that the active presentation position is the first of a string of character positions in /// `SSA` is used to indicate that the active presentation position is the first of a string of character positions in
/// the presentation component, the contents of which are eligible to be transmitted in the form of a data stream or /// the presentation component, the contents of which are eligible to be transmitted in the form of a data stream or
/// transferred to an auxilliary input/output device. /// transferred to an auxiliary input/output device.
/// ///
/// The end of this string is indicated by END OF SELECTED AREA ([`ESA`]). The string of characters actually transmitted /// The end of this string is indicated by END OF SELECTED AREA ([`ESA`]). The string of characters actually transmitted
/// or transferred depends on the setting of the GUARDED AREA TRANSFER MODE ([`GATM`][crate::modes::GATM]) and on any /// or transferred depends on the setting of the GUARDED AREA TRANSFER MODE ([`GATM`][crate::modes::GATM]) and on any
@@ -274,8 +297,9 @@ pub const SPA: ControlFunction = c1!(05 / 06);
/// ///
/// ## Note /// ## Note
/// ///
/// The control functions for area definition (`DAQ`, `EPA`, `ESA`, `SPA`, `SSA`) should not be used within an `SRS` /// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`],
/// string or an `SDS` string. /// [`SSA`]) should not be used within an [`SRS`][crate::control_sequences::SRS] string or an
/// [`SDS`][crate::control_sequences::SDS] string.
pub const SSA: ControlFunction = c1!(04 / 06); pub const SSA: ControlFunction = c1!(04 / 06);
/// Single-Shift Two. /// Single-Shift Two.
@@ -283,7 +307,9 @@ pub const SSA: ControlFunction = c1!(04 / 06);
/// `SS2` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data /// `SS2` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `SS2` is defined in Standard ECMA-35. /// The use of `SS2` is defined in Standard [ECMA-35][ecma-35].
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const SS2: ControlFunction = c1!(04 / 14); pub const SS2: ControlFunction = c1!(04 / 14);
/// Single-Shift Three. /// Single-Shift Three.
@@ -291,13 +317,16 @@ pub const SS2: ControlFunction = c1!(04 / 14);
/// `SS3` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data /// `SS3` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `SS3` is defined in Standard ECMA-35. /// The use of `SS3` is defined in Standard [ECMA-35][ecma-35].
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const SS3: ControlFunction = c1!(04 / 15); pub const SS3: ControlFunction = c1!(04 / 15);
/// String Terminator. /// String Terminator.
/// ///
/// `ST` is used as the closing delimiter of a control string opened by APPLICATION PROGRAM COMMAND (`APC`), DEVICE /// `ST` is used as the closing delimiter of a control string opened by APPLICATION PROGRAM COMMAND ([`APC`]), DEVICE
/// CONTROL STRING (`DCS`), OPERATING SYSTEM COMMAND (`OSC`), PRIVACY MESSAGE (`PM`), or START OF STRING (`SOS`). /// CONTROL STRING ([`DCS`]), OPERATING SYSTEM COMMAND ([`OSC`]), PRIVACY MESSAGE ([`PM`]), or START OF STRING
/// ([`SOS`]).
pub const ST: ControlFunction = c1!(05 / 12); pub const ST: ControlFunction = c1!(05 / 12);
/// Set Transmit State. /// Set Transmit State.

90
src/categories.rs Normal file
View File

@@ -0,0 +1,90 @@
//! This module re-exports categories of control functions.
/// All Control Functions that are Categorized as Delimiters.
pub mod delimiters {
pub use crate::c1::{APC, DCS, OSC, PM, SOS, ST};
pub use crate::independent_control_functions::CMD;
}
/// All Control Functions that are Categorized as Introducers.
pub mod introducers {
pub use crate::c0::ESC;
pub use crate::c1::{CSI, SCI};
}
/// All Control Functions that are Categorized as Shift Functions.
pub mod shift_functions {
pub use crate::c0::{LS0, LS1, SI, SO};
pub use crate::c1::{SS2, SS3};
pub use crate::independent_control_functions::{LS1R, LS2, LS2R, LS3, LS3R};
}
/// All Control Functions that are Categorized as Format Effectors.
pub mod format_effectors {
pub use crate::c0::{BS, CR, FF, HT, LF, VT};
pub use crate::c1::{HTJ, HTS, NEL, PLD, PLU, RI, VTS};
pub use crate::control_sequences::{
HPA, HPB, HPR, HVP, PPA, PPB, PPR, TBC, TSR, VPA, VPB, VPR,
};
}
/// All Control Functions that are Categorized as Presentation Control Functions.
pub mod presentation_control_functions {
pub use crate::c1::{BPH, NBH};
pub use crate::control_sequences::{
DTA, FNT, GCC, GSM, GSS, JFY, PEC, PFS, PTX, QUAD, SACS, SAPV, SCO, SCP, SCS, SDS, SGR,
SHS, SIMD, SLH, SLL, SLS, SPD, SPH, SPI, SPL, SPQR, SRCS, SRS, SSU, SSW, STAB, SVS, TAC,
TALE, TATE, TCC, TSS,
};
}
/// All Control Functions that are Categorized as Editor Functions.
pub mod editor_functions {
pub use crate::control_sequences::{DCH, DL, EA, ECH, ED, EF, EL, ICH, IL};
}
/// All Control Functions that are Categorized as Cursor Control Functions.
pub mod cursor_control_functions {
pub use crate::control_sequences::{
CBT, CHA, CHT, CNL, CPL, CTC, CUB, CUD, CUF, CUP, CUU, CVT,
};
}
/// All Control Functions that are Categorized as Display Control Functions.
pub mod display_control_functions {
pub use crate::control_sequences::{NP, PP, SD, SL, SR, SU};
}
/// All Control Functions that are Categorized as Device Control Functions.
pub mod device_control_functions {
pub use crate::c0::{DC1, DC2, DC3, DC4};
}
/// All Control Functions that are Categorized as Information Separators.
pub mod information_separators {
pub use crate::c0::{IS1, IS2, IS3, IS4};
}
/// All Control Functions that are Categorized as Area Definition Functions.
pub mod area_definition_functions {
pub use crate::c1::{EPA, ESA, SPA, SSA};
pub use crate::control_sequences::DAQ;
}
/// All Control Functions that are Categorized as Mode Setting Functions.
pub mod mode_setting_functions {
pub use crate::control_sequences::{RM, SM};
}
/// All Control Functions that are Categorized as Transmission Control Functions.
pub mod transmission_control_functions {
pub use crate::c0::{ACK, DLE, ENQ, EOT, ETB, ETX, NAK, SOH, STX, SYN};
}
/// All Control Functions that are Categorized as Miscellaneous Control Functions.
pub mod miscellaneous_control_functions {
pub use crate::c0::{BEL, CAN, EM, NUL, SUB};
pub use crate::c1::{CCH, MW, PU1, PU2, STS};
pub use crate::control_sequences::{CPR, DA, DSR, FNK, IDCS, IGS, MC, REP, SEE, SEF};
pub use crate::independent_control_functions::{DMI, EMI, INT, RIS};
}

View File

@@ -5,6 +5,18 @@
//! combinations identifying the control function. The control function `CSI` itself is an element of the //! combinations identifying the control function. The control function `CSI` itself is an element of the
//! [C1][crate::c1] set. //! [C1][crate::c1] set.
//! //!
//! ## Usage
//!
//! You can use the control sequences inside normal strings, format them with the `format!()` macro, or print
//! them with the `print!()` and `println!()` macros.
//!
//! For example, move the cursor to line 5, character 13:
//!
//! ```
//! use ansi_control_codes::control_sequences::CUP;
//! print!("{}", CUP(Some(5), Some(13)));
//! ```
//!
//! ## Overview of the Control Sequences //! ## Overview of the Control Sequences
//! //!
//! ### Without Intermediate Bytes //! ### Without Intermediate Bytes
@@ -12,7 +24,7 @@
//! | Row Number | Column `04` | Column `05` | Column `06` | //! | Row Number | Column `04` | Column `05` | Column `06` |
//! | ---------: | :---------: | :---------: | :---------: | //! | ---------: | :---------: | :---------: | :---------: |
//! | `00` | [`ICH`] | [`DCH`] | [`HPA`] | //! | `00` | [`ICH`] | [`DCH`] | [`HPA`] |
//! | `01` | [`CUU`] | [`SSE`] | [`HPR`] | //! | `01` | [`CUU`] | [`SEE`] | [`HPR`] |
//! | `02` | [`CUD`] | [`CPR`] | [`REP`] | //! | `02` | [`CUD`] | [`CPR`] | [`REP`] |
//! | `03` | [`CUF`] | [`SU`] | [`DA`] | //! | `03` | [`CUF`] | [`SU`] | [`DA`] |
//! | `04` | [`CUB`] | [`SD`] | [`VPA`] | //! | `04` | [`CUB`] | [`SD`] | [`VPA`] |
@@ -193,15 +205,15 @@ pub fn CPL(n: Option<u32>) -> ControlFunction {
/// Active Position Report. /// Active Position Report.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `CPR` is used to report the active presentation /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `CPR` is used to report
/// position of the sending device as residing in the presentation component at the `n`-th line position according to /// the active presentation position of the sending device as residing in the presentation component at the `n`-th line
/// the line progression and at the `m`-th character position according to the character path. /// position according to the line progression and at the `m`-th character position according to the character path.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `CPR` is used to report the active data position of the /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `CPR` is used to report the
/// sending device as residing in the data component at the `n`-th line position according to the line progression and /// active data position of the sending device as residing in the data component at the `n`-th line position according
/// at the `m`-th character position according to the character progression. /// to the line progression and at the `m`-th character position according to the character progression.
/// ///
/// `CPR` may be solicited by a DEVICE STATUS REPORT (`DSR`) or be sent unsolicited. /// `CPR` may be solicited by a DEVICE STATUS REPORT ([`DSR`]) or be sent unsolicited.
/// ///
/// Default value for `n` and `m` is `1`. /// Default value for `n` and `m` is `1`.
pub fn CPR(n: Option<u32>, m: Option<u32>) -> ControlFunction { pub fn CPR(n: Option<u32>, m: Option<u32>) -> ControlFunction {
@@ -382,9 +394,9 @@ pub enum AreaQualification {
/// position of a qualified area. The last character position of the qualified area is the character position in the /// position of a qualified area. The last character position of the qualified area is the character position in the
/// presentation component immediately preceding the first character position of the following qualified area. /// presentation component immediately preceding the first character position of the following qualified area.
/// ///
/// The control function operates independently of the setting of the TABULATION STOP MODE (`TSM`). The character /// The control function operates independently of the setting of the TABULATION STOP MODE ([`TSM`][crate::modes::TSM]).
/// tabulation stop set by parameter value [`AreaQualification::SetCharacterTabulationStop`] applies to the active line /// The character tabulation stop set by parameter value [`AreaQualification::SetCharacterTabulationStop`] applies to
/// only. /// the active line only.
/// ///
/// The default value for `s` is [`AreaQualification::UnprotectedUnguarded]. /// The default value for `s` is [`AreaQualification::UnprotectedUnguarded].
/// ///
@@ -398,22 +410,23 @@ pub fn DAQ(s: Option<AreaQualification>) -> ControlFunction {
/// Delete Character. /// Delete Character.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DSCM`) is set to PRESENTATION, `DCH` causes the contents of the active /// If the DEVICE COMPONENT SELECT MODE ([`DSCM`][crate::modes::DCSM]) is set to PRESENTATION, `DCH` causes the contents
/// presentation position and, depending on the setting of the CHARACTER EDITING MODE (`HEM`), the contents of the `n-1` /// of the active presentation position and, depending on the setting of the CHARACTER EDITING MODE
/// preceding or following character positions to be removed from the presentation component. The resulting gap is /// ([`HEM`][crate::modes::HEM]), the contents of the `n-1` preceding or following character positions to be removed
/// closed by shifting the contents of the adjacent character positions towards the active presentation position. At the /// from the presentation component. The resulting gap is closed by shifting the contents of the adjacent character
/// other end of the shifted part, `n` character positions are put into the erased state. /// positions towards the active presentation position. At the other end of the shifted part, `n` character positions
/// are put into the erased state.
/// ///
/// The extent of the shifted part is established by SELECT EDITING EXTEND (`SEE`). /// The extent of the shifted part is established by SELECT EDITING EXTEND ([`SEE`]).
/// ///
/// The effect of `CDH` on the start or end of a selected area, the start or end of a qualified area, or a tabulation /// The effect of `DCH` on the start or end of a selected area, the start or end of a qualified area, or a tabulation
/// stop in the shifted part is undefined. /// stop in the shifted part is undefined.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `DCH` causes the contents of the active data position /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `DCH` causes the contents of the
/// and, depending on the setting of the CHARACTER EDITING MODE (`HEM`), the contents of the `n-1` preceding or /// active data position and, depending on the setting of the CHARACTER EDITING MODE ([`HEM`][crate::modes::HEM]), the
/// following character positions to be removed from the data component. The resulting gap is closed by shifting the /// contents of the `n-1` preceding or following character positions to be removed from the data component. The
/// contents of the adjacent character positions towards the active data position. At the other end of the shifted part, /// resulting gap is closed by shifting the contents of the adjacent character positions towards the active data
/// `n` character positions are put into the erased state. /// position. At the other end of the shifted part, `n` character positions are put into the erased state.
/// ///
/// Default value for `n` is `1`. /// Default value for `n` is `1`.
pub fn DCH(n: Option<u32>) -> ControlFunction { pub fn DCH(n: Option<u32>) -> ControlFunction {
@@ -422,27 +435,29 @@ pub fn DCH(n: Option<u32>) -> ControlFunction {
/// Delete Line. /// Delete Line.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `DL` causes the contents of the active line /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `DL` causes the contents
/// (the line that contains the active presentation position) and, depending on the setting of the LINE EDITING MODE /// of the active line (the line that contains the active presentation position) and, depending on the setting of the
/// (`VEM`), the contents of the `n-1` preceding or following lines to be removed from the presentation component. The /// LINE EDITING MODE ([`VEM`][crate::modes::VEM]), the contents of the `n-1` preceding or following lines to be removed
/// resulting gap is closed by shifting the contents of a number of adjacent lines towards the active line. At the other /// from the presentation component. The resulting gap is closed by shifting the contents of a number of adjacent lines
/// end of the shifted part, `n` lines are put into the erased state. /// towards the active line. At the other end of the shifted part, `n` lines are put into the erased state.
/// ///
/// The active presentation position is moved to the line home position in the active line. The line home position is /// The active presentation position is moved to the line home position in the active line. The line home position is
/// established by the parameter value of SET LINE HOME (`SLH`). If the TABULATION STOP MODE (`TSM`) is set to SINGLE, /// established by the parameter value of SET LINE HOME ([`SLH`]). If the TABULATION STOP MODE
/// character tabulation stops are cleared in the lines that are put into the erased state. /// ([`TSM`][crate::modes::TSM]) is set to SINGLE, character tabulation stops are cleared in the lines that are put into
/// the erased state.
/// ///
/// The extent of the shifted part is established by SELECT EDITING EXTEND (`SEE`). /// The extent of the shifted part is established by SELECT EDITING EXTEND ([`SEE`]).
/// ///
/// Any occurrences of the start or end of a selected area, the start or end of a qualified area, or a tabulation stop /// Any occurrences of the start or end of a selected area, the start or end of a qualified area, or a tabulation stop
/// in the shifted part, are also shifted. /// in the shifted part, are also shifted.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `DL` causes the contents of the active line (the line /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `DL` causes the contents of the
/// that contains the active data position) and, depending on the setting of the LINE EDITING MODE (`VEM`), the contents /// active line (the line that contains the active data position) and, depending on the setting of the LINE EDITING MODE
/// of the `n-1` preceding or following lines to be removed from the data component. The resulting gap is closed by /// ([`VEM`][crate::modes::VEM]), the contents of the `n-1` preceding or following lines to be removed from the data
/// shifting the contents of a number of adjacent lines towards the active line. At the other end of the shifted part, /// component. The resulting gap is closed by shifting the contents of a number of adjacent lines towards the active
/// `n` lines are put into the erased state. The active data position is moved to the lines home position in the active /// line. At the other end of the shifted part, `n` lines are put into the erased state. The active data position is
/// line. The line home position is established by the parameter value of SET LINE HOME (`SLH`). /// moved to the lines home position in the active line. The line home position is established by the parameter value of
/// SET LINE HOME ([`SLH`]).
/// ///
/// The default value for `n` is `1`. /// The default value for `n` is `1`.
pub fn DL(n: Option<u32>) -> ControlFunction { pub fn DL(n: Option<u32>) -> ControlFunction {
@@ -456,23 +471,23 @@ pub enum DeviceStatusReport {
#[default] #[default]
Ready = 0, Ready = 0,
/// The device is busy, another `DSR` must be requested later. /// The device is busy, another [`DSR`] must be requested later.
BusyRepeat, BusyRepeat,
/// The device is busy, another `DSR` will be sent later. /// The device is busy, another [`DSR`] will be sent later.
BusyLater, BusyLater,
/// Some malfunction detected, another `DSR` must be requested later. /// Some malfunction detected, another [`DSR`] must be requested later.
MalfunctionRepeat, MalfunctionRepeat,
/// Some malfunction detected, another `DSR` will be sent later. /// Some malfunction detected, another [`DSR`] will be sent later.
MalfunctionLater, MalfunctionLater,
/// A device status report is requested. /// A device status report is requested.
RequestDeviceStatusReport, RequestDeviceStatusReport,
/// A report of the active presentation position or of the active data position in the form of ACTIVE POSITION /// A report of the active presentation position or of the active data position in the form of ACTIVE POSITION
/// REPORT (`CPR`) is requested. /// REPORT ([`CPR`]) is requested.
RequestActivePositionReport, RequestActivePositionReport,
} }
@@ -523,16 +538,16 @@ pub enum EraseArea {
/// Erase in Area. /// Erase in Area.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `EA` causes some or all character positions in /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `EA` causes some or all
/// the active qualified area (the qualified area in the presentation component which contains the active presentation /// character positions in the active qualified area (the qualified area in the presentation component which contains
/// the active presentation position) to be put into the erased state, depending on the parameter value.
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `EA` causes some or all character
/// positions in the active qualified area (the qualified area in the data component which contains the active data
/// position) to be put into the erased state, depending ont he parameter value. /// position) to be put into the erased state, depending ont he parameter value.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `EA` causes some or all character positions in the
/// active qualified area (the qualified area in the data component which contains the active data position) to be put
/// into the erased state, depending ont he parameter value.
///
/// Whether the character positions of protected areas are put into the erased state, or the character positions of /// Whether the character positions of protected areas are put into the erased state, or the character positions of
/// unprotected areas only, depends on the setting of ERASURE MODE (`ERM`). /// unprotected areas only, depends on the setting of ERASURE MODE ([`ERM`][crate::modes::ERM]).
/// ///
/// The default value of `s` is [`EraseArea::ActivePositionToEnd`]. /// The default value of `s` is [`EraseArea::ActivePositionToEnd`].
pub fn EA(s: Option<EraseArea>) -> ControlFunction { pub fn EA(s: Option<EraseArea>) -> ControlFunction {
@@ -541,16 +556,17 @@ pub fn EA(s: Option<EraseArea>) -> ControlFunction {
/// Erase Character. /// Erase Character.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `ECH` causes the active presentation position /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `ECH` causes the active
/// and the `n-1` following character positions in the presentation component to be put into the erased state. /// presentation position and the `n-1` following character positions in the presentation component to be put into the
/// erased state.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `ECH` causes the active data position and the `n-1` /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `ECH` causes the active data
/// following character positions in the data component to be put into the erased state. /// position and the `n-1` following character positions in the data component to be put into the erased state.
/// ///
/// Whether the character positions of protected areas are put into the erased state, or the character positions of /// Whether the character positions of protected areas are put into the erased state, or the character positions of
/// unprotected areas only, depends on the setting of the ERASURE MODE (`ERM`). /// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
/// ///
/// The default value for `n` is `1´. /// The default value for `n` is `1`.
pub fn ECH(n: Option<u32>) -> ControlFunction { pub fn ECH(n: Option<u32>) -> ControlFunction {
sequence!(05 / 08, numeric n, default 1) sequence!(05 / 08, numeric n, default 1)
} }
@@ -571,16 +587,16 @@ pub enum ErasePage {
/// Erase In Page. /// Erase In Page.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `ED` causes some or all character positions /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `ED` causes some or all
/// of the active page (the page which contains the active presentation position in the presentation component) to be /// character positions of the active page (the page which contains the active presentation position in the presentation
/// put into the erased state, depending on the parameter value. /// component) to be/ put into the erased state, depending on the parameter value.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `ED` causes some or all character positions of the /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `ED` causes some or all character
/// active page (the page which contains the active data position in the data component) to be put into the erased /// positions of the active page (the page which contains the active data position in the data component) to be put into
/// state, depending on the parameter value. /// the erased state, depending on the parameter value.
/// ///
/// Whether the character positions of protected areas are put into the erased state, or the character positions of /// Whether the character positions of protected areas are put into the erased state, or the character positions of
/// unprotected areas only, depends on the setting of the ERASURE MODE (`ERM`). /// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
/// ///
/// The default value of `s` is [`ErasePage::ActivePositionToEnd`]. /// The default value of `s` is [`ErasePage::ActivePositionToEnd`].
pub fn ED(s: Option<ErasePage>) -> ControlFunction { pub fn ED(s: Option<ErasePage>) -> ControlFunction {
@@ -603,16 +619,16 @@ pub enum EraseField {
/// Erase In Field. /// Erase In Field.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `EF` causes some or all character positions of /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `EF` causes some or all
/// the active field (the field which contains the active presentation position in the presentatio component) to be put /// character positions of the active field (the field which contains the active presentation position in the
/// presentation component) to be put into the erased state, depending on the parameter value.
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `EF` causes some or all character
/// positions of the active field (the field which contains the active data position in the data component) to be put
/// into the erased state, depending on the parameter value. /// into the erased state, depending on the parameter value.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `EF` causes some or all character positions of the
/// active field (the field which contains the active data position in the data component) to be put into the erased
/// state, depending on the parameter value.
///
/// Whether the character positions of protected areas are put into the erased state, or the character positions of /// Whether the character positions of protected areas are put into the erased state, or the character positions of
/// unprotected areas only, depends on the setting of the ERASURE MODE (`ERM`). /// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
/// ///
/// The default value for `s` is [`EraseField::ActivePositionToEnd`]. /// The default value for `s` is [`EraseField::ActivePositionToEnd`].
pub fn EF(s: Option<EraseField>) -> ControlFunction { pub fn EF(s: Option<EraseField>) -> ControlFunction {
@@ -635,16 +651,16 @@ pub enum EraseLine {
/// Erase In Line. /// Erase In Line.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `EL` causes some or all character positions of /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `EL` causes some or all
/// the active line (the line which contains the active presentation position in the presentation component) to be put /// character positions of the active line (the line which contains the active presentation position in the presentation
/// into the erased state, depending on the parameter value. /// component) to be put into the erased state, depending on the parameter value.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `EL` causes some or all character positions of the /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `EL` causes some or all character
/// active line (the line which contains the active data position in the data component) to be put into the erased /// positions of the active line (the line which contains the active data position in the data component) to be put into
/// state, depending on the parameter value. /// the erased state, depending on the parameter value.
/// ///
/// Whether the character positions of protected areas are put into the erased state, or the character positions of /// Whether the character positions of protected areas are put into the erased state, or the character positions of
/// unprotected areas only, depends on the setting of the ERASURE MODE (`ERM`). /// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
/// ///
/// The default value for `s` is [`EraseLine::ActivePositionToEnd`]. /// The default value for `s` is [`EraseLine::ActivePositionToEnd`].
pub fn EL(s: Option<EraseLine>) -> ControlFunction { pub fn EL(s: Option<EraseLine>) -> ControlFunction {
@@ -696,7 +712,7 @@ pub enum Font {
/// Font Selection. /// Font Selection.
/// ///
/// `FNT` is used to identify the character font to be selected as primary or alternative font by subsequent occurrences /// `FNT` is used to identify the character font to be selected as primary or alternative font by subsequent occurrences
/// of SELECT GRAPHIC RENDITION (`SGR`) in the data stream. /// of SELECT GRAPHIC RENDITION ([`SGR`]) in the data stream.
/// ///
/// - `s` specifies the primary or alternative font concerned. /// - `s` specifies the primary or alternative font concerned.
/// - `t` identifies the character font according to a register which is to be established. /// - `t` identifies the character font according to a register which is to be established.
@@ -745,7 +761,7 @@ pub fn GCC(s: Option<GraphicCharacterCombination>) -> ControlFunction {
/// Graphic Size Modification. /// Graphic Size Modification.
/// ///
/// `GSM` is used to modify for subsequent text the height and / or the width of all primary and alternative fonts /// `GSM` is used to modify for subsequent text the height and / or the width of all primary and alternative fonts
/// identified by FONT SELECT ([`FNT`]) and established by GRAPHIC SIZE SELECTION (`GSS`). The established values /// identified by FONT SELECT ([`FNT`]) and established by GRAPHIC SIZE SELECTION ([`GSS`]). The established values
/// remain in effect until the next occurrence of `GSM` or [`GSS`] in the data stream. /// remain in effect until the next occurrence of `GSM` or [`GSS`] in the data stream.
/// ///
/// - `h` specifies the height as a percentage of the height established by [`GSS`]. /// - `h` specifies the height as a percentage of the height established by [`GSS`].
@@ -759,13 +775,13 @@ pub fn GSM(h: Option<u32>, w: Option<u32>) -> ControlFunction {
/// Graphic Size Selection. /// Graphic Size Selection.
/// ///
/// `GSS` is used to establish for subsequent texts the height and the width of all primary and alternative fonts /// `GSS` is used to establish for subsequent texts the height and the width of all primary and alternative fonts
/// identified by FONT SELECT (`FNT`). The established values remain in effect until the next occurrence of `GSS` in the /// identified by FONT SELECT ([`FNT`]). The established values remain in effect until the next occurrence of `GSS` in the
/// data stream. /// data stream.
/// ///
/// - `n` specifies the height, the width is implicitly defined by the height. /// - `n` specifies the height, the width is implicitly defined by the height.
/// ///
/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT /// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
/// (`SSU`). /// ([`SSU`]).
pub fn GSS(n: u32) -> ControlFunction { pub fn GSS(n: u32) -> ControlFunction {
sequence!(02 / 00, 04/03, numeric n) sequence!(02 / 00, 04/03, numeric n)
} }
@@ -812,26 +828,27 @@ pub fn HVP(n: Option<u32>, m: Option<u32>) -> ControlFunction {
/// Insert Character. /// Insert Character.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `ICH` is used to prepare the insertion of `n` /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `ICH` is used to prepare
/// characters, by putting into the erased state the active presentation position and, depending on the setting of the /// the insertion of `n` characters, by putting into the erased state the active presentation position and, depending on
/// CHARACTER EDITING MODE (`HEM`), the `n-1` preceding or following character positions in the presentation component. /// the setting of the CHARACTER EDITING MODE ([`HEM`][crate::modes::HEM]), the `n-1` preceding or following character
/// The previous contents of the active presentation position and an adjacent string of character positions are shifted /// positions in the presentation component. The previous contents of the active presentation position and an adjacent
/// away from the active presentation position. The contents of `n` character positions at the other end of the shifted /// string of character positions are shifted away from the active presentation position. The contents of `n` character
/// part are removed. The active presentation position is moved to the line home position in the active line. The line /// positions at the other end of the shifted part are removed. The active presentation position is moved to the line
/// home position is established by the parameter value of SET LINE HOME (`SLH`). /// home position in the active line. The line home position is established by the parameter value of SET LINE HOME
/// ([`SLH`]).
/// ///
/// The extent of the shifted part is established by SELECT EDITING EXTENT (`SEE`). /// The extent of the shifted part is established by SELECT EDITING EXTENT ([`SEE`]).
/// ///
/// The effect of `ICH` on the start or end of a selected area, the start or end of a qualified area, or a tabulation /// The effect of `ICH` on the start or end of a selected area, the start or end of a qualified area, or a tabulation
/// stop in the shifted part is undefined. /// stop in the shifted part is undefined.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `ICH` is used to prepare the insertion of `n` /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `ICH` is used to prepare the
/// characters, by putting into the erased state the active data position and, depending on the setting of the /// insertion of `n` characters, by putting into the erased state the active data position and, depending on the setting
/// CHARACTER EDITING MODE (`HEM`), the `n-1` preceding or following character positions in the data component. The /// of the CHARACTER EDITING MODE ([`HEM`][crate::modes::HEM]), the `n-1` preceding or following character positions in
/// previous contents of the active data position and and adjacent string of character positions are shifted away from /// the data component. The previous contents of the active data position and and adjacent string of character positions
/// the active data position. The contents of `n` character positions at the other end of the shifted part are removed. /// are shifted away from the active data position. The contents of `n` character positions at the other end of the
/// The active data position is moved to the line home position in the active line. The line home position is /// shifted part are removed. The active data position is moved to the line home position in the active line. The line
/// established by the parameter value of SET LINE HOME (`SLH`). /// home position is/ established by the parameter value of SET LINE HOME ([`SLH`]).
/// ///
/// The default value for `n` is `1`. /// The default value for `n` is `1`.
pub fn ICH(n: Option<u32>) -> ControlFunction { pub fn ICH(n: Option<u32>) -> ControlFunction {
@@ -844,7 +861,9 @@ pub enum IdentifyDeviceControlString {
/// Reserved for use with the DIAGNOSTIC state of the STATUS REPORT TRANSFER MODE. /// Reserved for use with the DIAGNOSTIC state of the STATUS REPORT TRANSFER MODE.
Diagnostic, Diagnostic,
/// Reserved for Dynamically Redefinable Character Sets (`DRCS`) according to Standard ECMA-35. /// Reserved for Dynamically Redefinable Character Sets according to Standard [ECMA-35][ecma-35].
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
DynamicallyRedefinableCharacterSet, DynamicallyRedefinableCharacterSet,
/// Private command string. /// Private command string.
@@ -853,8 +872,9 @@ pub enum IdentifyDeviceControlString {
/// Identify Device Control String. /// Identify Device Control String.
/// ///
/// `IDCS` is used to specify the purpose and format of the command string of subsequent DEVICE CONTROL STRINGS (`DCS`). /// `IDCS` is used to specify the purpose and format of the command string of subsequent DEVICE CONTROL STRINGS
/// The specified purpose and format remain in effect until the next occurrence of `IDCS` in the data stream. /// ([`DCS`][crate::c1::DCS]). The specified purpose and format remain in effect until the next occurrence of `IDCS`
/// in the data stream.
/// ///
/// The format and interpretation of the command string corresponding to the parameter `s` are to be defined in /// The format and interpretation of the command string corresponding to the parameter `s` are to be defined in
/// appropriate standards. If this control function is used to identify a private command string, a private parameter /// appropriate standards. If this control function is used to identify a private command string, a private parameter
@@ -881,28 +901,29 @@ pub fn IGS(n: u32) -> ControlFunction {
/// Insert Line. /// Insert Line.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to PRESENTATION, `IL` is used to prepare the insertion of `n` /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `IL` is used to prepare
/// lines, by putting into the erased state in the presentation component the active line (the line that contains the /// the insertion of `n` lines, by putting into the erased state in the presentation component the active line
/// active presentation position) and, depending on the setting of the LINE EDITING MODE (`VEM`), the `n-1` preceding /// (the line that contains the active presentation position) and, depending on the setting of the LINE EDITING MODE
/// or following lines. The previous contents of the active line and of adjacent lines are shifted away from the active /// ([`VEM`][crate::modes::VEM]), the `n-1` preceding or following lines. The previous contents of the active line and
/// line. The contents of `n` lines at the other end of the shifted part are removed. The active presentation position /// of adjacent lines are shifted away from the active line. The contents of `n` lines at the other end of the shifted
/// is moved to the line home position in the active line. The line home position is established by the parameter value /// part are removed. The active presentation position is moved to the line home position in the active line. The line
/// of SET LINE HOME (`SLH`). /// home position is established by the parameter value of SET LINE HOME ([`SLH`]).
/// ///
/// The extent of the shifted part is established by SELECT EDITING EXTENT (`SEE`). /// The extent of the shifted part is established by SELECT EDITING EXTENT ([`SEE`]).
/// ///
/// Any occurrence of the start or end of a selected area, the start or end of a qualified area, or a tabulation stop in /// Any occurrence of the start or end of a selected area, the start or end of a qualified area, or a tabulation stop in
/// the shifted part, are also shifted. /// the shifted part, are also shifted.
/// ///
/// If the TABULATION STOP MODE (`TSM`) is set to SINGLE, character tabulation stops are cleared in the lines that are /// If the TABULATION STOP MODE ([`TSM`][crate::modes::TSM]) is set to SINGLE, character tabulation stops are cleared in
/// put into the erased state. /// the lines that are put into the erased state.
/// ///
/// If the DEVICE COMPONENT SELECT MODE (`DCSM`) is set to DATA, `IL` is used to prepare the insertion of `n` lines, by /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `IL` is used to prepare the
/// putting into the erased state in the data component the active line (the line that contains the active data /// insertion of `n` lines, by putting into the erased state in the data component the active line (the line that
/// position) and, depending on the setting of the LINE EDITING MODE (`VEM`), the `n-1` preceding or following lines. /// contains the active data position) and, depending on the setting of the LINE EDITING MODE
/// The previous contents of the active line and of adjacent lines are shifted away from the active line. The contents /// ([`VEM`][crate::modes::VEM]), the `n-1` preceding or following lines. The previous contents of the active line and
/// of `n` lines at the other end of the shifted part are removed. The active data position is moved to the line home /// of adjacent lines are shifted away from the active line. The contents of `n` lines at the other end of the shifted
/// position in the active line. The line home position is established by the parameter value of SET LINE HOME (`SLH`). /// part are removed. The active data position is moved to the line home position in the active line. The line home
/// position is established by the parameter value of SET LINE HOME ([`SLH`]).
/// ///
/// The default value for `n` is `1`. /// The default value for `n` is `1`.
pub fn IL(n: Option<u32>) -> ControlFunction { pub fn IL(n: Option<u32>) -> ControlFunction {
@@ -948,8 +969,8 @@ pub enum Justification {
/// ///
/// The end of the string to be justified is indicated by the next occurrence of `JFY` in the data stream. /// The end of the string to be justified is indicated by the next occurrence of `JFY` in the data stream.
/// ///
/// The line home position is established by the parameter value of SET LINE HOME (`SLH`). The line limit position is /// The line home position is established by the parameter value of SET LINE HOME ([`SLH`]). The line limit position is
/// established by the parameter value of SET LINE LIMIT (`SLL`). /// established by the parameter value of SET LINE LIMIT ([`SLL`]).
/// ///
/// The default value of `s` is [`Justification::None`]. /// The default value of `s` is [`Justification::None`].
pub fn JFY(s: Option<Justification>) -> ControlFunction { pub fn JFY(s: Option<Justification>) -> ControlFunction {
@@ -1009,7 +1030,7 @@ pub fn NP(n: Option<u32>) -> ControlFunction {
/// Valid parameter values to the function [`PEC`]. /// Valid parameter values to the function [`PEC`].
#[derive(Clone, Copy, PartialEq, Eq, Default)] #[derive(Clone, Copy, PartialEq, Eq, Default)]
pub enum PresentationExpandContract { pub enum PresentationExpandContract {
/// Normal, as specified by `SCS`, `SHS` or `SPI`. /// Normal, as specified by [`SCS`], [`SHS`] or [`SPI`].
#[default] #[default]
Normal = 0, Normal = 0,
@@ -1024,9 +1045,9 @@ pub enum PresentationExpandContract {
/// ///
/// `PEC` is used to establish the spacing and the extent of the graphic characters for subsequent text. The spacing is /// `PEC` is used to establish the spacing and the extent of the graphic characters for subsequent text. The spacing is
/// specified in the line as multiples of the spacing established by the most recent occurrence of SET CHARACTER SPACING /// specified in the line as multiples of the spacing established by the most recent occurrence of SET CHARACTER SPACING
/// (`SCS`) or of SELECT CHARACTER SPACING (`SHS`) or of SPACING INCREMENT (`SPI`) in the data stream. The extent of the /// ([`SCS`]) or of SELECT CHARACTER SPACING ([`SHS`]) or of SPACING INCREMENT ([`SPI`]) in the data stream. The extent
/// characters is implicitly established by these control functions. The established spacing and the extent remain in /// of the characters is implicitly established by these control functions. The established spacing and the extent
/// effect until the next occurrence of `PEC`, of `SCS`, of `SHS` or of `SPI` in the data stream. /// remain in effect until the next occurrence of `PEC`, of [`SCS`], of [`SHS`] or of [`SPI`] in the data stream.
/// ///
/// The default value for `s` is [`PresentationExpandContract::Normal`]. /// The default value for `s` is [`PresentationExpandContract::Normal`].
pub fn PEC(s: Option<PresentationExpandContract>) -> ControlFunction { pub fn PEC(s: Option<PresentationExpandContract>) -> ControlFunction {
@@ -1089,12 +1110,12 @@ pub enum PageFormat {
/// Page Format Selection /// Page Format Selection
/// ///
/// `PFS` is used to establish the available area for the imaging of pages of text based on paper size. The pages are /// `PFS` is used to establish the available area for the imaging of pages of text based on paper size. The pages are
/// introduced by the subsequent occurrence of FORM FEED (`FF`) in the data stream. /// introduced by the subsequent occurrence of FORM FEED ([`FF`][crate::c0::FF]) in the data stream.
/// ///
/// The established image area remains in effect until the next occurrence of `PFS` in the data stream. /// The established image area remains in effect until the next occurrence of `PFS` in the data stream.
/// ///
/// The page home position is established by the parameter value of SET PAGE HOME (`SPH`), the page limit position is /// The page home position is established by the parameter value of SET PAGE HOME ([`SPH`]), the page limit position is
/// established by the parameter value of SET PAGE LIMIT (`SPL`). /// established by the parameter value of SET PAGE LIMIT ([`SPL`]).
/// ///
/// The default value for `s` is [`PageFormat::TallBasicText`]. /// The default value for `s` is [`PageFormat::TallBasicText`].
pub fn PFS(s: Option<PageFormat>) -> ControlFunction { pub fn PFS(s: Option<PageFormat>) -> ControlFunction {
@@ -1182,7 +1203,7 @@ pub enum ParallelText {
/// `PTX` with a parameter value of [`ParallelText::End`] indicates the end of the strings of text intended to be /// `PTX` with a parameter value of [`ParallelText::End`] indicates the end of the strings of text intended to be
/// presented in parallel with one another. /// presented in parallel with one another.
/// ///
/// The default value for `s` is [`ParallelText::End]`. /// The default value for `s` is [`ParallelText::End`].
/// ///
/// ## Note /// ## Note
/// ///
@@ -1241,13 +1262,14 @@ pub enum Alignment {
/// according to the layout specified by the parameter value, see [`Alignment`]. /// according to the layout specified by the parameter value, see [`Alignment`].
/// ///
/// The beginning of the string to be positioned is indicated by the preceding occurrence in the data stream of either /// The beginning of the string to be positioned is indicated by the preceding occurrence in the data stream of either
/// `QUAD` or one of the following formator functions: FORM FEED (`FF`), CHARACTER AND LINE POSITION (`HVP`), LINE FEED /// `QUAD` or one of the following formator functions: FORM FEED ([`FF`][crate::c0::FF]), CHARACTER AND LINE POSITION
/// (`LF`), NEXT LINE (`NEL`), PAGE POSITION ABSOLUTE (`PPA`), PAGE POSITION BACKWARD (`PPB`), PAGE POSITION FORWARD /// ([`HVP`]), LINE FEED ([`LF`][crate::c0::LF]), NEXT LINE ([`NEL`][crate::c1::NEL]), PAGE POSITION ABSOLUTE
/// (`PPR`), REVERSE LINE FEED (`RI`), LINE POSITION ABSOLUTE (`VPA`), LINE POSITION BACKWARD (`VPB`), LINE POSITION /// ([`PPA`]), PAGE POSITION BACKWARD ([`PPB`]), PAGE POSITION FORWARD ([`PPR`]), REVERSE LINE FEED
/// FORWARD (`VPR`), or LINE TABULATION (`VT`). /// ([`RI`][crate::c1::RI]), LINE POSITION ABSOLUTE ([`VPA`]), LINE POSITION BACKWARD ([`VPB`]), LINE POSITION
/// FORWARD ([`VPR`]), or LINE TABULATION ([`VT`][crate::c0::VT]).
/// ///
/// The line home position is established by the parameter value of SET LINE HOME (`SLH`). The line limit position is /// The line home position is established by the parameter value of SET LINE HOME ([`SLH`]). The line limit position is
/// established by the parameter value of SET LINE LIMIT (`SLL`). /// established by the parameter value of SET LINE LIMIT ([`SLL`]).
/// ///
/// The default value for `s` is [`Alignment::LineHome`]. /// The default value for `s` is [`Alignment::LineHome`].
pub fn QUAD(s: Option<Alignment>) -> ControlFunction { pub fn QUAD(s: Option<Alignment>) -> ControlFunction {
@@ -1275,14 +1297,14 @@ pub fn RM(v: Vec<Mode>) -> ControlFunction {
/// Set Additional Character Representation. /// Set Additional Character Representation.
/// ///
/// `SACS` is used to establish extra inter-character escapement for subsequent text. The established extra escapement /// `SACS` is used to establish extra inter-character escapement for subsequent text. The established extra escapement
/// remains in effect until the next occurrence of `SACS` or of SET REDUCED CHARACTER SEPARATION (`SRCS`) in the data /// remains in effect until the next occurrence of `SACS` or of SET REDUCED CHARACTER SEPARATION ([`SRCS`]) in the data
/// stream or until it is reset to the default value by a subsequent occurrence of CARRIAGE RETURN LINE FEED (`CR LF`) /// stream or until it is reset to the default value by a subsequent occurrence of CARRIAGE RETURN LINE FEED
/// or of NEXT LINE (`NEL`) in the data stream. /// ([`CR`][crate::c0::CR] [`LF`][crate::c0::LF]) or of NEXT LINE ([`NEL`][crate::c1::NEL]) in the data stream.
/// ///
/// `n` specifies the number of units by which the inter-character escapement is enlarged. /// `n` specifies the number of units by which the inter-character escapement is enlarged.
/// ///
/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT /// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
/// (`SSU`). /// ([`SSU`]).
/// ///
/// The default value for `n` is 0. /// The default value for `n` is 0.
pub fn SACS(n: Option<u32>) -> ControlFunction { pub fn SACS(n: Option<u32>) -> ControlFunction {
@@ -1292,7 +1314,7 @@ pub fn SACS(n: Option<u32>) -> ControlFunction {
/// Valid parameter values to the function [`SAPV`]. /// Valid parameter values to the function [`SAPV`].
#[derive(Clone, Copy, PartialEq, Eq, Default)] #[derive(Clone, Copy, PartialEq, Eq, Default)]
pub enum PresentationVariant { pub enum PresentationVariant {
/// Default presentation (implementation-defined); cancels the effect of any preceding occurrence of `SAPV` in the /// Default presentation (implementation-defined); cancels the effect of any preceding occurrence of [`SAPV`] in the
/// data stream. /// data stream.
#[default] #[default]
Default = 0, Default = 0,
@@ -1364,7 +1386,7 @@ pub enum PresentationVariant {
NoContextualShapeArabicScript, NoContextualShapeArabicScript,
/// Contextual shape determination of Arabic scripts i not used, the graphic characters - excluding the digits - /// Contextual shape determination of Arabic scripts i not used, the graphic characters - excluding the digits -
/// are presented in the form thye are stored (pass-through). /// are presented in the form they are stored (pass-through).
NoContextualShapeArabicScriptExceptDigits, NoContextualShapeArabicScriptExceptDigits,
/// The graphic symbols used to present the decimal digits are device dependent. /// The graphic symbols used to present the decimal digits are device dependent.
@@ -1451,8 +1473,9 @@ pub enum CharacterPathScope {
/// ///
/// ## Note /// ## Note
/// ///
/// This may also permit the effect to take place after the next occurrence of `CR`, `NEL` or any control function /// This may also permit the effect to take place after the next occurrence of [`CR`][crate::c0::CR],
/// which initiates an absolute movement of the active presentation position or the active data position. /// [`NEL`][crate::c1::NEL] or any control function which initiates an absolute movement of the active presentation
/// position or the active data position.
Undefined = 0, Undefined = 0,
/// The content of the active line in the presentation component (the line that contains the active presentation /// The content of the active line in the presentation component (the line that contains the active presentation
@@ -1472,7 +1495,7 @@ pub enum CharacterPathScope {
/// Select Character Path. /// Select Character Path.
/// ///
/// `SCP` is used to select the character paht, relative to the line orientation, for the active line (the line that /// `SCP` is used to select the character path, relative to the line orientation, for the active line (the line that
/// contains the active presentation position) and subsequent lines in the presentation component. It is also used to /// contains the active presentation position) and subsequent lines in the presentation component. It is also used to
/// update the content of the active line in the presentation component and the content of the active line (the line /// update the content of the active line in the presentation component and the content of the active line (the line
/// that contains the active data position) in the data component. This takes effect immediately. /// that contains the active data position) in the data component. This takes effect immediately.
@@ -1484,13 +1507,13 @@ pub fn SCP(s: CharacterPath, t: CharacterPathScope) -> ControlFunction {
/// Set Character Spacing. /// Set Character Spacing.
/// ///
/// `SCS` is used to establish the character spacing for subsequent text. The established spacing remains in effect /// `SCS` is used to establish the character spacing for subsequent text. The established spacing remains in effect
/// until the next occurrence of `SCS`, or of SELECT CHARACTER SPACING (`SHS`) or of SPACING INCREMENT (`SPI`) in the /// until the next occurrence of `SCS`, or of SELECT CHARACTER SPACING ([`SHS`]) or of SPACING INCREMENT ([`SPI`]) in
/// data stream. /// the data stream.
/// ///
/// `n` specifies the character spacing. /// `n` specifies the character spacing.
/// ///
/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT /// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
/// (`SSU`). /// ([`SSU`]).
pub fn SCS(n: u32) -> ControlFunction { pub fn SCS(n: u32) -> ControlFunction {
sequence!(02 / 00, 06 / 07, numeric n) sequence!(02 / 00, 06 / 07, numeric n)
} }
@@ -1503,7 +1526,7 @@ pub fn SCS(n: u32) -> ControlFunction {
/// ///
/// The active presentation position is not affected by this control function. /// The active presentation position is not affected by this control function.
/// ///
/// The default value for `n` is `1´. /// The default value for `n` is `1`.
pub fn SD(n: Option<u32>) -> ControlFunction { pub fn SD(n: Option<u32>) -> ControlFunction {
sequence!(05 / 04, numeric n, default 1) sequence!(05 / 04, numeric n, default 1)
} }
@@ -1531,7 +1554,7 @@ pub enum StringDirection {
/// The beginning of a directed string is indicated by `SDS` with a parameter value not equal to /// The beginning of a directed string is indicated by `SDS` with a parameter value not equal to
/// [`StringDirection::End`]. A directed string may contain one or more nested strings. These nested strings may be /// [`StringDirection::End`]. A directed string may contain one or more nested strings. These nested strings may be
/// directed strings the beginning of which are indicated by `SDS` with a parameter value not equal to /// directed strings the beginning of which are indicated by `SDS` with a parameter value not equal to
/// [`StringDirection::End`], or reversed stings the beginning of which are indicated by START REVERSED STRING (`SRS`) /// [`StringDirection::End`], or reversed stings the beginning of which are indicated by START REVERSED STRING ([`SRS`])
/// with a parameter value of [`ReversedString::Start`]. Every beginning of such a string invokes the next deeper level /// with a parameter value of [`ReversedString::Start`]. Every beginning of such a string invokes the next deeper level
/// of nesting. /// of nesting.
/// ///
@@ -1546,19 +1569,21 @@ pub enum StringDirection {
/// ///
/// ## Note 1 /// ## Note 1
/// ///
/// The effect of receiving a `CVT`, `HT`, `SCP`, `SPD`, or `VT` control function within an `SDS` string is not defined. /// The effect of receiving a [`CVT`], [`HT`][crate::c0::HT], [`SCP`], [`SPD`], or [`VT`][crate::c0::VT] control
/// function within an `SDS` string is not defined.
/// ///
/// ## Note 2 /// ## Note 2
/// ///
/// The control functions for area definitions (`DAQ, `EPA`, `SPA`, `SSA`) should not be used within an `SDS` string. /// The control functions for area definitions ([`DAQ`], [`EPA`][crate::c1::EPA], [`SPA`][crate::c1::SPA],
/// [`SSA`][crate::c1::SPA]) should not be used within an `SDS` string.
pub fn SDS(s: Option<StringDirection>) -> ControlFunction { pub fn SDS(s: Option<StringDirection>) -> ControlFunction {
sequence!(05 / 13, selective default s) sequence!(05 / 13, selective default s)
} }
/// Valid parameter values to the function [`SSE`]. /// Valid parameter values to the function [`SEE`].
#[derive(Clone, Copy, PartialEq, Eq, Default)] #[derive(Clone, Copy, PartialEq, Eq, Default)]
pub enum EditingExtend { pub enum EditingExtend {
/// The shifted part is limitied to the active page in the presentation component. /// The shifted part is limited to the active page in the presentation component.
#[default] #[default]
ActivePage = 0, ActivePage = 0,
@@ -1582,7 +1607,7 @@ pub enum EditingExtend {
/// depends on the parameter value. /// depends on the parameter value.
/// ///
/// The default value for `s` is [`EditingExtend::ActivePage`]. /// The default value for `s` is [`EditingExtend::ActivePage`].
pub fn SSE(s: Option<EditingExtend>) -> ControlFunction { pub fn SEE(s: Option<EditingExtend>) -> ControlFunction {
sequence!(05 / 01, selective default s) sequence!(05 / 01, selective default s)
} }
@@ -1630,8 +1655,8 @@ pub fn SEF(l: Option<Load>, s: Option<Stack>) -> ControlFunction {
/// Valid parameter values to the function [`SGR`]. /// Valid parameter values to the function [`SGR`].
#[derive(Clone, Copy, PartialEq, Eq, Default)] #[derive(Clone, Copy, PartialEq, Eq, Default)]
pub enum GraphicRendition { pub enum GraphicRendition {
/// Default rendition (implementation-defined), cancels the effect of any preceding occurrence of `SGR` in the data /// Default rendition (implementation-defined), cancels the effect of any preceding occurrence of [`SGR`] in the
/// stream regardless of the setting of the GRAPHIC RENDITION COMBINATION MODE (`GRCM`). /// data stream regardless of the setting of the GRAPHIC RENDITION COMBINATION MODE ([`GRCM`][crate::modes::GRCM]).
#[default] #[default]
Default = 0, Default = 0,
@@ -1805,7 +1830,8 @@ pub enum GraphicRendition {
/// ///
/// `SGR` is used to establish one or more graphic rendition aspects for subsequent text. The established aspects remain /// `SGR` is used to establish one or more graphic rendition aspects for subsequent text. The established aspects remain
/// in effect until the next occurrence of `SGR` in the data stream, depending on the setting of the GRAPHIC RENDITION /// in effect until the next occurrence of `SGR` in the data stream, depending on the setting of the GRAPHIC RENDITION
/// COMBINATION MODE (`GRCM`). Each graphic rendition aspect is specified by a parameter value of [`GraphicRendition`]. /// COMBINATION MODE ([`GRCM`][crate::modes::GRCM]). Each graphic rendition aspect is specified by a parameter value of
/// [`GraphicRendition`].
/// ///
/// The default value for `s` is [`GraphicRendition::Default`]. /// The default value for `s` is [`GraphicRendition::Default`].
/// ///
@@ -1846,8 +1872,8 @@ pub enum CharacterSpacing {
/// Select Character Spacing. /// Select Character Spacing.
/// ///
/// `SHS` is used to establish the character spacing for subsequent text. The established spacing remains in effect /// `SHS` is used to establish the character spacing for subsequent text. The established spacing remains in effect
/// until the next occurrence of `SHS` or of SET CHARACTER SPACING (`SPS`) or of SPACING INCREMENT (`SPI`) in the data /// until the next occurrence of `SHS` or of SET CHARACTER SPACING ([`SCS`]) or of SPACING INCREMENT ([`SPI`]) in the
/// stream. /// data stream.
/// ///
/// The default value for `s` is [`CharacterSpacing::TenCharacters`]. /// The default value for `s` is [`CharacterSpacing::TenCharacters`].
pub fn SHS(s: Option<CharacterSpacing>) -> ControlFunction { pub fn SHS(s: Option<CharacterSpacing>) -> ControlFunction {
@@ -1868,7 +1894,7 @@ pub enum MovementDirection {
/// Select Implicit Movement Direction. /// Select Implicit Movement Direction.
/// ///
/// `SIMD` is used to select the direction of implicit movement of the data position relative to the character /// `SIMD` is used to select the direction of implicit movement of the data position relative to the character
/// progression. The direction selected remains in effect until the next occurrence of `SIMD`. /// progression. The direction selected remains in effect until the next occurrence of [`SIMD`].
/// ///
/// The default value of `s` is [`MovementDirection::Normal`]. /// The default value of `s` is [`MovementDirection::Normal`].
pub fn SIMD(s: Option<MovementDirection>) -> ControlFunction { pub fn SIMD(s: Option<MovementDirection>) -> ControlFunction {
@@ -1890,18 +1916,19 @@ pub fn SL(n: Option<u32>) -> ControlFunction {
/// Set Line Home. /// Set Line Home.
/// ///
/// If the DEVICE COMPONENT SELECT MODE is set to PRESENTATION, `SLH` is used to establish at character position `n` in /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `SLH` is used to
/// the active line (the line that contains the active presentation position) and lines of subsequent text in the /// establish at character position `n` in the active line (the line that contains the active presentation position) and
/// presentation component the position to which the active presentation position will be moved by subsequent /// lines of subsequent text in the presentation component the position to which the active presentation position will
/// occurrences of CARRIAGE RETURN (`CR`), DELETE LINE (`DL`), INSERT LINE (`IL`) or NEXT LINE (`NEL`) in the data /// be moved by subsequent occurrences of CARRIAGE RETURN ([`CR`][crate::c0::CR]), DELETE LINE ([`DL`]), INSERT LINE
/// stream. In the case of a device without data component, it is also the position ahead of which no implicit movement /// ([`IL`]) or NEXT LINE ([`NEL`][crate::c1::NEL]) in the data stream. In the case of a device without data component,
/// of the active presentation position shall occur. /// it is also the position ahead of which no implicit movement of the active presentation position shall occur.
/// ///
/// If the DEVICE COMPONENT SELECT MODE is set to DATA, `SLH` is used to establish at character position `n` in the /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SLH` is used to establish at
/// active line (the line that contains the active data position) and lines of subsequent text in the data component /// character position `n` in the active line (the line that contains the active data position) and lines of subsequent
/// the position to which the active data position will be moved by subsequent occurrences of CARRIAGE RETURN (`CR`), /// text in the data component the position to which the active data position will be moved by subsequent occurrences of
/// DELETE LINE (`DL`), INSERT LINE (`IL`) or NEXT LINE (`NEL`) in the data stream. It is also the position ahead of /// CARRIAGE RETURN ([`CR`][crate::c0::CR]), DELETE LINE ([`DL`]), INSERT LINE ([`IL`]) or NEXT LINE
/// which no implicit movement of the active data position shall occur. /// ([`NEL`][crate::c1::NEL]) in the data stream. It is also the position ahead of which no implicit movement of the
/// active data position shall occur.
/// ///
/// The established position is called the line home position and remains in effect until the next occurrence of `SLH` /// The established position is called the line home position and remains in effect until the next occurrence of `SLH`
/// in the data stream. /// in the data stream.
@@ -1911,20 +1938,20 @@ pub fn SLH(n: u32) -> ControlFunction {
/// Set Line Limit. /// Set Line Limit.
/// ///
/// If the DEVICE COMPONENT SELECT MODE is set to PRESENTATION, `SLL` is used to establish at character position `n` in /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `SLL` is used to
/// the active line (the line that contains the active presentation position) and lines of subsequent text in the /// establish at character position `n` in the active line (the line that contains the active presentation position) and
/// presentation component the position to which the active presentation position will be moved by subsequent /// lines of subsequent text in the presentation component the position to which the active presentation position will
/// occurrences of CARRIAGE RETURN (`CR`), or NEXT LINE (`NEL`) in the data stream if the parameter value of SELECT /// be moved by subsequent occurrences of CARRIAGE RETURN ([`CR`][crate::c0::CR]), or NEXT LINE
/// IMPLICIT MOVEMENT DIRECTION (`SIMD`) is equal to [`MovementDirection::Opposite`]. In the case of a device without /// ([`NEL`][crate::c1::NEL]) in the data stream if the parameter value of SELECT IMPLICIT MOVEMENT DIRECTION ([`SIMD`])
/// data component, it is also the position beyond which no implicit movement of the active presentation position shall /// is equal to [`MovementDirection::Opposite`]. In the case of a device without data component, it is also the position
/// occur. /// beyond which no implicit movement of the active presentation position shall occur.
/// ///
/// If the DEVICE COMPONENT SELECT MODE is set to DATA, `SLL` is used to establish at character position `n` in the /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SLL` is used to establish at
/// active line (the line that contains the active data position) and lines of subsequent text in the data component the /// character position `n` in the active line (the line that contains the active data position) and lines of subsequent
/// position beyond which no implicit movement of the active data position shall occur. It is also the position in the /// text in the data component the position beyond which no implicit movement of the active data position shall occur.
/// data component to which the active data position will be moved by subsequent occurrences of `CR` or `NEL` in the /// It is also the position in the data component to which the active data position will be moved by subsequent
/// data stream, if the parameter value of SELECT IMPLICIT MOVEMENT DIRECTION (SIMD) is equal to /// occurrences of [`CR`][crate::c0::CR] or [`NEL`][crate::c1::NEL] in the data stream, if the parameter value of
/// [`MovementDirection::Opposite`]. /// SELECT IMPLICIT MOVEMENT DIRECTION ([`SIMD`]) is equal to [`MovementDirection::Opposite`].
/// ///
/// The established position is called the line limit position and remains in effect until the next occurrence of `SLL` /// The established position is called the line limit position and remains in effect until the next occurrence of `SLL`
/// in the data stream. /// in the data stream.
@@ -1935,12 +1962,12 @@ pub fn SLL(n: u32) -> ControlFunction {
/// Set Line Spacing. /// Set Line Spacing.
/// ///
/// `SLS` is used to establish the line spacing for subsequent text. The established spacing remains in effect until the /// `SLS` is used to establish the line spacing for subsequent text. The established spacing remains in effect until the
/// next occurrence of `SLS` or of SELECT LINE SPACING (`SVS`) or of SPACING INCREMENT (`SPI`) in the data stream. /// next occurrence of `SLS` or of SELECT LINE SPACING ([`SVS`]) or of SPACING INCREMENT ([`SPI`]) in the data stream.
/// ///
/// `n` specifies the line spacing. /// `n` specifies the line spacing.
/// ///
/// The unit in which the parameter value is epxressed is that established by the paramaeter value of SELECT SIZE UNIT /// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
/// (`SSU`). /// ([`SSU`]).
pub fn SLS(n: u32) -> ControlFunction { pub fn SLS(n: u32) -> ControlFunction {
sequence!(02 / 00, 06 / 08, numeric n) sequence!(02 / 00, 06 / 08, numeric n)
} }
@@ -1988,8 +2015,9 @@ pub enum PresentationDirectionScope {
/// ///
/// ## Note /// ## Note
/// ///
/// This may also permit the effect to take place after the next occurrence of `CR`, `NEL` or any control function /// This may also permit the effect to take place after the next occurrence of [`CR`][crate::c0::CR],
/// which initiates an absolute movement of the active presentation position or the active data position. /// [`NEL`][crate::c1::NEL] or any control function which initiates an absolute movement of the active presentation
/// position or the active data position.
#[default] #[default]
Undefined = 0, Undefined = 0,
@@ -2026,18 +2054,20 @@ pub fn SPD(
/// Set Page Home. /// Set Page Home.
/// ///
/// If the DEVICE COMPONENT SELECT MODE is set to PRESENTATION, `SPH` is used to establish at line position `n` in the /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `SPH` is used to
/// active page (the page that contains the active presentation position) and subsequent pages in the presentation /// establish at line position `n` in the active page (the page that contains the active presentation position) and
/// component the position to which the active presentation position will be moved by subsequent occurrences of FORM /// subsequent pages in the presentation component the position to which the active presentation position will be moved
/// FEED (`FF`) in the data stream. In the case of a device without data component, it is also the position ahead of /// by subsequent occurrences of FORM FEED ([`FF`][crate::c0::FF]) in the data stream. In the case of a device without
/// which no implicit movement of the active presentation position shall occur. /// data component, it is also the position ahead of which no implicit movement of the active presentation position
/// shall occur.
/// ///
/// If the DEVICE COMPONENT SELECT MODE is set to DATA, `SPH` is used to establish at line position `n´ in the active page /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SPH` is used to establish at
/// (the page that contains the active data position) and subsequent pages in the data component the position to which /// line position `n` in the active page (the page that contains the active data position) and subsequent pages in the
/// the active data position will be moved by subsequent occurrences of FORM FEED (`FF`) in the data stream. It is also /// data component the position to which the active data position will be moved by subsequent occurrences of FORM FEED
/// the position ahead of which no implicit movement of the active presentation position shall occur. /// ([`FF`][crate::c0::FF]) in the data stream. It is also the position ahead of which no implicit movement of the
/// active presentation position shall occur.
/// ///
/// The established position is called the page home position and remains in effect until the next occurrence of ´SPH` /// The established position is called the page home position and remains in effect until the next occurrence of `SPH`
/// in the data stream. /// in the data stream.
pub fn SPH(n: u32) -> ControlFunction { pub fn SPH(n: u32) -> ControlFunction {
sequence!(02 / 00, 06 / 09, numeric n) sequence!(02 / 00, 06 / 09, numeric n)
@@ -2046,30 +2076,30 @@ pub fn SPH(n: u32) -> ControlFunction {
/// Spacing Increment. /// Spacing Increment.
/// ///
/// `SPI` is used to establish the line spacing and the character spacing for subsequent text. The established line /// `SPI` is used to establish the line spacing and the character spacing for subsequent text. The established line
/// spacing remains in effect until the next occurrence of `SPI` or of SET LINE SPACING (`SLS`) or of SELECT LINE /// spacing remains in effect until the next occurrence of `SPI` or of SET LINE SPACING ([`SLS`]) or of SELECT LINE
/// SPACING (`SVS`) in the data stream. The established character spacing remains in effect until the next occurrence /// SPACING ([`SVS`]) in the data stream. The established character spacing remains in effect until the next occurrence
/// of SET CHARACTER SPACING (`SCS`) or of SELECT CHARACTER SPACING (`SHS`) in the data stream. /// of SET CHARACTER SPACING ([`SCS`]) or of SELECT CHARACTER SPACING ([`SHS`]) in the data stream.
/// ///
/// `l` specifies the line spacing. /// `l` specifies the line spacing.
/// `c` specifies the character spacing. /// `c` specifies the character spacing.
/// ///
/// The unit in which the parameter values are expressed is that established by the parameter value of SELECT SIZE UNIT /// The unit in which the parameter values are expressed is that established by the parameter value of SELECT SIZE UNIT
/// (`SSU`). /// ([`SSU`]).
pub fn SPI(l: u32, c: u32) -> ControlFunction { pub fn SPI(l: u32, c: u32) -> ControlFunction {
sequence!(02 / 00, 04 / 07, numeric l, numeric c) sequence!(02 / 00, 04 / 07, numeric l, numeric c)
} }
/// Set Page Limit. /// Set Page Limit.
/// ///
/// If the DEVICE COMPONENT SELECT MODE is set to PRESENTATION, `SPL` is used to establish at line position `n` in the /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `SPL` is used to
/// active page (the page that contains the active presentation position) and pages of subsequent text in the /// establish at line position `n` in the active page (the page that contains the active presentation position) and
/// presentation component the position beyond which the active presentation position can normally not be moved. In the /// pages of subsequent text in the presentation component the position beyond which the active presentation position
/// case of a device without data component, it is also the position beyond which no implicit movement of the active /// can normally not be moved. In the case of a device without data component, it is also the position beyond which no
/// presentation position shall occur. /// implicit movement of the active presentation position shall occur.
/// ///
/// If the DEVICE COMPONENT SELECT MODE is set to DATA, `SPL` is used to establish at line position `n` in the active /// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SPL` is used to establish at
/// page (the page that contains the active data position) and pages of subsequent text in the data component the /// line position `n` in the active page (the page that contains the active data position) and pages of subsequent text
/// position beyond which no implicit movement of the active data position shall occur. /// in the data component the position beyond which no implicit movement of the active data position shall occur.
/// ///
/// The established position is called the page limit position and remains in effect until the next occurrence of `SPL` /// The established position is called the page limit position and remains in effect until the next occurrence of `SPL`
/// in the data stream. /// in the data stream.
@@ -2118,14 +2148,15 @@ pub fn SR(n: Option<u32>) -> ControlFunction {
/// Set Reduced Character Separation. /// Set Reduced Character Separation.
/// ///
/// `SRCS` is used to establish reduced inter-character escapement for subsequent text. The established reduced /// `SRCS` is used to establish reduced inter-character escapement for subsequent text. The established reduced
/// escapement remains in effect until the next occurrence of `SRCS` or of SET ADDITIONAL CHARACTER SEPARATION (`SACS`) /// escapement remains in effect until the next occurrence of `SRCS` or of SET ADDITIONAL CHARACTER SEPARATION
/// in the data stream or until it is reset to the default value by a subsequent occurrence of CARRIAGE RETURN/LINE FEED /// ([`SACS`]) in the data stream or until it is reset to the default value by a subsequent occurrence of
/// (`CR/LF`) or of NEXT LINE (`NEL`) in the data stream. /// CARRIAGE RETURN/LINE FEED ([`CR`][crate::c0::CR]/[`LF`][crate::c0::LF]) or of NEXT LINE ([`NEL`][crate::c1::NEL])
/// in the data stream.
/// ///
/// `n` specifies the number of units by which the inter-character escapement is reduced. /// `n` specifies the number of units by which the inter-character escapement is reduced.
/// ///
/// The unit in which the parameter values are expressed is that established by the parameter value of SELECT SIZE UNIT /// The unit in which the parameter values are expressed is that established by the parameter value of SELECT SIZE UNIT
/// (`SSU`). /// ([`SSU`]).
/// ///
/// The default value of `n` is `0`. /// The default value of `n` is `0`.
pub fn SRCS(n: Option<u32>) -> ControlFunction { pub fn SRCS(n: Option<u32>) -> ControlFunction {
@@ -2152,7 +2183,7 @@ pub enum ReversedString {
/// The beginning of a reversed string is indicated by `SRS` with a parameter value of [`ReversedString::Start`]. /// The beginning of a reversed string is indicated by `SRS` with a parameter value of [`ReversedString::Start`].
/// A reversed string may contain one or more nested strings. These nested strings may be reversed strings the /// A reversed string may contain one or more nested strings. These nested strings may be reversed strings the
/// beginnings of which are indicated by `SRS` with a parameter value of [`ReversedString::Start`], or directed strings /// beginnings of which are indicated by `SRS` with a parameter value of [`ReversedString::Start`], or directed strings
/// the beginnings of which are indicated by START DIRECTED STRING (`SDS`) with a parameter value not equal to /// the beginnings of which are indicated by START DIRECTED STRING ([`SDS`]) with a parameter value not equal to
/// [`StringDirection::End`]. Every beginning of such a string invokes the next deeper level of nesting. /// [`StringDirection::End`]. Every beginning of such a string invokes the next deeper level of nesting.
/// ///
/// This Standard does not define the location of the active data position within any such nested string. /// This Standard does not define the location of the active data position within any such nested string.
@@ -2166,12 +2197,13 @@ pub enum ReversedString {
/// ///
/// ## Note 1 /// ## Note 1
/// ///
/// The effect of receiving a `CVT`, `HT`, `SCP`, `SPD`, or `VT` control function within an `SRS` string is not defined. /// The effect of receiving a [`CVT`], [`HT`][crate::c0::HT], [`SCP`], [`SPD`], or [`VT`][crate::c0::VT] control
/// function within an `SRS` string is not defined.
/// ///
/// ## Note 2 /// ## Note 2
/// ///
/// The control functions for area definition (`DAQ`, `EPA`, `ESA`, `SPA`, `SSA`) should not be used within an `SRS` /// The control functions for area definition ([`DAQ`], [`EPA`][crate::c1::EPA], [`ESA`][crate::c1::ESA],
/// string. /// [`SPA`][crate::c1::SPA], [`SSA`][crate::c1::SSA]) should not be used within an `SRS` string.
pub fn SRS(s: Option<ReversedString>) -> ControlFunction { pub fn SRS(s: Option<ReversedString>) -> ControlFunction {
sequence!(05 / 11, selective default s) sequence!(05 / 11, selective default s)
} }
@@ -2220,20 +2252,21 @@ pub fn SSU(s: Option<SizeUnit>) -> ControlFunction {
/// Set Space Width. /// Set Space Width.
/// ///
/// `SSW` is used to establish for subsequent text the character escapement associated with the character SPACE. The /// `SSW` is used to establish for subsequent text the character escapement associated with the character `SPACE`. The
/// established escapement remains in effect until the next occurrence of `SSW` in the data stream or until it is reset /// established escapement remains in effect until the next occurrence of `SSW` in the data stream or until it is reset
/// to the default value by a subsequent occurrence of CARRIAGE RETURN/LINE FEED (`CR/LF`), CARRIAGE RETURN/FORM FEED /// to the default value by a subsequent occurrence of CARRIAGE RETURN/LINE FEED
/// (`CR/FF`), or of NEXT LINE (`NEL`) in the data stream. /// ([`CR`][crate::c0::CR]/[`LF`][crate::c0::LF]), CARRIAGE RETURN/FORM FEED
/// ([`CR`][crate::c0::CR]/[`FF`][crate::c0::FF]), or of NEXT LINE ([`NEL`][crate::c1::NEL]) in the data stream.
/// ///
/// `n` specifies the escapement. /// `n` specifies the escapement.
/// ///
/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT /// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
/// (`SSU`). /// ([`SSU`]).
/// ///
/// The default character escapement of SPACE is specified by the most recent occurrence of SET CHARACTER SPACING /// The default character escapement of SPACE is specified by the most recent occurrence of SET CHARACTER SPACING
/// (`SCS`) or of SELECT CHARACTER SPACING (`SHS`) or of SELECT SPACING INCREMENT (`SPI`) in the data stream if the /// ([`SCS`]) or of SELECT CHARACTER SPACING ([`SHS`]) or of SELECT SPACING INCREMENT ([`SPI`]) in the data stream if
/// current font has constant spacing, or is specified by the nominal width of the character SPACE in the current font /// the current font has constant spacing, or is specified by the nominal width of the character `SPACE` in the current
/// if that font has proportional spacing. /// font if that font has proportional spacing.
pub fn SSW(n: u32) -> ControlFunction { pub fn SSW(n: u32) -> ControlFunction {
sequence!(02 / 00, 05 / 11, numeric n) sequence!(02 / 00, 05 / 11, numeric n)
} }
@@ -2300,7 +2333,7 @@ pub enum LineSpacing {
/// Select Line Spacing. /// Select Line Spacing.
/// ///
/// `SVS` is used to establish the line spacing for subsequent text. The established spacing remains in effect until the /// `SVS` is used to establish the line spacing for subsequent text. The established spacing remains in effect until the
/// next occurrence of `SVS` or of SET LINE SPACING (`SLS`) or of SPACING INCREMENT (`SPI`) in the data stream. /// next occurrence of `SVS` or of SET LINE SPACING ([`SLS`]) or of SPACING INCREMENT ([`SPI`]) in the data stream.
/// ///
/// The default value for `s` is [`LineSpacing::SixLinesPer25`]. /// The default value for `s` is [`LineSpacing::SixLinesPer25`].
pub fn SVS(s: Option<LineSpacing>) -> ControlFunction { pub fn SVS(s: Option<LineSpacing>) -> ControlFunction {
@@ -2350,12 +2383,23 @@ pub fn TATE(n: u32) -> ControlFunction {
/// Valid parameter values to the function [`TBC`]. /// Valid parameter values to the function [`TBC`].
#[derive(Clone, Copy, PartialEq, Eq, Default)] #[derive(Clone, Copy, PartialEq, Eq, Default)]
pub enum ClearTabulation { pub enum ClearTabulation {
/// Clear the character tabulation stop at the active presentation position.
#[default] #[default]
CharacterTabulationStopActivePosition = 0, CharacterTabulationStopActivePosition = 0,
/// Clear the line tabulation stop at the active line.
LineTabulationStopActiveLine, LineTabulationStopActiveLine,
/// Clear all character tabulation stops at the active line.
AllCharacterTabulationStopsActiveLine, AllCharacterTabulationStopsActiveLine,
/// Clear all character tabulation stops.
AllCharacterTabulationStops, AllCharacterTabulationStops,
/// Clear all line tabulation stops.
AllLineTabulationStops, AllLineTabulationStops,
/// Clear all tabulation stops.
AllTabulationStops, AllTabulationStops,
} }
@@ -2386,7 +2430,7 @@ pub fn TBC(s: Option<ClearTabulation>) -> ControlFunction {
/// code. For a 7-bit code, the permissible range of values is `32` to `127`; for an 8-bit code, the permissible range /// code. For a 7-bit code, the permissible range of values is `32` to `127`; for an 8-bit code, the permissible range
/// of values is `32` to `127` and `160` to `255`. /// of values is `32` to `127` and `160` to `255`.
/// ///
/// The default value ofr `m` is `32`. /// The default value of `m` is `32`.
pub fn TCC(n: u32, m: Option<u32>) -> ControlFunction { pub fn TCC(n: u32, m: Option<u32>) -> ControlFunction {
let k = m.unwrap_or(32); let k = m.unwrap_or(32);
sequence!(02 / 00, 06 / 03, numeric n, numeric k) sequence!(02 / 00, 06 / 03, numeric n, numeric k)

View File

@@ -2,9 +2,83 @@
//! //!
//! A control string is a string of bit combinations which may occur in the data stream as a logical entity for //! A control string is a string of bit combinations which may occur in the data stream as a logical entity for
//! control purposes. A control string consists of an opening delimiter, a command string or a character string, //! control purposes. A control string consists of an opening delimiter, a command string or a character string,
//! and a terminating delimiter, the String Terminator (`ST`). //! and a terminating delimiter, the STRING TERMINATOR ([`ST`][crate::c1::ST]).
//! //!
//! A command string is a sequence of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. //! A command string is a sequence of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`.
//! //!
//! A character string is a sequence of any bit combination, except those representing Start Of String (`SOS`) or String //! A character string is a sequence of any bit combination, except those representing START OF STRING
//! Terminator (`ST`). //! ([`SOS`][crate::c1::SOS]) or STRING TERMINATOR ([`ST`][crate::c1::ST]).
//!
//! The low-level ansi control codes for control strings are defined in the module [`c1`][crate::c1].
//!
//! - APPLICATION PROGRAM COMMAND ([`APC`][crate::c1::APC])
//! - DEVICE CONTROL STRING ([`DCS`][crate::c1::DCS])
//! - OPERATING SYSTEM COMMAND ([`OSC`][crate::c1::OSC])
//! - PRIVACY MESSAGE ([`PM`][crate::c1::PM])
//! - START OF STRING ([`SOS`][crate::c1::SOS])
//! - STRING TERMINATOR ([`ST`][crate::c1::ST])
//!
//! This module contains higher level functions to invoke these low-level ansi control codes.
//!
//! ## Usage
//!
//! Invoke one of the available functions to create new control strings.
//!
//! For example, create a new operating system command to halt the operating system (this is operating system specific
//! and will most likely not work on your operating system).
//!
//! ```no_run
//! use ansi_control_codes::control_strings::operating_system_command;
//! let halt_command = operating_system_command("HALT");
//! println!("{}", halt_command);
//! ```
use crate::c1::{APC, DCS, OSC, PM, SOS, ST};
/// Creates a new Application Program Command.
///
/// The given command string will be prefixed with [`APC`] and suffixed with [`ST`].
///
/// The interpretation of the command string depends on the relevant application program.
pub fn application_program_command(command_string: &str) -> String {
format!("{}{}{}", APC, command_string, ST)
}
/// Creates a new Device Control String.
///
/// The given control string will be prefixed with [`DCS`] and suffixed with [`ST`].
///
/// The command string represents either one or more commands for the receiving device, or one or more status reports
/// from the sending device. The purpose and the format of the command string are specified by the most recent
/// occurrence of IDENTIFY DEVICE CONTROL STRING ([`IDCS`][crate::control_sequences::IDCS]), if any, or depend on the
/// sending and/or the receiving device.
pub fn device_control_string(control_string: &str) -> String {
format!("{}{}{}", DCS, control_string, ST)
}
/// Creates a new Operating System Command.
///
/// The given system command will be prefixed with [`OSC`] and suffixed with [`ST`].
///
/// The interpretation of the command string depends on the relevant operating system.
pub fn operating_system_command(system_command: &str) -> String {
format!("{}{}{}", OSC, system_command, ST)
}
/// Creates a new Privacy Message.
///
/// The given message will be prefixed with [`PM`] and suffixed with [`ST`].
///
/// The interpretation of the message depends on the relevant privacy discipline.
pub fn privacy_message(message: &str) -> String {
format!("{}{}{}", PM, message, ST)
}
/// Creates a new Control String.
///
/// The given control string will be prefixed with [`SOS`] and suffixed with [`ST`].
///
/// The interpretation of the character string depends on the application.
pub fn control_string(control_string: &str) -> String {
format!("{}{}{}", SOS, control_string, ST)
}

View File

@@ -4,6 +4,18 @@
//! `ESC` is represented by bit combination `01/11` and `Fs` is represented by a bit combination from `06/00` to //! `ESC` is represented by bit combination `01/11` and `Fs` is represented by a bit combination from `06/00` to
//! `07/14`. //! `07/14`.
//! //!
//! ## Usage
//!
//! You can use the independent control functions inside normal strings, format them with the `format!()` macro, or
//! print them with the `print!()` and `println!()` macros.
//!
//! For example, to disable manual input:
//!
//! ```
//! use ansi_control_codes::independent_control_functions::DMI;
//! println!("{}", DMI);
//! ```
//!
//! ## Overview of the Independent Control Functions //! ## Overview of the Independent Control Functions
//! //!
//! | Row Number | Column `06` | Column `07` | //! | Row Number | Column `06` | Column `07` |
@@ -68,7 +80,9 @@ pub const INT: ControlFunction = independent!(06 / 01);
/// `LS1R` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data /// `LS1R` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `LS1R` is defined in Standard ECMA-35. /// The use of `LS1R` is defined in Standard [ECMA-35][ecma-35].
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const LS1R: ControlFunction = independent!(07 / 14); pub const LS1R: ControlFunction = independent!(07 / 14);
/// Locking-Shift Two. /// Locking-Shift Two.
@@ -76,7 +90,9 @@ pub const LS1R: ControlFunction = independent!(07 / 14);
/// `LS2` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data /// `LS2` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `LS2` is defined in Standard ECMA-35. /// The use of `LS2` is defined in Standard [ECMA-35][ecma-35].
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const LS2: ControlFunction = independent!(06 / 14); pub const LS2: ControlFunction = independent!(06 / 14);
/// Locking-Shift Two Right. /// Locking-Shift Two Right.
@@ -84,7 +100,9 @@ pub const LS2: ControlFunction = independent!(06 / 14);
/// `LS2R` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data /// `LS2R` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `LS2R` is defined in Standard ECMA-35. /// The use of `LS2R` is defined in Standard [ECMA-35][ecma-35].
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const LS2R: ControlFunction = independent!(07 / 13); pub const LS2R: ControlFunction = independent!(07 / 13);
/// Locking-Shift Three. /// Locking-Shift Three.
@@ -92,7 +110,9 @@ pub const LS2R: ControlFunction = independent!(07 / 13);
/// `LS3` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data /// `LS3` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `LS3` is defined in Standard ECMA-35. /// The use of `LS3` is defined in Standard [ECMA-35][ecma-35].
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const LS3: ControlFunction = independent!(06 / 15); pub const LS3: ControlFunction = independent!(06 / 15);
/// Locking-Shift Three Right. /// Locking-Shift Three Right.
@@ -100,7 +120,9 @@ pub const LS3: ControlFunction = independent!(06 / 15);
/// `LS3R` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data /// `LS3R` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
/// stream to be changed. /// stream to be changed.
/// ///
/// The use of `LS3R` is defined in Standard ECMA-35. /// The use of `LS3R` is defined in Standard [ECMA-35][ecma-35].
///
/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
pub const LS3R: ControlFunction = independent!(07 / 12); pub const LS3R: ControlFunction = independent!(07 / 12);
/// Reset to Initial State. /// Reset to Initial State.

View File

@@ -12,7 +12,7 @@
//! In the [ECMA-48 Standard][ecma-48] a convention has been adopted to assist the reader of the Standard. //! In the [ECMA-48 Standard][ecma-48] a convention has been adopted to assist the reader of the Standard.
//! //!
//! Capital letters are used to refer to a specific control function, mode, mode setting, or graphic character in order //! Capital letters are used to refer to a specific control function, mode, mode setting, or graphic character in order
//! to avoid confusion, for example, between the concept `space`, and the character `SPACE`. //! to avoid confusion, for example, between the concept "space", and the character `SPACE`.
//! //!
//! As is intended by the [ECMA-48 Standard][ecma-48], this convention and all acronyms of modes, and control functions //! As is intended by the [ECMA-48 Standard][ecma-48], this convention and all acronyms of modes, and control functions
//! are retained in this library, where rust permits. //! are retained in this library, where rust permits.
@@ -20,6 +20,51 @@
//! A character from the [ASCII table][ascii-table] is represented in the form `xx/yy`, where `xx` represents the column //! A character from the [ASCII table][ascii-table] is represented in the form `xx/yy`, where `xx` represents the column
//! number `00` to `07` in a 7-bit code table, and `yy` represents the row number `00` to `15`. //! number `00` to `07` in a 7-bit code table, and `yy` represents the row number `00` to `15`.
//! //!
//! ## Low-Level Control Functions
//!
//! The control functions of this library are sorted into several modules. You will find the low-level control functions
//! in the modules [c0], [c1], [control_sequences], [independent_control_functions]
//!
//! The control functions can be put into normal strings. For example, to ring the bell:
//!
//! ```
//! use ansi_control_codes::c0::BEL;
//! println!("Let's ring the bell {}", BEL);
//! ```
//!
//! Or to move the cursor to line 5, column 13:
//!
//! ```
//! use ansi_control_codes::control_sequences::CUP;
//! print!("{}", CUP(5.into(), 13.into()));
//! ```
//!
//! It might be necessary in some circumstances to announce the active set of control sequences before they can be used.
//! This is possible by invoking one of the announcer sequences.
//!
//! ```
//! use ansi_control_codes::c1::{ANNOUNCER_SEQUENCE, NEL};
//! // announce the C1 control function set, then move to the next line.
//! print!("{}{}", ANNOUNCER_SEQUENCE, NEL);
//! ```
//!
//! ## Categories of control functions
//!
//! Most control functions are categorized into different groups. They can be accessed from the module
//! [categories].
//!
//! ```
//! use ansi_control_codes::categories::format_effectors::{CR, LF};
//! println!("line1{}{}line2", CR, LF);
//! ```
//!
//! ## High-Level Functions
//!
//! For your convenience and ease-of-use of the ansi control codes, some functionality is exposed in wrapper functions.
//! See the following module documentations for a more in-depth introduction to these functions.
//!
//! - Working with control strings in module [control_strings].
//!
//! ## Source Material //! ## Source Material
//! //!
//! The second, and newer, editions of the [ECMA-48 Standard][ecma-48] are based on the text of the //! The second, and newer, editions of the [ECMA-48 Standard][ecma-48] are based on the text of the
@@ -37,23 +82,22 @@
//! [ecma-48]: https://www.ecma-international.org/publications-and-standards/standards/ecma-48/ //! [ecma-48]: https://www.ecma-international.org/publications-and-standards/standards/ecma-48/
//! [iso-6429]: https://www.iso.org/standard/12782.html //! [iso-6429]: https://www.iso.org/standard/12782.html
//! [wikipedia-ansi]: https://en.wikipedia.org/wiki/ANSI_escape_code //! [wikipedia-ansi]: https://en.wikipedia.org/wiki/ANSI_escape_code
#![allow(dead_code)]
use std::str; use std::{fmt, str};
/// Convert the ascii table notation `xx/yy` into a rust string. /// Converts the ascii table notation `xx/yy` into a rust string.
/// ///
/// A character from the [ASCII table][ascii-table] is represented in the form `xx/yy`, where `xx` represents the column /// A character from the [ASCII table][ascii-table] is represented in the form `xx/yy`, where `xx` represents the column
/// number `00` to `07` in a 7-bit code table, and `yy` represents the row number `00` to `15`. /// number `00` to `07` in a 7-bit code table, and `yy` represents the row number `00` to `15`.
/// ///
/// The macro can be used to convert a single code point into a str, or to convert a sequence of them. /// The macro can be used to convert a single code point into a str, or to convert a sequence of them.
/// ///
/// ``` /// ```ignore
/// let a: &'static str = ascii!(06 / 01); /// let a: &'static str = ascii!(06 / 01);
/// let abc: &'static str = ascii!(06 / 01, 06 / 02, 06 / 03); /// let abc: &'static str = ascii!(06 / 01, 06 / 02, 06 / 03);
/// ``` /// ```
/// ///
/// ## Safeness /// ## Safety
/// ///
/// This macro converts the given `xx/yy` combination into a ascii code by the formula `(xx << 4) + yy`. /// This macro converts the given `xx/yy` combination into a ascii code by the formula `(xx << 4) + yy`.
/// The result is passed to the unsafe function std::str::from_utf8_unchecked. /// The result is passed to the unsafe function std::str::from_utf8_unchecked.
@@ -64,7 +108,7 @@ use std::str;
/// - `yy: [0,15]` /// - `yy: [0,15]`
/// ///
/// Since this macro is not public and only used by the library itself, it is assumed to be used only within safe /// Since this macro is not public and only used by the library itself, it is assumed to be used only within safe
/// bounds. /// bounds, and therefore considered safe.
/// ///
/// [ascii-table]: https://en.wikipedia.org/wiki/ASCII#/media/File:USASCII_code_chart.png /// [ascii-table]: https://en.wikipedia.org/wiki/ASCII#/media/File:USASCII_code_chart.png
macro_rules! ascii { macro_rules! ascii {
@@ -74,10 +118,14 @@ macro_rules! ascii {
} }
/// The different types of control functions. /// The different types of control functions.
///
#[derive(Clone, Copy, PartialEq, Eq)]
enum ControlFunctionType { enum ControlFunctionType {
/// Elements of the C0 set. /// Elements of the C0 set.
/// ///
/// C0 control functions are represented in 7-bit codes by bit combinations from 00/00 to 01/15. /// C0 control functions are represented in 7-bit codes by bit combinations from `00/00` to `01/15`.
///
/// The control functions of the C0 set are defined in the module [c0].
C0, C0,
/// Elements of the C1 set. /// Elements of the C1 set.
@@ -85,28 +133,28 @@ enum ControlFunctionType {
/// C1 control functions are represented in 7-bit codes by 2-character escape sequences of the form `ESC Fe`, /// C1 control functions are represented in 7-bit codes by 2-character escape sequences of the form `ESC Fe`,
/// where `ESC` is represented by bit combination `01/11`, and `Fe` is represented by a bit combination from /// where `ESC` is represented by bit combination `01/11`, and `Fe` is represented by a bit combination from
/// `04/00` to `05/15`. /// `04/00` to `05/15`.
///
/// The control functions of the C1 set are defined in the module [c1].
C1, C1,
/// Control Sequences. /// Control Sequences.
/// ///
/// Control sequences are strings of bit combinations starting with the control function Control Function Introducer /// Control sequences are strings of bit combinations starting with the control function
/// (`CSI`), followed by one or more bit combinations representing parameters, if any, and by one ore more bit /// `CONTROL SEQUENCE INTRODUCER` ([`CSI`][c1::CSI]), followed by one or more bit combinations representing
/// combinations identifying the control function. The control function `CSI` itself is an element of the independent_control_function set. /// parameters, if any, and by one ore more bit combinations identifying the control function. The control function
/// `CSI` itself is an element of the [c1] set.
///
/// The control sequences are defined in the module [control_sequences].
ControlSequence, ControlSequence,
/// Independent Control Functions. /// Independent Control Functions.
/// ///
/// Independent control functions are represented in 7-bit codes by 2-character escape sequences of the form /// Independent control functions are represented in 7-bit codes by 2-character escape sequences of the form
/// `ESC Fs`, where `ESC` is represented by bit combination `01/11`, and `Fs` is represented by a bit combination /// `ESC Fs`, where `ESC` is represented by bit combination `01/11`, and `Fs` is represented by a bit combination
/// from `06/00` to `07/14` /// from `06/00` to `07/14`.
IndependentControlFunction,
/// Control Strings.
/// ///
/// A control string is a string of bit combinations which may occur in the data stream as a logical entity for /// The independent control functions are defined in the module [independent_control_functions].
/// control purposes. A control string consists of an opening delimiter, a command string or character string, and IndependentControlFunction,
/// a terminating delimiter, the String Terminator (`ST`).
ControlString,
} }
impl fmt::Debug for ControlFunctionType { impl fmt::Debug for ControlFunctionType {
@@ -118,21 +166,28 @@ impl fmt::Debug for ControlFunctionType {
ControlFunctionType::IndependentControlFunction => { ControlFunctionType::IndependentControlFunction => {
write!(f, "Independent Control Function") write!(f, "Independent Control Function")
} }
ControlFunctionType::ControlString => write!(f, "Control String"),
} }
} }
} }
/// An ansi control function defined in [ECMA-48][ecma-48].
///
/// [ecma-48]: https://www.ecma-international.org/publications-and-standards/standards/ecma-48/
pub struct ControlFunction { pub struct ControlFunction {
/// The type of the control function.
function_type: ControlFunctionType, function_type: ControlFunctionType,
/// The byte or byte combination identifying the control function.
value: &'static str, value: &'static str,
/// An arbitrary number of arguments for this control function.
parameters: Vec<String>, parameters: Vec<String>,
} }
impl ControlFunction { impl ControlFunction {
/// Creates a new control function of type [C0][ControlFunctionType::C0]. /// Creates a new control function of type [`C0`][ControlFunctionType::C0].
/// ///
/// C0 control functions do not accept any parameters. /// `C0` control functions do not accept any parameters.
const fn new_c0(value: &'static str) -> Self { const fn new_c0(value: &'static str) -> Self {
ControlFunction { ControlFunction {
function_type: ControlFunctionType::C0, function_type: ControlFunctionType::C0,
@@ -141,9 +196,9 @@ impl ControlFunction {
} }
} }
/// Creates a new control function of type [C1][ControlFunctionType::C1]. /// Creates a new control function of type [`C1`][ControlFunctionType::C1].
/// ///
/// independent_control_function control functions do not accept any parameters. /// `C1` control functions do not accept any parameters.
const fn new_c1(value: &'static str) -> Self { const fn new_c1(value: &'static str) -> Self {
ControlFunction { ControlFunction {
function_type: ControlFunctionType::C1, function_type: ControlFunctionType::C1,
@@ -152,7 +207,7 @@ impl ControlFunction {
} }
} }
/// Creates a new control function of type [ControlSequence][ControlFunctionType::ControlSequence]. /// Creates a new control function of type [`ControlSequence`][ControlFunctionType::ControlSequence].
const fn new_sequence(value: &'static str, parameters: Vec<String>) -> Self { const fn new_sequence(value: &'static str, parameters: Vec<String>) -> Self {
ControlFunction { ControlFunction {
function_type: ControlFunctionType::ControlSequence, function_type: ControlFunctionType::ControlSequence,
@@ -161,7 +216,8 @@ impl ControlFunction {
} }
} }
/// Creates a new control function of type [IndependentControlFunction][ControlFunctionType::IndependentControlFunction]. /// Creates a new control function of type
/// [`IndependentControlFunction`][ControlFunctionType::IndependentControlFunction].
const fn new_independent_control_function(value: &'static str) -> Self { const fn new_independent_control_function(value: &'static str) -> Self {
ControlFunction { ControlFunction {
function_type: ControlFunctionType::IndependentControlFunction, function_type: ControlFunctionType::IndependentControlFunction,
@@ -169,11 +225,94 @@ impl ControlFunction {
parameters: vec![], parameters: vec![],
} }
} }
fn format_parameters(&self) -> String {
self.parameters.join(ascii!(03 / 11))
}
}
impl fmt::Display for ControlFunction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.function_type {
ControlFunctionType::C0 => {
write!(f, "{}", self.value)
}
ControlFunctionType::C1 => {
write!(f, "{}{}", c0::ESC, self.value)
}
ControlFunctionType::ControlSequence => {
let parameters = self.format_parameters();
write!(f, "{}{}{}", c1::CSI, parameters, self.value)
}
ControlFunctionType::IndependentControlFunction => {
write!(f, "{}{}", c0::ESC, self.value)
}
}
}
}
impl fmt::Debug for ControlFunction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let function: String = self
.value
.as_bytes()
.into_iter()
.map(|b| format!("{:02}/{:02}", b >> 4, (b & 0xF)))
.collect();
f.debug_struct("ControlFunction")
.field("function_type", &self.function_type)
.field("function", &function)
.field("parameters", &self.parameters)
.finish()
}
}
impl From<ControlFunction> for String {
fn from(control_function: ControlFunction) -> Self {
format!("{}", control_function)
}
} }
pub mod c0; pub mod c0;
pub mod c1; pub mod c1;
pub mod categories;
pub mod control_sequences; pub mod control_sequences;
pub mod control_strings; pub mod control_strings;
pub mod independent_control_functions; pub mod independent_control_functions;
pub mod modes; pub mod modes;
#[cfg(test)]
mod tests {
use crate::c0::BEL;
use crate::ControlFunctionType;
/// Test the debug format of [`ControlFunctionType`].
#[test]
fn debug_control_function_type() {
assert_eq!(format!("{:?}", ControlFunctionType::C0), "C0");
assert_eq!(format!("{:?}", ControlFunctionType::C1), "C1");
assert_eq!(
format!("{:?}", ControlFunctionType::ControlSequence),
"Control Sequence"
);
assert_eq!(
format!("{:?}", ControlFunctionType::IndependentControlFunction),
"Independent Control Function"
);
}
/// Test the debug format of [`ControlFunction`][crate::ControlFunction].
#[test]
fn debug_control_function() {
assert_eq!(
format!("{:?}", BEL),
"ControlFunction { function_type: C0, function: \"00/07\", parameters: [] }"
);
assert_eq!(
format!("{:?}", crate::control_sequences::CUP(None, Some(10))),
"ControlFunction { function_type: Control Sequence, function: \"04/08\", parameters: [\"1\", \"10\"] }"
);
}
}

View File

@@ -1,123 +1,610 @@
//! Modes.
//!
//! The [ECMA-48][ecma-48] standard is intended to be applicable to a very large range of devices, in which there are
//! variations. Some of these variations have been formalized in the form of modes. They deal with the way in which a
//! device transmits, receives, processes, or images data. Each mode has two states. The reset state, and the set state.
//!
//! The states of the modes may be established explicitly in the data stream by the control functions SET MODE
//! ([`SM`][crate::control_sequences::SM]) and RESET MODE ([`RM`][crate::control_sequences::RM]) or may be established
//! by agreement between sender and recipient. In an implementation, some or all of the modes have one state only.
//!
//! To ensure data compatibility and ease of interchange with a variety of equipment the use of modes is deprecated. If
//! modes have to be implemented for backward compatibility it is recommended that the reset state of the modes be the
//! initial state. Otherwise, explicit agreements will have to be negotiated between sender and recipient, to the
//! detriment of "blind" interchange.
//!
//! ## Usage
//!
//! Two possibilities exist to use modes.
//!
//! ### Directly invoking `SM` or `RM` Control Functions
//!
//! You can pass modes to the arguments of the control functions SET MODE ([`SM`][crate::control_sequences::SM]) and
//! RESET MODE ([`RM`][crate::control_sequences::RM]).
//!
//! ```
//! use ansi_control_codes::control_sequences;
//! use ansi_control_codes::modes;
//!
//! // set the device component select mode to PRESENTATION.
//! print!("{}", control_sequences::SM(vec![modes::DCSM]));
//! // set the device component select mode to DATA.
//! print!("{}", control_sequences::RM(vec![modes::Mode::DeviceComponentSelectMode]));
//! ```
//!
//! ### Setting or Resetting Modes
//!
//! You can invoke the set and reset functions of a mode instead.
//!
//! ```
//! use ansi_control_codes::modes;
//!
//! // set the device component select mode to PRESENTATION.
//! print!("{}", modes::DCSM.set());
//! // set the device component select mode to DATA.
//! print!("{}", modes::Mode::DeviceComponentSelectMode.reset());
//! ```
//!
//! [ecma-48]: https://www.ecma-international.org/publications-and-standards/standards/ecma-48/
use crate::ControlFunction;
/// Device Modes. /// Device Modes.
#[derive(Clone, Copy, PartialEq, Eq)] #[derive(Clone, Copy, PartialEq, Eq)]
pub enum Mode { pub enum Mode {
/// Guarded Area Transfer Mode `GATM`. /// Guarded Area Transfer Mode `GATM`.
///
/// ## Reset: Guard
///
/// Only the contents of unguarded areas in an eligible area are transmitted or transferred.
///
/// ## Set: All
///
/// The contents of guarded as well as of unguarded areas in an eligible area are transmitted or transferred.
///
/// ## Note
///
/// No control functions are affected.
GuardedAreaTransferMode = 1, GuardedAreaTransferMode = 1,
/// Keyboard Action Mode `KAM`. /// Keyboard Action Mode `KAM`.
///
/// ## Reset: Enabled
///
/// All or part of the manual input facilities are enabled to be used.
///
/// ## Set: Disabled
///
/// All or part of the manual input facilities are disabled.
///
/// ## Note
///
/// No control functions are affected.
KeyboardActionMode, KeyboardActionMode,
/// Control Presentation Mode `CRM`. /// Control Presentation Mode `CRM`.
///
/// ## Reset: Control
///
/// All control functions are performed as defined; the way formator functions are processed depends on the setting
/// of the FORMAT EFFECTOR ACTION MODE ([`FEAM`]). A device may choose to image the graphical representations of
/// control functions in addition to performing them.
///
/// ## Set: Graphic
///
/// All control functions, except RESET MODE ([`RM`]), are treated as graphic characters. A device may choose to
/// perform some control functions in addition to storing them and imaging their graphical representations.
ControlPresentationMode, ControlPresentationMode,
/// Insertion Replacement Mode `IRM`. /// Insertion Replacement Mode `IRM`.
///
/// ## Reset: Replace
///
/// The graphic symbol of a graphic character or of a control function, for which a graphical representation is
/// required, replaces (or, depending upon the implementation, is combined with) the graphic symbol imaged at the
/// active presentation position.
///
/// ## Set: Insert
///
/// The graphic symbol of a graphic character or of a control function, for which a graphical representation is
/// required, is inserted at the active presentation position.
///
/// ## Note
///
/// Only control functions for which a graphical representation is required are affected.
InsertionReplacementMode, InsertionReplacementMode,
/// Status Report Transfer Mode `SRTM`. /// Status Report Transfer Mode `SRTM`.
///
/// ## Reset: Normal
///
/// Status reports in the form of DEVICE CONTROL STRINGs ([`DCS`][crate::c1::DCS]) are not generated automatically.
///
/// ## Set: Diagnostic
///
/// Status reports in the form of DEVICE CONTROL STRINGs ([`DCS`][crate::c1::DCS]) are included in every data stream
/// transmitted or transferred.
///
/// ## Note:
///
/// No control functions are affected.
StatusReportTransferMode, StatusReportTransferMode,
/// Erasure Mode `ERM`. /// Erasure Mode `ERM`.
///
/// ## Reset: Protect
///
/// Only the contents of unprotected areas are affected by an erasure control function.
///
/// ## Set: All
///
/// The contents of protected as well as of unprotected areas are affected by an erasure control function.
///
/// ## Note
///
/// Control functions affected are: [`EA`][crate::control_sequences::EA], [`ECH`][crate::control_sequences::ECH],
/// [`ED`][crate::control_sequences::ED], [`EF`][crate::control_sequences::EF],
/// [`EL`][crate::control_sequences::EL].
ErasureMode, ErasureMode,
/// Line Editing Mode `VEM`. /// Line Editing Mode `VEM`.
///
/// ## Reset: Following
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`]) is set to PRESENTATION, a line insertion causes the contents of
/// the active line (the line that contains the active presentation position) and of the following lines in the
/// presentation component to be shifted in the direction of the line progression; a line deletion causes the
/// contents of the lines following the active line to be shifted in the direction opposite to that of the line
/// progression.
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`]) is set to DATA, a line insertion causes the contents of the
/// active line (the line that contains the active data position) and of the following lines in the data component
/// to be shifted in the direction of the line progression; a line deletion causes the contents of the lines
/// following the active line to be shifted in the direction opposite to that of the line progression.
///
/// ## Set: Preceding
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`]) is set to PRESENTATION, a line insertion causes the contents of
/// the active line (the line that contains the active presentation position) and of the preceding lines to be
/// shifted in the direction opposite to that of the line progression; a line deletion causes the contents of the
/// lines preceding the active line to be shifted in the direction of the line progression.
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`]) is set to DATA, a line insertion causes the contents of the
/// active line (the line that contains the active data position) and of the preceding lines to be shifted in the
/// direction opposite to that of the line progression; a line deletion causes the contents of the lines preceding
/// the active line to be shifted in the direction of the line progression.
///
/// ## Note
///
/// Control functions affected are: [`DL`][crate::control_sequences::DL], [`IL`][crate::control_sequences::IL].
LineEditingMode, LineEditingMode,
/// Bi-directional support mode `BDSM`. /// Bi-directional support mode `BDSM`.
///
/// ## Reset: Explicit
///
/// Control functions are performed in the data component or in the presentation component, depending on the setting
/// of the DEVICE COMPONENT SELECT MODE ([`DeviceComponentSelectMode`][Mode::DeviceComponentSelectMode]).
///
/// ## Set: Implicit
///
/// Control functions are performed in the data component. All bi-directional aspects of data are handled by the
/// device itself.
BiDirectionalSupportMode, BiDirectionalSupportMode,
/// Device Component Select Mode `DCSM`. /// Device Component Select Mode `DCSM`.
///
/// ## Reset: Presentation
///
/// Certain control functions are performed in the presentation component. The active presentation position (or the
/// active line, where applicable) in the presentation component is the reference position against which the
/// relevant control functions are performed.
///
/// ## Set: Data
///
/// Certain control functions are performed in the data component. The active data position (or the active line,
/// where applicable) in the data component is the reference position against which the relevant control functions
/// are performed.
///
/// ## Note
///
/// Control functions affected are: [`CPR`][crate::control_sequences::CPR], [`CR`][crate::c0::CR],
/// [`DCH`][crate::control_sequences::DCH], [`DL`][crate::control_sequences::DL],
/// [`EA`][crate::control_sequences::EA], [`ECH`][crate::control_sequences::ECH],
/// [`ED`][crate::control_sequences::ED], [`EF`][crate::control_sequences::EF],
/// [`EL`][crate::control_sequences::EF], [`ICH`][crate::control_sequences::ICH],
/// [`IL`][crate::control_sequences::IL], [`LF`][crate::c0::LF], [`NEL`][crate::c1::NEL], [`RI`][crate::c1::RI],
/// [`SLH`][crate::control_sequences::SLH], [`SLL`][crate::control_sequences::SLL],
/// [`SPH`][crate::control_sequences::SPH], [`SPL`][crate::control_sequences::SPH].
DeviceComponentSelectMode, DeviceComponentSelectMode,
/// Character Editing Mode `HEM`. /// Character Editing Mode `HEM`.
///
/// ## Reset: Following
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`]) is set to PRESENTATION, a character insertion causes the contents
/// of the active presentation position and of the following character positions in the presentation component to be
/// shifted in the direction of the character path; a character deletion causes the contents of the character
/// positions following the active presentation position to be shifted in the direction opposite to that of the
/// character path
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`]) is set to DATA, a character insertion causes the contents of the
/// active data position and of the following character positions in the data component to be shifted in the
/// direction of the character progression; a character deletion causes the contents of the character positions
/// following the active data position to be shifted in the direction opposite to that of the character progression.
///
/// ## Set: Preceding
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`]) is set to PRESENTATION, a character insertion causes the contents
/// of the active presentation position and of the following character positions in the presentation component to be
/// shifted in the direction opposite to that of the character path; a character deletion causes the contents of the
/// character positions following the active presentation position to be shifted in the direction of the character
/// path.
///
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`]) is set to DATA, a character insertion causes the contents of the
/// active data position and of preceding character positions in the data component to be shifted in the direction
/// opposite to that of the character progression; a character deletion causes the contents of the character
/// positions preceding the active data position to be shifted in the direction of the character progression.
///
/// ## Note
///
/// Control functions affected are: [`DCH`][crate::control_sequences::DCH], [`ICH`][crate::control_sequences::ICH].
CharacterEditingMode, CharacterEditingMode,
/// Positioning Unit Mode `PUM`. /// Positioning Unit Mode `PUM`.
///
/// ## Reset: Character
///
/// The unit for numeric parameters of the positioning format effectors is one character position.
///
/// ## Set: Size
///
/// The unit for numeric parameters of the positioning format effectors is that established by the parameter value
/// of SELECT SIZE UNIT ([`SSU`][crate::control_sequences::SSU]).
///
/// ## Note 1
///
/// Control functions affected are: [`CUB`][crate::control_sequences::CUB], [`CUD`][crate::control_sequences::CUD],
/// [`CUF`][crate::control_sequences::CUF], [`CUU`][crate::control_sequences::CUU],
/// [`HPA`][crate::control_sequences::HPA], [`HPB`][crate::control_sequences::HPB],
/// [`HPR`][crate::control_sequences::HPR], [`HVP`][crate::control_sequences::HVP],
/// [`SLH`][crate::control_sequences::SLH], [`SLL`][crate::control_sequences::SLL],
/// [`SSU`][crate::control_sequences::SSU], [`VPA`][crate::control_sequences::VPA],
/// [`VPB`][crate::control_sequences::VPB], [`VPR`][crate::control_sequences::VPR].
///
/// ## Note 2
///
/// As the default parameter value of the control function SELECT SIZE UNIT (SSU) is CHARACTER, this mode is
/// redundant and should no longer be used.
///
/// # Note 3
///
/// The use of the POSITIONING UNIT MODE ([`PUM`]) is deprecated.
PositioningUnitMode, PositioningUnitMode,
/// Send/Receive Mode `SRM`. /// Send/Receive Mode `SRM`.
///
/// ## Reset: Monitor
///
/// Data which are locally entered are immediately imaged.
///
/// ## Set: Simultaneous
///
/// Local input facilities are logically disconnected from the output mechanism; only data which are sent to the
/// device are imaged.
///
/// ## Note
///
/// No control functions are affected.
SendReceiveMode, SendReceiveMode,
/// Format Effector Action Mode `FEAM`. /// Format Effector Action Mode `FEAM`.
///
/// ## Reset: Execute
///
/// Formator functions are performed immediately and may be stored in addition to being performed.
///
/// ## Set: Store
///
/// Formator functions are stored but not performed. In this case, the specified action is intended to be performed
/// by another device when the associated data are transmitted or transferred.
///
/// ## Note
///
/// Control functions affected are: [`BPH`][crate::c1::BPH], [`BS`][crate::c0::BS], [`CR`][crate::c0::CR],
/// [`DTA`][crate::control_sequences::DTA], [`FF`][crate::c0::FF], [`FNT`][crate::control_sequences::FNT],
/// [`GCC`][crate::control_sequences::GCC], [`GSM`][crate::control_sequences::GSM],
/// [`GSS`][crate::control_sequences::GSS], [`HPA`][crate::control_sequences::HPA],
/// [`HPB`][crate::control_sequences::HPB], [`HPR`][crate::control_sequences::HPR],
/// [`HT`][crate::c0::HT], [`HTJ`][crate::c1::HTJ], [`HTS`][crate::c1::HTS], [`HVP`][crate::control_sequences::HVP],
/// [`JFY`][crate::control_sequences::JFY], [`NEL`][crate::c1::NEL], [`PEC`][crate::control_sequences::PEC],
/// [`PFS`][crate::control_sequences::PFS], [`PLD`][crate::c1::PLD], [`PLU`][crate::c1::PLU],
/// [`PPA`][crate::control_sequences::PPA], [`PPB`][crate::control_sequences::PPB],
/// [`PPR`][crate::control_sequences::PPR], [`PTX`][crate::control_sequences::PTX],
/// [`QUAD`][crate::control_sequences::QUAD], [`RI`][crate::c1::RI], [`SACS`][crate::control_sequences::SACS],
/// [`SAPV`][crate::control_sequences::SAPV], [`SCO`][crate::control_sequences::SCO],
/// [`SCS`][crate::control_sequences::SCS], [`SGR`][crate::control_sequences::SGR],
/// [`SHS`][crate::control_sequences::SHS], [`SLH`][crate::control_sequences::SLH],
/// [`SLL`][crate::control_sequences::SLL], [`SLS`][crate::control_sequences::SLS],
/// [`SPD`][crate::control_sequences::SPD], [`SPI`][crate::control_sequences::SPI],
/// [`SPQR`][crate::control_sequences::SPQR], [`SRCS`][crate::control_sequences::SRCS],
/// [`SRS`][crate::control_sequences::SRS], [`SSU`][crate::control_sequences::SSU],
/// [`SSW`][crate::control_sequences::SSW], [`STAB`][crate::control_sequences::STAB],
/// [`SVS`][crate::control_sequences::SVS], [`TAC`][crate::control_sequences::TAC],
/// [`TALE`][crate::control_sequences::TALE], [`TATE`][crate::control_sequences::TATE],
/// [`TBC`][crate::control_sequences::TBC], [`TCC`][crate::control_sequences::TCC],
/// [`TSS`][crate::control_sequences::TSS], [`VPA`][crate::control_sequences::VPA],
/// [`VPB`][crate::control_sequences::VPB], [`VPR`][crate::control_sequences::VPR],
/// [`VTS`][crate::c1::VTS].
FormatEffectorActionMode, FormatEffectorActionMode,
/// Format Effector Transfer Mode `FETM`. /// Format Effector Transfer Mode `FETM`.
///
/// ## Reset: Insert
///
/// Formator functions may be inserted in a data stream to be transmitted or in data to be transferred to an
/// auxiliary input/output device.
///
/// ## Set: Exclude
///
/// No formator functions other than those received while the FORMAT EFFECTOR ACTION MODE [`FEAM`] is set to
/// STORE are included in a transmitted data stream or in data transferred to an auxiliary input/output device.
///
/// ## Note
///
/// No control functions are affected.
FormatEffectorTransferMode, FormatEffectorTransferMode,
/// Multiple Area Transfer Mode `MATM`. /// Multiple Area Transfer Mode `MATM`.
///
/// ## Reset: Single
///
/// Only the contents of the selected area which contains the active presentation position are eligible to be
/// transmitted or transferred
///
/// ## Set: Multiple
///
/// The contents of all selected areas are eligible to be transmitted or transferred.
///
/// ## Note
///
/// No control functions are affected.
MultipleAreaTransferMode, MultipleAreaTransferMode,
/// Transfer Termination Mode `TTM`. /// Transfer Termination Mode `TTM`.
///
/// ## Reset: Cursor
///
/// Only the contents of the character positions preceding the active presentation position in the presentation
/// component are eligible to be transmitted or transferred.
///
/// ## Set: All
///
/// The contents of character positions preceding, following, and at the active presentation position are eligible
/// to be transmitted or transferred.
///
/// ## Note
///
/// No control functions are affected.
TransferTerminationMode, TransferTerminationMode,
/// Selected Area Transfer Mode `SATM`. /// Selected Area Transfer Mode `SATM`.
///
/// ## Reset: Select
///
/// Only the contents of selected areas are eligible to be transmitted or transferred.
///
/// ## Set: All
///
/// The contents of all character positions, irrespective of any explicitly defined selected areas, are eligible to
/// be transmitted or transferred.
///
/// ## Note
///
/// No control functions are affected.
SelectedAreaTransferMode, SelectedAreaTransferMode,
/// Tabulation Stop Mode `TSM`. /// Tabulation Stop Mode `TSM`.
///
/// ## Reset: Multiple
///
/// Character tabulation stops in the presentation component are set or cleared in the active line (the line that
/// contains the active presentation position) and in the corresponding character positions of the preceding lines
/// and of the following lines.
///
/// ## Set: Single
///
/// Character tabulation stops in the presentation component are set or cleared in the active line only.
///
/// ## Note
///
/// Control functions affected are: [`CTC`][crate::control_sequences::CTC], [`DL`][crate::control_sequences::DL],
/// [`HTS`][crate::c1::HTS], [`IL`][crate::control_sequences::IL], [`TBC`][crate::control_sequences::TBC].
TabulationStopMode, TabulationStopMode,
/// Graphic Rendition Combination Mode `GRCM`. /// Graphic Rendition Combination Mode `GRCM`.
///
/// ## Reset: Replacing
///
/// Each occurrence of the control function SELECT GRAPHIC RENDITION ([`SGR`][crate::control_sequences::SGR])
/// cancels the effect of any preceding occurrence. Any graphic rendition aspects that are to remain unchanged after
/// an occurrence of [`SGR`][crate::control_sequences::SGR] have to be re-specified by that
/// [`SGR`][crate::control_sequences::SGR].
///
/// ## Set: Cumulative
///
/// Each occurrence of the control function SELECT GRAPHIC RENDITION ([`SGR`][crate::control_sequences::SGR]) causes
/// only those graphic rendition aspects to be changed that are specified by that
/// [`SGR`][crate::control_sequences::SGR]. All other graphic rendition aspects remain unchanged.
///
/// ## Note
///
/// Control function affected is [`SGR`][crate::control_sequences::SGR].
GraphicRenditionCombinationMode = 21, GraphicRenditionCombinationMode = 21,
/// Zero Default Mode `ZDM`. /// Zero Default Mode `ZDM`.
///
/// ## Reset: Zero
///
/// A parameter value of 0 of a control function means the number `0`.
///
/// ## Set: Default
///
/// A parameter value of `0` represents a default parameter value which may be different from `0`.
///
/// ## Note 1
///
/// This mode was provided for implementations of the first edition of this Standard which specified that "an empty
/// parameter sub-string or a parameter sub-string which consists of bit combinations `03/00` only represents a
/// default value which depends on the control function".
///
/// For numeric parameters which are expressed in units established by the parameter value of SELECT SIZE UNIT
/// ([`SSU`][crate::control_sequences::SSU]) the value `0` could then be specified. For numeric parameters which are
/// effectively repeat counts, a `0` parameter value corresponded to a "no-op". In either instance, non-negative
/// computed numeric parameter values might have been used without treating `0` as a special (unusable) case.
///
/// Where an explicit parameter value was not used, implementors were urged to omit a parameter value (use an empty
/// parameter sub-string) to imply a default parameter value.
///
/// Control functions affected are: [`CBT`][crate::control_sequences::CBT], [`CHA`][crate::control_sequences::CHA],
/// [`CHT`][crate::control_sequences::CHT], [`CNL`][crate::control_sequences::CNL],
/// [`CPL`][crate::control_sequences::CPL], [`CPR`][crate::control_sequences::CPR],
/// [`CUB`][crate::control_sequences::CUB], [`CUD`][crate::control_sequences::CUD],
/// [`CUF`][crate::control_sequences::CUF], [`CUP`][crate::control_sequences::CUP],
/// [`CUU`][crate::control_sequences::CUU], [`CVT`][crate::control_sequences::CVT],
/// [`DCH`][crate::control_sequences::DCH], [`DL`][crate::control_sequences::DL],
/// [`ECH`][crate::control_sequences::ECH], [`GSM`][crate::control_sequences::GSM],
/// [`HPA`][crate::control_sequences::HPA], [`HPB`][crate::control_sequences::HPB],
/// [`HPR`][crate::control_sequences::HPR], [`HVP`][crate::control_sequences::HVP],
/// [`ICH`][crate::control_sequences::ICH], [`IL`][crate::control_sequences::IL],
/// [`NP`][crate::control_sequences::NP], [`PP`][crate::control_sequences::PP],
/// [`PPA`][crate::control_sequences::PPA], [`PPB`][crate::control_sequences::PPB],
/// [`PPR`][crate::control_sequences::PPR], [`REP`][crate::control_sequences::REP],
/// [`SD`][crate::control_sequences::SD], [`SL`][crate::control_sequences::SL],
/// [`SR`][crate::control_sequences::SR], [`SU`][crate::control_sequences::SU],
/// [`TCC`][crate::control_sequences::TCC], [`VPA`][crate::control_sequences::VPA],
/// [`VPB`][crate::control_sequences::VPB], [`VPR`][crate::control_sequences::VPR].
///
/// ## Note 2
///
/// Since the publication of the first edition of this Standard in 1976 almost 15 years have expired. The use of
/// this mode should no longer be required because the definition of default parameter values has been changed.
///
/// # Note 3
///
/// The use of the ZERO DEFAULT MODE ([`ZDM`]) is deprecated.
ZeroDefaultMode, ZeroDefaultMode,
} }
use crate::control_sequences::{RM, SM};
impl Mode {
/// Set the mode.
pub fn set(self) -> ControlFunction {
SM(vec![self])
}
/// Reset the mode.
pub fn reset(self) -> ControlFunction {
RM(vec![self])
}
}
/// Guarded Area Transfer Mode `GATM`. /// Guarded Area Transfer Mode `GATM`.
///
/// See [`Mode::GuardedAreaTransferMode`].
pub const GATM: Mode = Mode::GuardedAreaTransferMode; pub const GATM: Mode = Mode::GuardedAreaTransferMode;
/// Keyboard Action Mode `KAM`. /// Keyboard Action Mode `KAM`.
///
/// See [`Mode::KeyboardActionMode`].
pub const KAM: Mode = Mode::KeyboardActionMode; pub const KAM: Mode = Mode::KeyboardActionMode;
/// Control Presentation Mode `CRM`. /// Control Presentation Mode `CRM`.
///
/// See [`Mode::ControlPresentationMode`].
pub const CRM: Mode = Mode::ControlPresentationMode; pub const CRM: Mode = Mode::ControlPresentationMode;
/// Insertion Replacement Mode `IRM`. /// Insertion Replacement Mode `IRM`.
///
/// See [`Mode::InsertionReplacementMode`].
pub const IRM: Mode = Mode::InsertionReplacementMode; pub const IRM: Mode = Mode::InsertionReplacementMode;
/// Status Report Transfer Mode `SRTM`. /// Status Report Transfer Mode `SRTM`.
///
/// See [`Mode::StatusReportTransferMode`].
pub const SRTM: Mode = Mode::StatusReportTransferMode; pub const SRTM: Mode = Mode::StatusReportTransferMode;
/// Erasure Mode `ERM`. /// Erasure Mode `ERM`.
///
/// See [`Mode::ErasureMode`].
pub const ERM: Mode = Mode::ErasureMode; pub const ERM: Mode = Mode::ErasureMode;
/// Line Editing Mode `VEM`. /// Line Editing Mode `VEM`.
///
/// See [`Mode::LineEditingMode`].
pub const VEM: Mode = Mode::LineEditingMode; pub const VEM: Mode = Mode::LineEditingMode;
/// Bi-directional support mode `BDSM`. /// Bi-directional support mode `BDSM`.
///
/// See [`Mode::BiDirectionalSupportMode`].
pub const BDSM: Mode = Mode::BiDirectionalSupportMode; pub const BDSM: Mode = Mode::BiDirectionalSupportMode;
/// Device Component Select Mode `DCSM`. /// Device Component Select Mode `DCSM`.
///
/// See [`Mode::DeviceComponentSelectMode`].
pub const DCSM: Mode = Mode::DeviceComponentSelectMode; pub const DCSM: Mode = Mode::DeviceComponentSelectMode;
/// Character Editing Mode `HEM`. /// Character Editing Mode `HEM`.
///
/// See [`Mode::CharacterEditingMode`].
pub const HEM: Mode = Mode::CharacterEditingMode; pub const HEM: Mode = Mode::CharacterEditingMode;
/// Positioning Unit Mode `PUM`. /// Positioning Unit Mode `PUM`.
///
/// See [`Mode::PositioningUnitMode`].
pub const PUM: Mode = Mode::PositioningUnitMode; pub const PUM: Mode = Mode::PositioningUnitMode;
/// Send/Receive Mode `SRM`. /// Send/Receive Mode `SRM`.
///
/// See [`Mode::SendReceiveMode`].
pub const SRM: Mode = Mode::SendReceiveMode; pub const SRM: Mode = Mode::SendReceiveMode;
/// Format Effector Action Mode `FEAM`. /// Format Effector Action Mode `FEAM`.
///
/// See [`Mode::FormatEffectorActionMode`].
pub const FEAM: Mode = Mode::FormatEffectorActionMode; pub const FEAM: Mode = Mode::FormatEffectorActionMode;
/// Format Effector Transfer Mode `FETM`. /// Format Effector Transfer Mode `FETM`.
///
/// See [`Mode::FormatEffectorTransferMode`].
pub const FETM: Mode = Mode::FormatEffectorTransferMode; pub const FETM: Mode = Mode::FormatEffectorTransferMode;
/// Multiple Area Transfer Mode `MATM`. /// Multiple Area Transfer Mode `MATM`.
///
/// See [`Mode::MultipleAreaTransferMode`].
pub const MATM: Mode = Mode::MultipleAreaTransferMode; pub const MATM: Mode = Mode::MultipleAreaTransferMode;
/// Transfer Termination Mode `TTM`. /// Transfer Termination Mode `TTM`.
///
/// See [`Mode::TransferTerminationMode`].
pub const TTM: Mode = Mode::TransferTerminationMode; pub const TTM: Mode = Mode::TransferTerminationMode;
/// Selected Area Transfer Mode `SATM`. /// Selected Area Transfer Mode `SATM`.
///
/// See [`Mode::SelectedAreaTransferMode`].
pub const SATM: Mode = Mode::SelectedAreaTransferMode; pub const SATM: Mode = Mode::SelectedAreaTransferMode;
/// Tabulation Stop Mode `TSM`. /// Tabulation Stop Mode `TSM`.
///
/// See [`Mode::TabulationStopMode`].
pub const TSM: Mode = Mode::TabulationStopMode; pub const TSM: Mode = Mode::TabulationStopMode;
/// Graphic Rendition Combination Mode `GRCM`. /// Graphic Rendition Combination Mode `GRCM`.
///
/// See [`Mode::GraphicRenditionCombinationMode`].
pub const GRCM: Mode = Mode::GraphicRenditionCombinationMode; pub const GRCM: Mode = Mode::GraphicRenditionCombinationMode;
/// Zero Default Mode `ZDM`. /// Zero Default Mode `ZDM`.
///
/// See [`Mode::ZeroDefaultMode`].
pub const ZDM: Mode = Mode::ZeroDefaultMode; pub const ZDM: Mode = Mode::ZeroDefaultMode;