ansi_control_codes/independent_control_functions.rs
1//! Independent Control Functions.
2//!
3//! These control functions are represented in 7-bit codes by 2-character escape sequences of the form `ESC Fs`, where
4//! `ESC` is represented by bit combination `01/11` and `Fs` is represented by a bit combination from `06/00` to
5//! `07/14`.
6//!
7//! ## Usage
8//!
9//! You can use the independent control functions inside normal strings, format them with the `format!()` macro, or
10//! print them with the `print!()` and `println!()` macros.
11//!
12//! For example, to disable manual input:
13//!
14//! ```
15//! use ansi_control_codes::independent_control_functions::DMI;
16//! println!("{}", DMI);
17//! ```
18//!
19//! ## Overview of the Independent Control Functions
20//!
21//! | Row Number | Column `06` | Column `07` |
22//! | ---------: | :---------: | :---------: |
23//! | `00` | [`DMI`] | -- |
24//! | `01` | [`INT`] | -- |
25//! | `02` | [`EMI`] | -- |
26//! | `03` | [`RIS`] | -- |
27//! | `04` | [`CMD`] | -- |
28//! | `05` | -- | -- |
29//! | `06` | -- | -- |
30//! | `07` | -- | -- |
31//! | `08` | -- | -- |
32//! | `09` | -- | -- |
33//! | `10` | -- | -- |
34//! | `11` | -- | -- |
35//! | `12` | -- | [`LS3R`] |
36//! | `13` | -- | [`LS2R`] |
37//! | `14` | [`LS2`] | [`LS1R`] |
38//! | `15` | [`LS3`] | -- |
39//!
40//! ## Note
41//!
42//! `ESC Fs` sequences are registered in the ISO International Register of Coded Character Sets to be Used with Escape
43//! Sequences, which is maintained by the Registration Authority for ISO 2375.
44
45use crate::ControlFunction;
46
47macro_rules! independent {
48 ($xx:literal/$yy:literal) => {
49 ControlFunction::new_independent_control_function(ascii!($xx / $yy))
50 };
51}
52
53/// Coding Method Delimiter.
54///
55/// `CMD` is used as the delimiter of a string of data coded according to Standard ECMA-35, and to switch to a general
56/// level of control.
57///
58/// The use of `CMD` is not mandatory if the higher level protocol defines means of delimiting the string, for instance,
59/// by specifying the length of the string.
60pub const CMD: ControlFunction = independent!(06 / 04);
61
62/// Disable Manual Input
63///
64/// `DMI` causes the manual input facilities of a device to be disabled.
65pub const DMI: ControlFunction = independent!(06 / 00);
66
67/// Enable Manual Input.
68///
69/// `EMI` is used to enable the manual input facilities of a device.
70pub const EMI: ControlFunction = independent!(06 / 02);
71
72/// Interrupt.
73///
74/// `INT` is used to indicate to the receiving device that the current process is to be interrupted and an agreed
75/// procedure is to be initiated. This control function is applicable to either direction of transmission.
76pub const INT: ControlFunction = independent!(06 / 01);
77
78/// Locking-Shift One Right.
79///
80/// `LS1R` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
81/// stream to be changed.
82///
83/// The use of `LS1R` is defined in Standard [ECMA-35][ecma-35].
84///
85/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
86pub const LS1R: ControlFunction = independent!(07 / 14);
87
88/// Locking-Shift Two.
89///
90/// `LS2` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
91/// stream to be changed.
92///
93/// The use of `LS2` is defined in Standard [ECMA-35][ecma-35].
94///
95/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
96pub const LS2: ControlFunction = independent!(06 / 14);
97
98/// Locking-Shift Two Right.
99///
100/// `LS2R` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
101/// stream to be changed.
102///
103/// The use of `LS2R` is defined in Standard [ECMA-35][ecma-35].
104///
105/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
106pub const LS2R: ControlFunction = independent!(07 / 13);
107
108/// Locking-Shift Three.
109///
110/// `LS3` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
111/// stream to be changed.
112///
113/// The use of `LS3` is defined in Standard [ECMA-35][ecma-35].
114///
115/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
116pub const LS3: ControlFunction = independent!(06 / 15);
117
118/// Locking-Shift Three Right.
119///
120/// `LS3R` is used for code extension purposes. It causes the meaning of the bit combinations following it in the data
121/// stream to be changed.
122///
123/// The use of `LS3R` is defined in Standard [ECMA-35][ecma-35].
124///
125/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
126pub const LS3R: ControlFunction = independent!(07 / 12);
127
128/// Reset to Initial State.
129///
130/// `RIS` causes a device to be reset to its initial state, i.e. the state it has after it is made operational. This
131/// may imply, if applicable: clear tabulation stops, remove qualified areas, reset graphic rendition, put all character
132/// positions into the erased state, move the active presentation position to the first position of the first line in
133/// the presentation component, move the active data position to the first character position of the first line in the
134/// data component, set the modes into the reset state, etc..
135pub const RIS: ControlFunction = independent!(06 / 03);