ansi_control_codes/
c1.rs

1//! Elements of the C1 set.
2//!
3//! These control functions are represented in 7-bit codes by escape sequences of the form `ESC Fe`, where `ESC` is
4//! represented by bit combination `01/11` and `Fe` is represented by a bit combination from `04/00` to `05/15`.
5//!
6//! The unallocated bit combinations are reserved for future standardization and shall not be used.
7//!
8//! The 3-character escape sequence designating and invoking this c1 set is `ESC 02/06 04/00` and `ESC 02/02 F`.
9//! see [`ANNOUNCER_SEQUENCE`], and [`ALTERNATIVE_ANNOUNCER_SEQUENCE`].
10//!
11//! ## Usage
12//!
13//! You can use the Elements of the C1 set inside normal strings, format them with the `format!()` macro, or print
14//! them with the `print!()` and `println!()` macros.
15//!
16//! For example, designate the C1 set, then set a character tabulation stop.
17//!
18//! ```
19//! use ansi_control_codes::c1::{ANNOUNCER_SEQUENCE, HTS};
20//! println!("{}{}", ANNOUNCER_SEQUENCE, HTS);
21//! ```
22//!
23//! ## Overview of the C1 Set
24//!
25//! | Row Number | Column `04` | Column `05` |
26//! | ---------: | :---------: | :---------: |
27//! |       `00` |     --      |   [`DCS`]   |
28//! |       `01` |     --      |   [`PU1`]   |
29//! |       `02` |   [`BPH`]   |   [`PU2`]   |
30//! |       `03` |   [`NBH`]   |   [`STS`]   |
31//! |       `04` |     --      |   [`CCH`]   |
32//! |       `05` |   [`NEL`]   |   [`MW`]    |
33//! |       `06` |   [`SSA`]   |   [`SPA`]   |
34//! |       `07` |   [`ESA`]   |   [`EPA`]   |
35//! |       `08` |   [`HTS`]   |   [`SOS`]   |
36//! |       `09` |   [`HTJ`]   |     --      |
37//! |       `10` |   [`VTS`]   |   [`SCI`]   |
38//! |       `11` |   [`PLD`]   |   [`CSI`]   |
39//! |       `12` |   [`PLU`]   |    [`ST`]   |
40//! |       `13` |    [`RI`]   |   [`OSC`]   |
41//! |       `14` |   [`SS2`]   |    [`PM`]   |
42//! |       `15` |   [`SS3`]   |   [`APC`]   |
43
44use crate::ControlFunction;
45
46macro_rules! c1 {
47    ($xx:literal/$yy:literal) => {
48        ControlFunction::new_c1(ascii!($xx / $yy))
49    };
50}
51
52/// Announcer Sequence for C1.
53///
54/// Designate the C1 set of control functions as the active set of control functions.
55///
56/// ## Note
57///
58/// The use of this escape sequence implies that all control function of this C1 set must be implemented.
59pub const ANNOUNCER_SEQUENCE: &str = ascii!(01 / 11, 02 / 06, 04 / 00);
60
61/// Alternative Announcer Sequence for C1.
62///
63/// Designate the C1 set of control functions as the active set of control functions.
64///
65/// ## Note
66///
67/// The use of this escape sequence implies that all control function of this C1 set must be implemented.
68pub const ALTERNATIVE_ANNOUNCER_SEQUENCE: &str = ascii!(01 / 11, 02 / 02, 04 / 06);
69
70/// Application Program Command.
71///
72/// `APC` is used as the opening delimiter of a control string for application program use. The command string following
73/// may consist of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control string is closed
74/// by the terminating delimiter String Terminator ([`ST`]). The interpretation of the command string depends on the
75/// relevant application program.
76pub const APC: ControlFunction = c1!(05 / 15);
77
78/// Break Permitted Here.
79///
80/// `BPH` is used to indicate a point where a line break may occur when text is formatted. `BPH` may occur between two
81/// graphic characters, either or both of which may be `SPACE`.
82pub const BPH: ControlFunction = c1!(04 / 02);
83
84/// Cancel Character.
85///
86/// `CCH` is used to indicate that both the preceding graphic character in the data stream (represented by one or more
87/// bit combinations), including `SPACE`, and the control function `CCH` itself are to be ignored for further
88/// interpretation of the data stream.
89///
90/// If the character preceding `CCH` in the data stream is a control function (represented by one or more bit
91/// combinations), the effect of `CCH` is not defined.
92pub const CCH: ControlFunction = c1!(05 / 04);
93
94/// Control Sequence Introducer.
95///
96/// `CSI` is used as the first character of a control sequence. See [control_sequences][crate::control_sequences].
97pub const CSI: ControlFunction = c1!(05 / 11);
98
99/// Device Control String.
100///
101/// `DCS` is used as the opening delimiter of a control string for device control use. The command string following may
102/// consist of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control string is closed by
103/// the terminating delimiter STRING TERMINATOR ([`ST`]).
104///
105/// The command string represents either one or more commands for the receiving device, or one or more status reports
106/// from the sending device. The purpose and the format of the command string are specified by the most recent
107/// occurrence of IDENTIFY DEVICE CONTROL STRING ([`IDCS`][crate::control_sequences::IDCS]), if any, or depend on the
108/// sending and/or the receiving device.
109pub const DCS: ControlFunction = c1!(05 / 00);
110
111/// End Of Guarded Area.
112///
113/// `EPA` is used to indicate that the active presentation position is the last of a string of character positions in
114/// the presentation component, the contents of which are protected against manual alteration, are guarded against
115/// transmission or transfer, depending on the setting of GUARDED AREA TRANSFER MODE ([`GATM`][crate::modes::GATM]),
116/// and may be protected against erasure, depending on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
117/// The beginning of this string is indicated by START OF GUARDED AREA ([`SPA`]).
118///
119/// ## Note
120///
121/// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`],
122/// [`SSA`]) should not be used within an [`SRS`][crate::control_sequences::SRS] string or an
123/// [`SDS`][crate::control_sequences::SDS] string.
124pub const EPA: ControlFunction = c1!(05 / 07);
125
126/// End Of Selected Area.
127///
128/// `ESA` is used to indicate that the active presentation position is the last of a string of character positions in
129/// the presentation component, the contents of which are eligible to be transmitted in the form of a data stream or
130/// transferred to an auxiliary input/output device. The beginning of the string is indicated by START OF SELECTED
131/// AREA ([`SSA`])
132///
133/// ## Note
134///
135/// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`],
136/// [`SSA`]) should not be used within an [`SRS`][crate::control_sequences::SRS] string or an
137/// [`SDS`][crate::control_sequences::SDS] string.
138pub const ESA: ControlFunction = c1!(04 / 07);
139
140/// Character Tabulation With Justification.
141///
142/// `HTJ` causes the contents of the active field (the field in the presentation component that contains the active
143/// presentation position) to be shifted forward so that it ends at the character position preceding the following
144/// character tabulation stop. The active presentation position is moved to that following character tabulation stop.
145/// The character positions which precede the beginning of the shifted string are put into the erased state.
146pub const HTJ: ControlFunction = c1!(04 / 09);
147
148/// Character Tabulation Set.
149///
150/// `HTS` causes a character tabulation stop to be set at the active presentation position in the presentation
151/// component.
152///
153/// The number of lines affected depends on the setting of the TABULATION STOP MODE ([`TSM`][crate::modes::TSM]).
154pub const HTS: ControlFunction = c1!(04 / 08);
155
156/// Message Waiting.
157///
158/// `MW` is used to set a message waiting indicator in the receiving device. An appropriate acknowledgement to the
159/// receipt of `MW` may be given by using DEVICE STATUS REPORT ([`DSR`][crate::control_sequences::DSR]).
160pub const MW: ControlFunction = c1!(05 / 05);
161
162/// No Break Here.
163///
164/// `NBH` is used to indicate a point where a line break shall not occur when text is formatted. `NBH` may occur between
165/// two graphic characters either or both of which may be `SPACE`.
166pub const NBH: ControlFunction = c1!(04 / 03);
167
168/// Next Line.
169///
170/// The effect of `NEL` depends on the setting of the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) and on
171/// the parameter value of SELECT IMPLICIT MOVEMENT DIRECTION ([`SIMD`][crate::control_sequences::SIMD]).
172///
173/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION and with a parameter value
174/// of [`SIMD`][crate::control_sequences::SIMD] equal to
175/// [`Normal`][crate::control_sequences::MovementDirection::Normal], `NEL` causes the active presentation position to be
176/// moved to the line home position of the following line in the presentation component. The line home position is
177/// established by the parameter value of SET LINE HOME ([`SLH`][crate::control_sequences::SLH]).
178///
179/// With a parameter value of [`SIMD`][crate::control_sequences::SIMD] equal to
180/// [`Opposite`][crate::control_sequences::MovementDirection::Opposite], `NEL` causes the active presentation position
181/// to be moved to the line limit position of the following line in the presentation component. The line limit position
182/// is established by the parameter value of SET LINE LIMIT ([`SLL`][crate::control_sequences::SLL]).
183///
184/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA and with a parameter value of
185/// [`SIMD`][crate::control_sequences::SIMD] equal to [`Normal`][crate::control_sequences::MovementDirection::Normal],
186/// `NEL` causes the active data position to be moved to the line home position of the following line in the data
187/// component. The line home position is established by the parameter value of SET LINE HOME
188/// ([`SLH`][crate::control_sequences::SLH]).
189///
190/// With a parameter value of [`SIMD`][crate::control_sequences::SIMD] equal to
191/// [`Opposite`][crate::control_sequences::MovementDirection::Opposite], `NEL` causes the active data position to be
192/// moved to the line limit position of the following line in the data component. The line limit position is established
193/// by the parameter value of SET LINE LIMIT ([`SLL`][crate::control_sequences::SLL]).
194pub const NEL: ControlFunction = c1!(04 / 05);
195
196/// Operating System Command
197///
198/// `OSC` is used as the opening delimiter of a control string for operating system use. The command string following
199/// may consist of a sequence of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control
200/// string is closed by the terminating delimiter STRING TERMINATOR ([`ST`]). The interpretation of the command string
201/// depends on the relevant operating system.
202pub const OSC: ControlFunction = c1!(05 / 13);
203
204/// Partial Line Forward.
205///
206/// `PLD` causes the active presentation position to be moved in the presentation component to the corresponding
207/// position of an imaginary line with a partial offset in the direction of the line progression. This offset should be
208/// sufficient either to image following characters as subscripts until the first following occurrence of PARTIAL LINE
209/// BACKWARD ([`PLU`]) in the data stream, or, if preceding characters were imaged as superscripts, to restore imaging
210/// of following characters to the active line (the line that contains the active presentation position).
211///
212/// Any interactions between `PLD` and format effectors other than [`PLU`] are not defined.
213pub const PLD: ControlFunction = c1!(04 / 11);
214
215/// Partial Line Backwards.
216///
217/// `PLU` causes the active presentation position to be moved in the presentation component to the corresponding
218/// position of an imaginary line with a partial offset in the direction opposite to that of the line progression. This
219/// offset should be sufficient either to image following characters as superscripts until the first following
220/// occurrence of PARTIAL LINE FORWARD ([`PLD`]) in the data stream, or, if preceding characters were imaged as
221/// subscripts, to restore imaging of following characters to the active line (the line that contains the active
222/// presentation position).
223///
224/// Any interactions between `PLU` and format effectors other than [`PLD`] are not defined.
225pub const PLU: ControlFunction = c1!(04 / 12);
226
227/// Privacy Message.
228///
229/// `PM` is used as the opening delimiter of a control string for privacy message use. The command string following may
230/// consist of a sequence of bit combinations in the range `00/08` to `00/13` and `02/00` to `07/14`. The control string
231/// is closed by the terminating delimiter STRING TERMINATOR ([`ST`]). The interpretation of the command string depends
232/// on the relevant privacy discipline.
233pub const PM: ControlFunction = c1!(05 / 14);
234
235/// Private Use One.
236///
237/// `PU1` is reserved for a function without standardized meaning for private use as required, subject to the prior
238/// agreement between the sender and the recipient of the data.
239pub const PU1: ControlFunction = c1!(05 / 01);
240
241/// Private Use Two.
242///
243/// `PU2` is reserved for a function without standardized meaning for private use as required, subject to the prior
244/// agreement between the sender and the recipient of the data.
245pub const PU2: ControlFunction = c1!(05 / 02);
246
247/// Reverse Line Feed.
248///
249/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `RI` causes the active
250/// presentation position to be moved in the presentation component to the corresponding character position of the
251/// preceding line feed.
252///
253/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `RI` causes the active data
254/// position to be moved in the data component to the corresponding character position of the preceding line.
255pub const RI: ControlFunction = c1!(04 / 13);
256
257/// Single Character Introducer.
258///
259/// `SCI` and the bit combination following it are used to represent a control function or a graphic character. The bit
260/// combination following `SCI` must be from `00/08` to `00/13` or `02/00` to `07/14`. The use of `SCI` is reserved
261/// for future standardization.
262pub const SCI: ControlFunction = c1!(05 / 10);
263
264/// Start of String.
265///
266/// `SOS` is used as the opening delimiter of a control string. The character string following may consist of any bit
267/// combination, except those representing `SOS` or STRING TERMINATOR ([`ST`]). The control string is closed by the
268/// terminating delimiter STRING TERMINATOR ([`ST`]). The interpretation of the character string depends on the
269/// application.
270pub const SOS: ControlFunction = c1!(05 / 08);
271
272/// Start of Guarded Area.
273///
274/// `SPA` is used to indicate that the active presentation position is the first of a string of character positions in
275/// the presentation component, the contents of which are protected against manual alteration, are guarded against
276/// transmission or transfer, depending on the setting of the GUARDED AREA TRANSFER MODE ([`GATM`][crate::modes::GATM])
277/// and may be protected against erasure, depending on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
278/// The end of this string is indicated by END OF GUARDED AREA (`EPA`).
279///
280/// ## Note
281///
282/// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`],
283/// [`SSA`]) should not be used within an [`SRS`][crate::control_sequences::SRS] string or an
284/// [`SDS`][crate::control_sequences::SDS] string.
285pub const SPA: ControlFunction = c1!(05 / 06);
286
287/// Start of Selected Area.
288///
289/// `SSA` is used to indicate that the active presentation position is the first of a string of character positions in
290/// the presentation component, the contents of which are eligible to be transmitted in the form of a data stream or
291/// transferred to an auxiliary input/output device.
292///
293/// The end of this string is indicated by END OF SELECTED AREA ([`ESA`]). The string of characters actually transmitted
294/// or transferred depends on the setting of the GUARDED AREA TRANSFER MODE ([`GATM`][crate::modes::GATM]) and on any
295/// guarded areas established by DEFINE AREA QUALIFICATION ([`DAQ`][crate::control_sequences::DAQ]), or by START OF
296/// GUARDED AREA ([`SPA`]) and END OF GUARDED AREA ([`EPA`]).
297///
298/// ## Note
299///
300/// The control functions for area definition ([`DAQ`][crate::control_sequences::DAQ], [`EPA`], [`ESA`], [`SPA`],
301/// [`SSA`]) should not be used within an [`SRS`][crate::control_sequences::SRS] string or an
302/// [`SDS`][crate::control_sequences::SDS] string.
303pub const SSA: ControlFunction = c1!(04 / 06);
304
305/// Single-Shift Two.
306///
307/// `SS2` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data
308/// stream to be changed.
309///
310/// The use of `SS2` is defined in Standard [ECMA-35][ecma-35].
311///
312/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
313pub const SS2: ControlFunction = c1!(04 / 14);
314
315/// Single-Shift Three.
316///
317/// `SS3` is used for code extension purposes. It causes the meanings of the bit combinations following it in the data
318/// stream to be changed.
319///
320/// The use of `SS3` is defined in Standard [ECMA-35][ecma-35].
321///
322/// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
323pub const SS3: ControlFunction = c1!(04 / 15);
324
325/// String Terminator.
326///
327/// `ST` is used as the closing delimiter of a control string opened by APPLICATION PROGRAM COMMAND ([`APC`]), DEVICE
328/// CONTROL STRING ([`DCS`]), OPERATING SYSTEM COMMAND ([`OSC`]), PRIVACY MESSAGE ([`PM`]), or START OF STRING
329/// ([`SOS`]).
330pub const ST: ControlFunction = c1!(05 / 12);
331
332/// Set Transmit State.
333///
334/// `STS` is used to establish the transmit state in the receiving device. In this state the transmission of data from
335/// the device is possible.
336///
337/// The actual initiation of transmission of data is performed by a data communication or input/output interface control
338/// procedure which is outside the scope of this Standard.
339///
340/// The transmit state is established either by `STS` appearing in the received data stream or by the operation of an
341/// appropriate key on a keyboard.
342pub const STS: ControlFunction = c1!(05 / 03);
343
344/// Line Tabulation Set.
345///
346/// `VTS` causes a line tabulation stop to be set at the active line (the line that contains the active presentation
347/// position).
348pub const VTS: ControlFunction = c1!(04 / 10);