ansi_control_codes/
control_sequences.rs

1//! Control Sequences.
2//!
3//! A control sequence is a string of bit combinations starting with the control function Control Sequence Introducer
4//! (`CSI`), followed by one or more bit combinations representing parameters, if any, and by one or more bit
5//! combinations identifying the control function. The control function `CSI` itself is an element of the
6//! [C1][crate::c1] set.
7//!
8//! ## Usage
9//!
10//! You can use the control sequences inside normal strings, format them with the `format!()` macro, or print
11//! them with the `print!()` and `println!()` macros.
12//!
13//! For example, move the cursor to line 5, character 13:
14//!
15//! ```
16//! use ansi_control_codes::control_sequences::CUP;
17//! print!("{}", CUP(Some(5), Some(13)));
18//! ```
19//!
20//! ## Overview of the Control Sequences
21//!
22//! ### Without Intermediate Bytes
23//!
24//! | Row Number | Column `04` | Column `05` | Column `06` |
25//! | ---------: | :---------: | :---------: | :---------: |
26//! |       `00` |   [`ICH`]   |   [`DCH`]   |   [`HPA`]   |
27//! |       `01` |   [`CUU`]   |   [`SEE`]   |   [`HPR`]   |
28//! |       `02` |   [`CUD`]   |   [`CPR`]   |   [`REP`]   |
29//! |       `03` |   [`CUF`]   |   [`SU`]    |   [`DA`]    |
30//! |       `04` |   [`CUB`]   |   [`SD`]    |   [`VPA`]   |
31//! |       `05` |   [`CNL`]   |   [`NP`]    |   [`VPR`]   |
32//! |       `06` |   [`CPL`]   |   [`PP`]    |   [`HVP`]   |
33//! |       `07` |   [`CHA`]   |   [`CTC`]   |   [`TBC`]   |
34//! |       `08` |   [`CUP`]   |   [`ECH`]   |   [`SM`]    |
35//! |       `09` |   [`CHT`]   |   [`CVT`]   |   [`MC`]    |
36//! |       `10` |   [`ED`]    |   [`CBT`]   |   [`HPB`]   |
37//! |       `11` |   [`EL`]    |   [`SRS`]   |   [`VPB`]   |
38//! |       `12` |   [`IL`]    |   [`PTX`]   |   [`RM`]    |
39//! |       `13` |   [`DL`]    |   [`SDS`]   |   [`SGR`]   |
40//! |       `14` |   [`EF`]    |   [`SIMD`]  |   [`DSR`]   |
41//! |       `15` |   [`EA`]    |      --     |   [`DAQ`]   |
42//!
43//! ### With Intermediate Bytes `02/00`
44//!
45//! | Row Number | Column `04` | Column `05` | Column `06` |
46//! | ---------: | :---------: | :---------: | :---------: |
47//! |       `00` |   [`SL`]    |   [`PPA`]   |  [`TATE`]   |
48//! |       `01` |   [`SR`]    |   [`PPR`]   |  [`TALE`]   |
49//! |       `02` |   [`GSM`]   |   [`PPB`]   |   [`TAC`]   |
50//! |       `03` |   [`GSS`]   |   [`SPD`]   |   [`TCC`]   |
51//! |       `04` |   [`FNT`]   |   [`DTA`]   |   [`TSR`]   |
52//! |       `05` |   [`TSS`]   |   [`SLH`]   |   [`SCO`]   |
53//! |       `06` |   [`JFY`]   |   [`SLL`]   |  [`SRCS`]   |
54//! |       `07` |   [`SPI`]   |   [`FNK`]   |   [`SCS`]   |
55//! |       `08` |  [`QUAD`]   |  [`SPQR`]   |   [`SLS`]   |
56//! |       `09` |   [`SSU`]   |   [`SEF`]   |   [`SPH`]   |
57//! |       `10` |   [`PFS`]   |   [`PEC`]   |   [`SPL`]   |
58//! |       `11` |   [`SHS`]   |   [`SSW`]   |   [`SCP`]   |
59//! |       `12` |   [`SVS`]   |  [`SACS`]   |     --      |
60//! |       `13` |   [`IGS`]   |  [`SAPV`]   |     --      |
61//! |       `14` |     --      |  [`STAB`]   |     --      |
62//! |       `15` |  [`IDCS`]   |   [`GCC`]   |     --      |
63//!
64//! ## Note
65//!
66//! As intended by the standard, notation of control functions is kept identical to the definitions in the standard.
67//! This means that functions in this rust module will not follow the standard snake_case rust naming convention, but
68//! instead follow the ECMA standard. This is intended.
69#![allow(non_snake_case)]
70
71use crate::{modes::Mode, ControlFunction};
72
73macro_rules! sequence {
74    // numeric control sequence with no intermediate byte and no default value
75    ($xx:literal / $yy:literal, numeric $param:ident) => {
76        ControlFunction::new_sequence(ascii!($xx / $yy), vec![$param.to_string()])
77    };
78    // numeric control sequence with no intermediate byte and default value
79    ($xx:literal / $yy:literal, numeric $param:ident, default $default:literal) => {
80        ControlFunction::new_sequence(
81            ascii!($xx / $yy),
82            vec![$param.unwrap_or($default).to_string()],
83        )
84    };
85    // numeric control sequence with no intermediate byte, two parameters and default values
86    ($xx:literal / $yy:literal, numeric $param1:ident, default $default1:literal, numeric $param2:ident, default $default2:literal) => {
87        ControlFunction::new_sequence(
88            ascii!($xx / $yy),
89            vec![
90                $param1.unwrap_or($default1).to_string(),
91                $param2.unwrap_or($default2).to_string(),
92            ],
93        )
94    };
95    // selective control sequence with no intermediate byte and default value
96    ($xx:literal / $yy:literal, selective default $param:ident) => {
97        ControlFunction::new_sequence(
98            ascii!($xx / $yy),
99            vec![($param.unwrap_or_default() as u32).to_string()],
100        )
101    };
102    // selective control sequence with intermediate byte and default value
103    ($xx1:literal / $yy1:literal, $xx2:literal / $yy2:literal, selective default $param:ident) => {
104        ControlFunction::new_sequence(
105            ascii!($xx1 / $yy1, $xx2 / $yy2),
106            vec![($param.unwrap_or_default() as u32).to_string()],
107        )
108    };
109    // selective control sequence with intermediate byte and two default value
110    ($xx1:literal / $yy1:literal, $xx2:literal / $yy2:literal, selective default $param1:ident, selective default $param2:ident) => {
111        ControlFunction::new_sequence(
112            ascii!($xx1 / $yy1, $xx2 / $yy2),
113            vec![
114                ($param1.unwrap_or_default() as u32).to_string(),
115                ($param2.unwrap_or_default() as u32).to_string(),
116            ],
117        )
118    };
119    // numeric control sequence with intermediate byte, one parameters, and no default value
120    ($xx1:literal / $yy1:literal, $xx2:literal / $yy2:literal, numeric $param:ident) => {
121        ControlFunction::new_sequence(ascii!($xx1 / $yy1, $xx2 / $yy2), vec![$param.to_string()])
122    };
123    // numeric control sequence with intermediate byte, one parameters, and default value
124    ($xx1:literal / $yy1:literal, $xx2:literal / $yy2:literal, numeric $param:ident, default $default:literal) => {
125        ControlFunction::new_sequence(
126            ascii!($xx1 / $yy1, $xx2 / $yy2),
127            vec![$param.unwrap_or($default).to_string()],
128        )
129    };
130    // numeric control sequence with intermediate byte, two parameters, and no default value
131    ($xx1:literal / $yy1:literal, $xx2:literal / $yy2:literal, numeric $param1:ident, numeric $param2:ident) => {
132        ControlFunction::new_sequence(
133            ascii!($xx1 / $yy1, $xx2 / $yy2),
134            vec![$param1.to_string(), $param2.to_string()],
135        )
136    };
137    // numeric control sequence with intermediate byte, two parameters, and default values
138    ($xx1:literal / $yy1:literal, $xx2:literal / $yy2:literal, numeric $param1:ident, default $default1:literal, numeric $param2:ident, default $default2:literal) => {
139        ControlFunction::new_sequence(
140            ascii!($xx1 / $yy1, $xx2 / $yy2),
141            vec![
142                $param1.unwrap_or($default1).to_string(),
143                $param2.unwrap_or($default2).to_string(),
144            ],
145        )
146    };
147    // control sequence with variadic number of selective arguments
148    ($xx:literal / $yy: literal, variadic selective $vector:expr) => {
149        ControlFunction::new_sequence(
150            ascii!($xx / $yy),
151            $vector.iter().map(|e| (*e as u32).to_string()).collect(),
152        )
153    };
154}
155
156/// Cursor Backward Tabulation.
157///
158/// `CBT` causes the active presentation position to be moved to the character position corresponding to the `n`-th
159/// preceding character tabulation stop in the presentation component, according to the character path.
160///
161/// Default value for `n` is `1`.
162pub fn CBT(n: Option<u32>) -> ControlFunction<'static> {
163    sequence!(05 / 10, numeric n, default 1)
164}
165
166/// Cursor Character Absolute.
167///
168/// `CHA` causes the active presentation position to be moved to character position `n` in the active line in the
169/// presentation component.
170///
171/// Default value for `n` is `1`.
172pub fn CHA(n: Option<u32>) -> ControlFunction<'static> {
173    sequence!(04 / 07, numeric n, default 1)
174}
175
176/// Cursor Forward Tabulation.
177///
178/// `CHT` causes the active presentation position to be moved to the character position corresponding to the `n`-th
179/// following character tabulation stop in the presentation component, according to the character path.
180///
181/// Default value for `n` is `1`.
182pub fn CHT(n: Option<u32>) -> ControlFunction<'static> {
183    sequence!(04 / 09, numeric n, default 1)
184}
185
186/// Cursor Next Line.
187///
188/// `CNL` causes the active presentation position to be moved to the first character position of the `n`-th following
189/// line in the presentation component.
190///
191/// Default value for `n` is `1`.
192pub fn CNL(n: Option<u32>) -> ControlFunction<'static> {
193    sequence!(04 / 05, numeric n, default 1)
194}
195
196/// Cursor Preceding Line.
197///
198/// `CPL` causes the active presentation position to be moved to the first character position of the `n`-th preceding
199/// line in the presentation component.
200///
201/// Default value for `n` is `1`.
202pub fn CPL(n: Option<u32>) -> ControlFunction<'static> {
203    sequence!(04 / 06, numeric n, default 1)
204}
205
206/// Active Position Report.
207///
208/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `CPR` is used to report
209/// the active presentation position of the sending device as residing in the presentation component at the `n`-th line
210/// position according to the line progression and at the `m`-th character position according to the character path.
211///
212/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `CPR` is used to report the
213/// active data position of the sending device as residing in the data component at the `n`-th line position according
214/// to the line progression and at the `m`-th character position according to the character progression.
215///
216/// `CPR` may be solicited by a DEVICE STATUS REPORT ([`DSR`]) or be sent unsolicited.
217///
218/// Default value for `n` and `m` is `1`.
219pub fn CPR(n: Option<u32>, m: Option<u32>) -> ControlFunction<'static> {
220    sequence!(05 / 02, numeric n, default 1, numeric m, default 1)
221}
222
223/// Valid parameter values to the function [`CTC`].
224#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
225pub enum TabulationControl {
226    /// A character tabulation stop is set at the active presentation position.
227    #[default]
228    SetCharacterTabulationStop = 0,
229
230    /// A line tabulation stop is set at the active line (the line that contains the active presentation position).
231    SetLineTabulationStop,
232
233    /// The character tabulation stop at the active presentation position is cleared.
234    ClearCharacterTabulationStop,
235
236    /// The line tabulation stop at the active line is cleared.
237    ClearLineTabulationStop,
238
239    /// All character tabulation stops in the active line are cleared.
240    ClearCharacterTabulationStopsInLine,
241
242    /// All character tabulation stops are cleared.
243    ClearAllCharacterTabulationStops,
244
245    /// All line tabulation stops are cleared.
246    ClearAllLineTabulationStops,
247}
248
249/// Cursor Tabulation Control.
250///
251/// `CTC` causes one or more tabulation stops to be set or cleared in the presentation component, depending on the
252/// parameter value.
253///
254/// Default value for `s` is [`TabulationControl::SetCharacterTabulationStop`].
255pub fn CTC(s: Option<TabulationControl>) -> ControlFunction<'static> {
256    sequence!(05 / 07, selective default s)
257}
258
259/// Cursor Left.
260///
261/// `CUB` causes the active presentation position to be moved leftwards in the presentation component by `n` character
262/// positions, if the character path is horizontal, or by `n` line positions if the character path is vertical.
263///
264/// Default value for `n` is `1`.
265pub fn CUB(n: Option<u32>) -> ControlFunction<'static> {
266    sequence!(04 / 04, numeric n, default 1)
267}
268
269/// Cursor Down.
270///
271/// `CUD` causes the active presentation position to be moved downwards in the presentation component by `n` line
272/// positions, if the character path is horizontal, or by `n` character positions if the character path is vertical.
273///
274/// Default value for `n` is `1`.
275pub fn CUD(n: Option<u32>) -> ControlFunction<'static> {
276    sequence!(04 / 02, numeric n, default 1)
277}
278
279/// Cursor Right.
280///
281/// `CUF` causes the active presentation position to be moved rightwards in the presentation component by `n` character
282/// positions, if the character path is horizontal, or by `n` line positions if the character path is vertical.
283///
284/// Default value for `n` is `1`.
285pub fn CUF(n: Option<u32>) -> ControlFunction<'static> {
286    sequence!(04 / 03, numeric n, default 1)
287}
288
289/// Cursor Position.
290///
291/// `CUP` causes the active presentation position to be moved in the presentation component ot the `n`-th line position
292/// according to the line progression, and to the `m`-th character position according to the character path.
293///
294/// Default value for `n` and `m` is `1`.
295pub fn CUP(n: Option<u32>, m: Option<u32>) -> ControlFunction<'static> {
296    sequence!(04 / 08, numeric n, default 1, numeric m, default 1)
297}
298
299/// Cursor Up.
300///
301/// `CUU` causes the active presentation position to be moved upwards in the presentation component by `n` line
302/// positions, if the character path is horizontal, or by `n` character positions if the character path is vertical.
303///
304/// Default value for `n` is `1`.
305pub fn CUU(n: Option<u32>) -> ControlFunction<'static> {
306    sequence!(04 / 01, numeric n, default 1)
307}
308
309/// Cursor Line Tabulation.
310///
311/// `CVT` causes the active presentation position to be moved to the character position of the line corresponding to
312/// the `n`-th following line tabulation stop in the presentation component.
313///
314/// Default value for `n` is `1`.
315pub fn CVT(n: Option<u32>) -> ControlFunction<'static> {
316    sequence!(05 / 09, numeric n, default 1)
317}
318
319/// Valid parameter values to the function [`DA`].
320#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
321#[repr(u32)]
322pub enum DeviceAttributes {
323    /// Request identifying device attributes from a device.
324    #[default]
325    Request = 0,
326
327    /// Device attributes identification code.
328    Identify(u32),
329}
330
331/// Device Attributes.
332///
333/// With a parameter [`DeviceAttributes::Identify`] (not equal to 0), `DA` is used to identify the device which sends
334/// the `DA`. The parameter value is a device type identification code according to a register which is to be
335/// established.
336///
337/// If the parameter value is [`DeviceAttributes::Request`], `DA` is used to request an identifying `DA` from a device.
338///
339/// Default value for `s` is [`DeviceAttributes::Request`].
340pub fn DA(s: Option<DeviceAttributes>) -> ControlFunction<'static> {
341    let v = match s {
342        Some(DeviceAttributes::Request) => 0,
343        Some(DeviceAttributes::Identify(x)) => x,
344        None => 0,
345    };
346    sequence!(06 / 03, numeric v)
347}
348
349/// Valid parameter values to the function [`DAQ`].
350#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
351pub enum AreaQualification {
352    /// Unprotected and unguarded.
353    #[default]
354    UnprotectedUnguarded = 0,
355
356    /// Protected and guarded.
357    ProtectedGuarded,
358
359    /// Graphic character input.
360    GraphicCharacterInput,
361
362    /// Numeric input.
363    NumericInput,
364
365    /// Alphabetic input.
366    AlphabeticInput,
367
368    /// Input aligned on the last character position of the qualified area.
369    InputAlignedRight,
370
371    /// Fill with ZEROs.
372    FillZeros,
373
374    /// Set a character tabulation stop at the active presentation position (the first character position of the
375    /// qualified area) to indicate the beginning of a field.
376    SetCharacterTabulationStop,
377
378    /// Protected and unguarded
379    ProtectedUnguarded,
380
381    /// Fill with SPACEs
382    FillSpaces,
383
384    /// Input aligned on the first character position of the qualified area.
385    InputAlignedLeft,
386
387    /// The order of the character positions in the input field is reserved, i.e. the last position in each line becomes
388    /// the first and vice versa; input begins at the new first position.
389    Reversed,
390}
391
392/// Define Area Qualification.
393///
394/// `DAQ` is used to indicate that the active presentation position in the presentation component is the first character
395/// position of a qualified area. The last character position of the qualified area is the character position in the
396/// presentation component immediately preceding the first character position of the following qualified area.
397///
398/// The control function operates independently of the setting of the TABULATION STOP MODE ([`TSM`][crate::modes::TSM]).
399/// The character tabulation stop set by parameter value [`AreaQualification::SetCharacterTabulationStop`] applies to
400/// the active line only.
401///
402/// The default value for `s` is [`AreaQualification::UnprotectedUnguarded].
403///
404/// ## Note
405///
406/// The control functions for area definitions ([`DAQ`], [`EPA`][crate::c1::EPA], [`ESA`][crate::c1::ESA],
407/// [`SPA`][crate::c1::SPA], [`SSA`][crate::c1::SSA]) should not be used within an [`SRS`] string or an [`SDS`] string.
408pub fn DAQ(s: Option<AreaQualification>) -> ControlFunction<'static> {
409    sequence!(06 / 15, selective default s)
410}
411
412/// Delete Character.
413///
414/// If the DEVICE COMPONENT SELECT MODE ([`DSCM`][crate::modes::DCSM]) is set to PRESENTATION, `DCH` causes the contents
415/// of the active presentation position and, depending on the setting of the CHARACTER EDITING MODE
416/// ([`HEM`][crate::modes::HEM]), the contents of the `n-1` preceding or following character positions to be removed
417/// from the presentation component. The resulting gap is closed by shifting the contents of the adjacent character
418/// positions towards the active presentation position. At the other end of the shifted part, `n` character positions
419/// are put into the erased state.
420///
421/// The extent of the shifted part is established by SELECT EDITING EXTEND ([`SEE`]).
422///
423/// The effect of `DCH` on the start or end of a selected area, the start or end of a qualified area, or a tabulation
424/// stop in the shifted part is undefined.
425///
426/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `DCH` causes the contents of the
427/// active data position and, depending on the setting of the CHARACTER EDITING MODE ([`HEM`][crate::modes::HEM]), the
428/// contents of the `n-1` preceding or following character positions to be removed from the data component. The
429/// resulting gap is closed by shifting the contents of the adjacent character positions towards the active data
430/// position. At the other end of the shifted part, `n` character positions are put into the erased state.
431///
432/// Default value for `n` is `1`.
433pub fn DCH(n: Option<u32>) -> ControlFunction<'static> {
434    sequence!(05 / 00, numeric n, default 1)
435}
436
437/// Delete Line.
438///
439/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `DL` causes the contents
440/// of the active line (the line that contains the active presentation position) and, depending on the setting of the
441/// LINE EDITING MODE ([`VEM`][crate::modes::VEM]), the contents of the `n-1` preceding or following lines to be removed
442/// from the presentation component. The resulting gap is closed by shifting the contents of a number of adjacent lines
443/// towards the active line. At the other end of the shifted part, `n` lines are put into the erased state.
444///
445/// The active presentation position is moved to the line home position in the active line. The line home position is
446/// established by the parameter value of SET LINE HOME ([`SLH`]). If the TABULATION STOP MODE
447/// ([`TSM`][crate::modes::TSM]) is set to SINGLE, character tabulation stops are cleared in the lines that are put into
448/// the erased state.
449///
450/// The extent of the shifted part is established by SELECT EDITING EXTEND ([`SEE`]).
451///
452/// Any occurrences of the start or end of a selected area, the start or end of a qualified area, or a tabulation stop
453/// in the shifted part, are also shifted.
454///
455/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `DL` causes the contents of the
456/// active line (the line that contains the active data position) and, depending on the setting of the LINE EDITING MODE
457/// ([`VEM`][crate::modes::VEM]), the contents of the `n-1` preceding or following lines to be removed from the data
458/// component. The resulting gap is closed by shifting the contents of a number of adjacent lines towards the active
459/// line. At the other end of the shifted part, `n` lines are put into the erased state. The active data position is
460/// moved to the lines home position in the active line. The line home position is established by the parameter value of
461/// SET LINE HOME ([`SLH`]).
462///
463/// The default value for `n` is `1`.
464pub fn DL(n: Option<u32>) -> ControlFunction<'static> {
465    sequence!(04 / 13, numeric n, default 1)
466}
467
468/// Valid parameter values to the function [`DSR`].
469#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
470pub enum DeviceStatusReport {
471    /// The device is ready, no malfunction detected
472    #[default]
473    Ready = 0,
474
475    /// The device is busy, another [`DSR`] must be requested later.
476    BusyRepeat,
477
478    /// The device is busy, another [`DSR`] will be sent later.
479    BusyLater,
480
481    /// Some malfunction detected, another [`DSR`] must be requested later.
482    MalfunctionRepeat,
483
484    /// Some malfunction detected, another [`DSR`] will be sent later.
485    MalfunctionLater,
486
487    /// A device status report is requested.
488    RequestDeviceStatusReport,
489
490    /// A report of the active presentation position or of the active data position in the form of ACTIVE POSITION
491    /// REPORT ([`CPR`]) is requested.
492    RequestActivePositionReport,
493}
494
495/// Device Status Report.
496///
497/// `DSR` is used either to report the status of the sending device or to request a status report from the receiving
498/// device, depending on the parameter value.
499///
500/// `DSR` with parameter value [`DeviceStatusReport::Ready`], [`DeviceStatusReport::BusyRepeat`],
501/// [`DeviceStatusReport::BusyLater`], [`DeviceStatusReport::MalfunctionRepeat`], or
502/// [`DeviceStatusReport::MalfunctionLater`] may be sent either unsolicited or as a response to a request such as a
503/// `DSR` with a parameter value [`DeviceStatusReport::RequestDeviceStatusReport`] or MESSAGE WAITING
504/// ([`MW`][crate::c1::MW]).
505///
506/// The default value for `s` is [`DeviceStatusReport::Ready`].
507pub fn DSR(s: Option<DeviceStatusReport>) -> ControlFunction<'static> {
508    sequence!(06 / 14, selective default s)
509}
510
511/// Dimension Text Area.
512///
513/// `DTA` is used to establish the dimensions of the text area for subsequent pages.
514///
515/// The established dimensions remain in effect until the next occurrence of `DTA` in the data stream.
516///
517/// - `n` specifies the dimension in the direction perpendicular to the line orientation.
518/// - `m` specifies the dimension in the direction parallel to the line orientation.
519///
520/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
521/// (`SSU`).
522pub fn DTA(n: u32, m: u32) -> ControlFunction<'static> {
523    sequence!(02 / 00, 05 / 04, numeric n, numeric m)
524}
525
526/// Valid parameter values to the function [`EA`].
527#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
528pub enum EraseArea {
529    /// Erase from the active position until the end of the qualified area.
530    #[default]
531    ActivePositionToEnd = 0,
532
533    /// Erase from the beginning of the qualified area until (including) the active position.
534    BeginToActivePosition,
535
536    /// Erase all contents from the beginning of the qualified area until the end of the qualified area.
537    BeginToEnd,
538}
539
540/// Erase in Area.
541///
542/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `EA` causes some or all
543/// character positions in the active qualified area (the qualified area in the presentation component which contains
544/// the active presentation position) to be put into the erased state, depending on the parameter value.
545///
546/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `EA` causes some or all character
547/// positions in the active qualified area (the qualified area in the data component which contains the active data
548/// position) to be put into the erased state, depending ont he parameter value.
549///
550/// Whether the character positions of protected areas are put into the erased state, or the character positions of
551/// unprotected areas only, depends on the setting of ERASURE MODE ([`ERM`][crate::modes::ERM]).
552///
553/// The default value of `s` is [`EraseArea::ActivePositionToEnd`].
554pub fn EA(s: Option<EraseArea>) -> ControlFunction<'static> {
555    sequence!(04 / 15, selective default s)
556}
557
558/// Erase Character.
559///
560/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `ECH` causes the active
561/// presentation position and the `n-1` following character positions in the presentation component to be put into the
562/// erased state.
563///
564/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `ECH` causes the active data
565/// position and the `n-1` following character positions in the data component to be put into the erased state.
566///
567/// Whether the character positions of protected areas are put into the erased state, or the character positions of
568/// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
569///
570/// The default value for `n` is `1`.
571pub fn ECH(n: Option<u32>) -> ControlFunction<'static> {
572    sequence!(05 / 08, numeric n, default 1)
573}
574
575/// Valid parameter values to the function [`ED`].
576#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
577pub enum ErasePage {
578    /// Erase from the active position until the end of the page.
579    #[default]
580    ActivePositionToEnd = 0,
581
582    /// Erase from the beginning of the page until (including) the active position.
583    BeginToActivePosition,
584
585    /// Erase all contents from the beginning of the page until the end of the page.
586    BeginToEnd,
587}
588
589/// Erase In Page.
590///
591/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `ED` causes some or all
592/// character positions of the active page (the page which contains the active presentation position in the presentation
593/// component) to be/ put into the erased state, depending on the parameter value.
594///
595/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `ED` causes some or all character
596/// positions of the active page (the page which contains the active data position in the data component) to be put into
597/// the erased state, depending on the parameter value.
598///
599/// Whether the character positions of protected areas are put into the erased state, or the character positions of
600/// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
601///
602/// The default value of `s` is [`ErasePage::ActivePositionToEnd`].
603pub fn ED(s: Option<ErasePage>) -> ControlFunction<'static> {
604    sequence!(04 / 10, selective default s)
605}
606
607/// Valid parameter values to the function [`EF`].
608#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
609pub enum EraseField {
610    /// Erase from the active position until the end of the field.
611    #[default]
612    ActivePositionToEnd = 0,
613
614    /// Erase from the beginning of the field until (including) the active position.
615    BeginToActivePosition,
616
617    /// Erase all contents from the beginning of the field until the end of the field.
618    BeginToEnd,
619}
620
621/// Erase In Field.
622///
623/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `EF` causes some or all
624/// character positions of the active field (the field which contains the active presentation position in the
625/// presentation component) to be put into the erased state, depending on the parameter value.
626///
627/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `EF` causes some or all character
628/// positions of the active field (the field which contains the active data position in the data component) to be put
629/// into the erased state, depending on the parameter value.
630///
631/// Whether the character positions of protected areas are put into the erased state, or the character positions of
632/// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
633///
634/// The default value for `s` is [`EraseField::ActivePositionToEnd`].
635pub fn EF(s: Option<EraseField>) -> ControlFunction<'static> {
636    sequence!(04 / 14, selective default s)
637}
638
639/// Valid parameter values to the function [`EL`].
640#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
641pub enum EraseLine {
642    /// Erase from the active position until the end of the line.
643    #[default]
644    ActivePositionToEnd = 0,
645
646    /// Erase from the beginning of the line until (including) the active position.
647    BeginToActivePosition,
648
649    /// Erase all contents from the beginning of the line until the end of the line.
650    BeginToEnd,
651}
652
653/// Erase In Line.
654///
655/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `EL` causes some or all
656/// character positions of the active line (the line which contains the active presentation position in the presentation
657/// component) to be put into the erased state, depending on the parameter value.
658///
659/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `EL` causes some or all character
660/// positions of the active line (the line which contains the active data position in the data component) to be put into
661/// the erased state, depending on the parameter value.
662///
663/// Whether the character positions of protected areas are put into the erased state, or the character positions of
664/// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
665///
666/// The default value for `s` is [`EraseLine::ActivePositionToEnd`].
667pub fn EL(s: Option<EraseLine>) -> ControlFunction<'static> {
668    sequence!(04 / 11, selective default s)
669}
670
671/// Function Key.
672///
673/// `FNK` is a control function in which the parameter value identifies the function key which has been operated.
674pub fn FNK(n: u32) -> ControlFunction<'static> {
675    sequence!(02 / 00, 05 / 07, numeric n)
676}
677
678/// Valid parameter values to the function [`FNT`].
679#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
680pub enum Font {
681    /// Primary font.
682    #[default]
683    Primary = 0,
684
685    /// First alternative font.
686    Alternative1,
687
688    /// Second alternative font.
689    Alternative2,
690
691    /// Third alternative font.
692    Alternative3,
693
694    /// Forth alternative font.
695    Alternative4,
696
697    /// Fifth alternative font.
698    Alternative5,
699
700    /// Sixth alternative font.
701    Alternative6,
702
703    /// Seventh alternative font.
704    Alternative7,
705
706    /// Eighth alternative font.
707    Alternative8,
708
709    /// Ninth alternative font.
710    Alternative9,
711}
712
713/// Font Selection.
714///
715/// `FNT` is used to identify the character font to be selected as primary or alternative font by subsequent occurrences
716/// of SELECT GRAPHIC RENDITION ([`SGR`]) in the data stream.
717///
718/// - `s` specifies the primary or alternative font concerned.
719/// - `t` identifies the character font according to a register which is to be established.
720///
721/// The default value for `s` is [`Font::Primary`], and for `t` is `0`.
722pub fn FNT(s: Option<Font>, t: Option<u32>) -> ControlFunction<'static> {
723    let a = match s {
724        Some(font) => font as u32,
725        None => (Font::default()) as u32,
726    };
727    let b = t.unwrap_or(0);
728    sequence!(02 / 00, 04 / 04, numeric a, numeric b)
729}
730
731/// Valid parameter values to the function [`GCC`].
732#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
733pub enum GraphicCharacterCombination {
734    /// Combine the following two graphic characters into a single graphic symbol.
735    #[default]
736    CombineTwo = 0,
737
738    /// Combine all following graphic characters, until the occurrence of
739    /// [`GraphicCharacterCombination::EndOfCombination`] into a single graphic symbol.
740    StartOfCombination,
741
742    /// Combine all preceding graphic characters, starting from [`GraphicCharacterCombination::StartOfCombination`],
743    /// into a single graphic symbol.
744    EndOfCombination,
745}
746
747/// Graphic Character Combination
748///
749/// `GCC` is used to indicate that two or more graphic characters are to be imaged as one single graphic symbol.
750///
751/// The default value of `s` is [`GraphicCharacterCombination::CombineTwo`].
752///
753/// ## Note
754///
755/// `GCC` does not explicitly specify the relative sizes or placements of the component parts of a composite graphic
756/// symbol. In the simplest case, two components may be "half-width" and side-by-side. For example in Japanese text a
757/// pair of characters may be presented side-by-side, and occupy the space of a normal-size Kanji character.
758pub fn GCC(s: Option<GraphicCharacterCombination>) -> ControlFunction<'static> {
759    sequence!(02 / 00, 05 / 15, selective default s)
760}
761
762/// Graphic Size Modification.
763///
764/// `GSM` is used to modify for subsequent text the height and / or the width of all primary and alternative fonts
765/// identified by FONT SELECT ([`FNT`]) and established by GRAPHIC SIZE SELECTION ([`GSS`]). The established values
766/// remain in effect until the next occurrence of `GSM` or [`GSS`] in the data stream.
767///
768/// - `h` specifies the height as a percentage of the height established by [`GSS`].
769/// - `w` specifies the width as a percentage of the width established by [`GSS`].
770///
771/// The default value for `h`, and `w` is `100`.
772pub fn GSM(h: Option<u32>, w: Option<u32>) -> ControlFunction<'static> {
773    sequence!(02 / 00, 04 / 02, numeric h, default 100, numeric w, default 100)
774}
775
776/// Graphic Size Selection.
777///
778/// `GSS` is used to establish for subsequent texts the height and the width of all primary and alternative fonts
779/// identified by FONT SELECT ([`FNT`]). The established values remain in effect until the next occurrence of `GSS` in the
780/// data stream.
781///
782/// - `n` specifies the height, the width is implicitly defined by the height.
783///
784/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
785/// ([`SSU`]).
786pub fn GSS(n: u32) -> ControlFunction<'static> {
787    sequence!(02 / 00, 04/03, numeric n)
788}
789
790/// Character Position Absolute.
791///
792/// `HPA` causes the active data position to be moved to character position `n` in the active line (the line in the data
793/// component that contains the active data position).
794///
795/// The default value for `n` is `1`.
796pub fn HPA(n: Option<u32>) -> ControlFunction<'static> {
797    sequence!(06 / 00, numeric n, default 1)
798}
799
800/// Character Position Backward.
801///
802/// `HPB` causes the active data position to be moved by `n` character positions in the data component in the direction
803/// opposite to that of the character progression.
804///
805/// The default value for `n` is `1`.
806pub fn HPB(n: Option<u32>) -> ControlFunction<'static> {
807    sequence!(06 / 10, numeric n, default 1)
808}
809
810/// Character Position Forward.
811///
812/// `HPR` causes the active data position to be moved by `n` character positions in the data component in the direction
813/// of the character progression.
814///
815/// The default value for `n` is `1`.
816pub fn HPR(n: Option<u32>) -> ControlFunction<'static> {
817    sequence!(06 / 01, numeric n, default 1)
818}
819
820/// Character And Line Position.
821///
822/// `HVP` causes the active data position to be moved in the data component to the `n`-th line position according to the
823/// line progression and to the `m`-th character position according to the character progression.
824///
825/// The default value for `n` and `m` is `1`.
826pub fn HVP(n: Option<u32>, m: Option<u32>) -> ControlFunction<'static> {
827    sequence!(06 / 06, numeric n, default 1, numeric m, default 1)
828}
829
830/// Insert Character.
831///
832/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `ICH` is used to prepare
833/// the insertion of `n` characters, by putting into the erased state the active presentation position and, depending on
834/// the setting of the CHARACTER EDITING MODE ([`HEM`][crate::modes::HEM]), the `n-1` preceding or following character
835/// positions in the presentation component. The previous contents of the active presentation position and an adjacent
836/// string of character positions are shifted away from the active presentation position. The contents of `n` character
837/// positions at the other end of the shifted part are removed. The active presentation position is moved to the line
838/// home position in the active line. The line home position is established by the parameter value of SET LINE HOME
839/// ([`SLH`]).
840///
841/// The extent of the shifted part is established by SELECT EDITING EXTENT ([`SEE`]).
842///
843/// The effect of `ICH` on the start or end of a selected area, the start or end of a qualified area, or a tabulation
844/// stop in the shifted part is undefined.
845///
846/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `ICH` is used to prepare the
847/// insertion of `n` characters, by putting into the erased state the active data position and, depending on the setting
848/// of the CHARACTER EDITING MODE ([`HEM`][crate::modes::HEM]), the `n-1` preceding or following character positions in
849/// the data component. The previous contents of the active data position and and adjacent string of character positions
850/// are shifted away from the active data position. The contents of `n` character positions at the other end of the
851/// shifted part are removed. The active data position is moved to the line home position in the active line. The line
852/// home position is established by the parameter value of SET LINE HOME ([`SLH`]).
853///
854/// The default value for `n` is `1`.
855pub fn ICH(n: Option<u32>) -> ControlFunction<'static> {
856    sequence!(04 / 00, numeric n, default 1)
857}
858
859/// Valid parameter values to the function [`IDCS`].
860#[derive(Debug, Clone, Copy, PartialEq, Eq)]
861#[repr(u32)]
862pub enum IdentifyDeviceControlString {
863    /// Reserved for use with the DIAGNOSTIC state of the STATUS REPORT TRANSFER MODE.
864    Diagnostic = 0,
865
866    /// Reserved for Dynamically Redefinable Character Sets according to Standard [ECMA-35][ecma-35].
867    ///
868    /// [ecma-35]: https://www.ecma-international.org/wp-content/uploads/ECMA-35_6th_edition_december_1994.pdf
869    DynamicallyRedefinableCharacterSet,
870
871    /// Private command string.
872    Private(u32),
873}
874
875/// Identify Device Control String.
876///
877/// `IDCS` is used to specify the purpose and format of the command string of subsequent DEVICE CONTROL STRINGS
878/// ([`DCS`][crate::c1::DCS]). The specified purpose and format remain in effect until the next occurrence of `IDCS`
879/// in the data stream.
880///
881/// The format and interpretation of the command string corresponding to the parameter `s` are to be defined in
882/// appropriate standards. If this control function is used to identify a private command string, a private parameter
883/// value shall be used [`IdentifyDeviceControlString::Private`].
884pub fn IDCS(s: IdentifyDeviceControlString) -> ControlFunction<'static> {
885    let v = match s {
886        IdentifyDeviceControlString::Private(i) => i,
887        IdentifyDeviceControlString::Diagnostic => 1,
888        IdentifyDeviceControlString::DynamicallyRedefinableCharacterSet => 2,
889    };
890
891    sequence!(02 / 00, 04 / 15, numeric v)
892}
893
894/// Identify Graphic Subrepertoire.
895///
896/// `IGS` is used to indicate that a repertoire of the graphic characters of ISO/IEC 10367 is used in the subsequent
897/// text.
898///
899/// The parameter value of `IGS` identifies a graphic character repertoire registered in accordance with ISO/IEC 7350.
900pub fn IGS(n: u32) -> ControlFunction<'static> {
901    sequence!(02 / 00, 04 / 13, numeric n)
902}
903
904/// Insert Line.
905///
906/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `IL` is used to prepare
907/// the insertion of `n` lines, by putting into the erased state in the presentation component the active line
908/// (the line that contains the active presentation position) and, depending on the setting of the LINE EDITING MODE
909/// ([`VEM`][crate::modes::VEM]), the `n-1` preceding or following lines. The previous contents of the active line and
910/// of adjacent lines are shifted away from the active line. The contents of `n` lines at the other end of the shifted
911/// part are removed. The active presentation position is moved to the line home position in the active line. The line
912/// home position is established by the parameter value of SET LINE HOME ([`SLH`]).
913///
914/// The extent of the shifted part is established by SELECT EDITING EXTENT ([`SEE`]).
915///
916/// Any occurrence of the start or end of a selected area, the start or end of a qualified area, or a tabulation stop in
917/// the shifted part, are also shifted.
918///
919/// If the TABULATION STOP MODE ([`TSM`][crate::modes::TSM]) is set to SINGLE, character tabulation stops are cleared in
920/// the lines that are put into the erased state.
921///
922/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `IL` is used to prepare the
923/// insertion of `n` lines, by putting into the erased state in the data component the active line (the line that
924/// contains the active data position) and, depending on the setting of the LINE EDITING MODE
925/// ([`VEM`][crate::modes::VEM]), the `n-1` preceding or following lines. The previous contents of the active line and
926/// of adjacent lines are shifted away from the active line. The contents of `n` lines at the other end of the shifted
927/// part are removed. The active data position is moved to the line home position in the active line. The line home
928/// position is established by the parameter value of SET LINE HOME ([`SLH`]).
929///
930/// The default value for `n` is `1`.
931pub fn IL(n: Option<u32>) -> ControlFunction<'static> {
932    sequence!(04 / 12, numeric n, default 1)
933}
934
935/// Valid parameter values to the function [`JFY`].
936#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
937pub enum Justification {
938    /// No justification, end of justification of preceding text.
939    #[default]
940    None = 0,
941
942    /// Word fill.
943    WordFill,
944
945    /// Word space.
946    WordSpace,
947
948    /// Letter space.
949    LetterSpace,
950
951    /// Hyphenation.
952    Hyphenation,
953
954    /// Flush to line home position margin.
955    Left,
956
957    /// Centre between line home position and line limit position margins.
958    Centre,
959
960    /// Flush to line limit position margin.
961    Right,
962
963    /// Italian hyphenation.
964    ItalianHyphenation,
965}
966
967/// Justify.
968///
969/// `JFY` is used to indicate the beginning of a string of graphic characters in the presentation component that are to
970/// be justified according to the layout specified by the parameter value.
971///
972/// The end of the string to be justified is indicated by the next occurrence of `JFY` in the data stream.
973///
974/// The line home position is established by the parameter value of SET LINE HOME ([`SLH`]). The line limit position is
975/// established by the parameter value of SET LINE LIMIT ([`SLL`]).
976///
977/// The default value of `s` is [`Justification::None`].
978pub fn JFY(s: Option<Justification>) -> ControlFunction<'static> {
979    sequence!(02 / 00, 04 / 06, selective default s)
980}
981
982/// Valid parameter values to the function [`MC`].
983#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
984pub enum MediaCopy {
985    /// Initiate transfer to a primary auxiliary device.
986    #[default]
987    BeginTransferToPrimary = 0,
988
989    /// Initiate transfer from a primary auxiliary device.
990    BeginTransferFromPrimary,
991
992    /// Initiate transfer to a secondary auxiliary device.
993    BeginTransferToSecondary,
994
995    /// Initiate transfer from a secondary auxiliary device.
996    BeginTransferFromSecondary,
997
998    /// Stop relay to a primary auxiliary device.
999    StopRelayPrimary,
1000
1001    /// Start relay to a primary auxiliary device.
1002    StartRelayPrimary,
1003
1004    /// Stop relay to a secondary auxiliary device.
1005    StopRelaySecondary,
1006
1007    /// Start relay to a secondary auxiliary device.
1008    StartRelaySecondary,
1009}
1010
1011/// Media Copy.
1012///
1013/// `MC` is used either to initiate a transfer of data from or to an auxiliary input/output device or to enable or
1014/// disable the relay of the received data stream to an auxiliary input/output device, depending on the parameter value.
1015///
1016/// The default value for `s` is [`MediaCopy::BeginTransferToPrimary`].
1017pub fn MC(s: Option<MediaCopy>) -> ControlFunction<'static> {
1018    sequence!(06 / 09, selective default s)
1019}
1020
1021/// Next Page.
1022///
1023/// `NP` causes the `n`-th following page in the presentation component to be displayed.
1024///
1025/// The effect of this control function on the active presentation position is not defined.
1026///
1027/// The default value for `n` is `1`.
1028pub fn NP(n: Option<u32>) -> ControlFunction<'static> {
1029    sequence!(05 / 05, numeric n, default 1)
1030}
1031
1032/// Valid parameter values to the function [`PEC`].
1033#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1034pub enum PresentationExpandContract {
1035    /// Normal, as specified by [`SCS`], [`SHS`] or [`SPI`].
1036    #[default]
1037    Normal = 0,
1038
1039    /// Expanded, multiplied by a factor not greater than `2`.
1040    Expanded,
1041
1042    /// Condensed, multiplied by a factor not less than `0.5`.
1043    Condensed,
1044}
1045
1046/// Presentation Expand or Contract.
1047///
1048/// `PEC` is used to establish the spacing and the extent of the graphic characters for subsequent text. The spacing is
1049/// specified in the line as multiples of the spacing established by the most recent occurrence of SET CHARACTER SPACING
1050/// ([`SCS`]) or of SELECT CHARACTER SPACING ([`SHS`]) or of SPACING INCREMENT ([`SPI`]) in the data stream. The extent
1051/// of the characters is implicitly established by these control functions. The established spacing and the extent
1052/// remain in effect until the next occurrence of `PEC`, of [`SCS`], of [`SHS`] or of [`SPI`] in the data stream.
1053///
1054/// The default value for `s` is [`PresentationExpandContract::Normal`].
1055pub fn PEC(s: Option<PresentationExpandContract>) -> ControlFunction<'static> {
1056    sequence!(02/00, 05/10, selective default s)
1057}
1058
1059/// Valid parameter values to the function [`PFS`].
1060#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1061pub enum PageFormat {
1062    /// Tall basic text communication format.
1063    #[default]
1064    TallBasicText = 0,
1065
1066    /// Wide basic text communication format.
1067    WideBasicText,
1068
1069    ///Tall basic A4 format.
1070    TallBasicA4,
1071
1072    /// Wide basic A4 format.
1073    WideBasicA4,
1074
1075    /// Tall North American letter format.
1076    TallLetter,
1077
1078    /// Wide North American letter format.
1079    WideLetter,
1080
1081    /// Tall extended A4 format.
1082    TallExtendedA4,
1083
1084    /// Wide extended A4 format.
1085    WideExtendedA4,
1086
1087    /// Tall North American legal format.
1088    TallLegal,
1089
1090    /// Wide North American legal format.
1091    WideLegal,
1092
1093    /// A4 short lines format.
1094    A4ShortLines,
1095
1096    /// A4 long lines format.
1097    A4LongLines,
1098
1099    /// B5 short lines format.
1100    B5ShortLines,
1101
1102    /// B5 long lines format
1103    B5LongLines,
1104
1105    /// B4 short lines format.
1106    B4ShortLines,
1107
1108    /// B4 long lines format
1109    B4LongLines,
1110}
1111
1112/// Page Format Selection
1113///
1114/// `PFS` is used to establish the available area for the imaging of pages of text based on paper size. The pages are
1115/// introduced by the subsequent occurrence of FORM FEED ([`FF`][crate::c0::FF]) in the data stream.
1116///
1117/// The established image area remains in effect until the next occurrence of `PFS` in the data stream.
1118///
1119/// The page home position is established by the parameter value of SET PAGE HOME ([`SPH`]), the page limit position is
1120/// established by the parameter value of SET PAGE LIMIT ([`SPL`]).
1121///
1122/// The default value for `s` is [`PageFormat::TallBasicText`].
1123pub fn PFS(s: Option<PageFormat>) -> ControlFunction<'static> {
1124    sequence!(02/00, 04/10, selective default s)
1125}
1126
1127/// Preceding Page.
1128///
1129/// `PP` causes the `n`-th preceding page in the presentation component to be displayed. The effect of this control
1130/// function on the active presentation position is not defined.
1131///
1132/// The default for `n` is `1`.
1133pub fn PP(n: Option<u32>) -> ControlFunction<'static> {
1134    sequence!(05 / 06, numeric n, default 1)
1135}
1136
1137/// Page Position Absolute.
1138///
1139/// `PPA` causes the active data position to be moved in the data component to the corresponding character position on
1140/// the `n-th` page.
1141///
1142/// The default for `n` is `1`.
1143pub fn PPA(n: Option<u32>) -> ControlFunction<'static> {
1144    sequence!(02 / 00, 05 / 00, numeric n, default 1)
1145}
1146
1147/// Page Position Backward.
1148///
1149/// `PPB` causes the active data position to be moved in the data component to the corresponding character position on
1150/// the `n-th` page.
1151///
1152/// The default value for `n` is `1`.
1153pub fn PPB(n: Option<u32>) -> ControlFunction<'static> {
1154    sequence!(02 / 00, 05 / 02, numeric n, default 1)
1155}
1156
1157/// Page Position Forward.
1158///
1159/// `PPR` causes the active data position to be moved in the data component to the corresponding character position on
1160/// the `n`-th following page.
1161///
1162/// The default value for `n` is `1`.
1163pub fn PPR(n: Option<u32>) -> ControlFunction<'static> {
1164    sequence!(02 / 00, 05 / 01, numeric n, default 1)
1165}
1166
1167/// Valid parameter values to the function [`PTX`].
1168#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1169pub enum ParallelText {
1170    /// End of parallel texts.
1171    #[default]
1172    End = 0,
1173
1174    /// Beginning of a string of principal parallel text.
1175    BeginPrincipal,
1176
1177    /// Beginning of a string of supplementary parallel text.
1178    BeginSupplementary,
1179
1180    /// Beginning of a string of supplementary Japanese phonetic annotation
1181    BeginJapanesePhonetic,
1182
1183    /// Beginning of a string of supplementary Chinese phonetic annotation
1184    BeginChinesePhonetic,
1185
1186    /// End of a string of supplementary phonetic annotations
1187    EndPhonetic,
1188}
1189
1190/// Parallel Texts.
1191///
1192/// `PTX` is used to delimit strings of graphic characters that are communicated one after another in the data stream,
1193/// but that are intended to be presented in parallel with one another, usually in adjacent lines.
1194///
1195/// `PTX` with a parameter value of [`ParallelText::BeginPrincipal`] indicates the beginning of the string of principal
1196/// text intended to be presented in parallel with one or more strings of supplementary text.
1197///
1198/// `PTX` with a parameter value of [`ParallelText::BeginSupplementary`], [`ParallelText::BeginJapanesePhonetic`], or
1199/// [`ParallelText::BeginChinesePhonetic`] indicates the beginning of a string of supplementary text that is intended to
1200/// be presented in parallel with either a string of principal text or the immediately preceding string of supplementary
1201/// text, if any; at the same time it indicates the end of the preceding string of principal text or of the immediately
1202/// preceding string of supplementary text, if any. The end of a string of supplementary text is indicated by a
1203/// subsequent occurrence of `PTX` with a parameter other than [`ParallelText::BeginPrincipal`].
1204///
1205/// `PTX` with a parameter value of [`ParallelText::End`] indicates the end of the strings of text intended to be
1206/// presented in parallel with one another.
1207///
1208/// The default value for `s` is [`ParallelText::End`].
1209///
1210/// ## Note
1211///
1212/// `PTX` does not explicitly specify the relative placement of the strings of principal and supplementary parallel
1213/// texts, or the relative sizes of graphic characters in the strings of parallel text. A string of supplementary text
1214/// is normally presented in a line adjacent to the line containing the string of principal text, or adjacent to the
1215/// line containing the immediately preceding string of supplementary text, if any. The first graphic character of the
1216/// string of principal text and the first graphic character of a string of supplementary text are normally presented
1217/// in the same position of their respective lines. However, a string of supplementary text longer (when presented)
1218/// than the associated string of principal text may be centred on that string. In the case of long strings of text,
1219/// such as paragraphs in different languages, the strings may be presented in successive lines in parallel columns,
1220/// with their beginnings aligned with one another and the shorter of the paragraphs followed by an appropriate amount
1221/// of "white space".
1222///
1223/// Japanese phonetic annotation typically consists of a few half-size or smaller Kana characters which indicate the
1224/// pronunciation or interpretation of one ore more Kanji characters and are presented above those Kanji characters if
1225/// the character path is horizontal, or to the right of them if the character path is vertical.
1226///
1227/// Chines phonetic annotation typically consists of a few Pinyin characters which indicate the pronunciation of one
1228/// or more Hanzi characters and are presented above those Hanzi characters. Alternatively, the Pinyin characters may
1229/// be presented in the same line as the Hanzi characters and following the respective Hanzi characters. The Pinyin
1230/// characters will then be presented within enclosing paris of parentheses.
1231pub fn PTX(s: Option<ParallelText>) -> ControlFunction<'static> {
1232    sequence!(05 / 12, selective default s)
1233}
1234
1235/// Valid parameter values to the function [`QUAD`].
1236#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1237pub enum Alignment {
1238    /// Flush to line home position margin.
1239    #[default]
1240    LineHome = 0,
1241
1242    /// Flush to line home position margin and fill with leader.
1243    LineHomeLeader,
1244
1245    /// Centre between line home position and line limit position margins.
1246    Centre,
1247
1248    /// Center between line home position and line limit position margins and fill with leader.
1249    CentreLeader,
1250
1251    /// Flush to line limit position margin.
1252    LineLimit,
1253
1254    /// Flush to line limit position margin and fill with leader.
1255    LineLimitLeader,
1256
1257    /// Flush to both margins
1258    Justify,
1259}
1260
1261/// Quad.
1262///
1263/// `QUAD` is used to indicate the end of a string of graphic characters that are to be positioned on a single line
1264/// according to the layout specified by the parameter value, see [`Alignment`].
1265///
1266/// The beginning of the string to be positioned is indicated by the preceding occurrence in the data stream of either
1267/// `QUAD` or one of the following formator functions: FORM FEED ([`FF`][crate::c0::FF]), CHARACTER AND LINE POSITION
1268/// ([`HVP`]), LINE FEED ([`LF`][crate::c0::LF]), NEXT LINE ([`NEL`][crate::c1::NEL]), PAGE POSITION ABSOLUTE
1269/// ([`PPA`]), PAGE POSITION BACKWARD ([`PPB`]), PAGE POSITION FORWARD ([`PPR`]), REVERSE LINE FEED
1270/// ([`RI`][crate::c1::RI]), LINE POSITION ABSOLUTE ([`VPA`]), LINE POSITION BACKWARD ([`VPB`]), LINE POSITION
1271/// FORWARD ([`VPR`]), or LINE TABULATION ([`VT`][crate::c0::VT]).
1272///
1273/// The line home position is established by the parameter value of SET LINE HOME ([`SLH`]). The line limit position is
1274/// established by the parameter value of SET LINE LIMIT ([`SLL`]).
1275///
1276/// The default value for `s` is [`Alignment::LineHome`].
1277pub fn QUAD(s: Option<Alignment>) -> ControlFunction<'static> {
1278    sequence!(02 / 00, 04 / 08, selective default s)
1279}
1280
1281/// Repeat.
1282///
1283/// `REP` is used to indicate that the preceding character in the data stream, if it is a graphic character (presented
1284/// by one or more bit combinations) including SPACE, is to be repeated `n` times. If the character preceding `REP` is
1285/// a control function or part of a control function, the effect of `REP` is not defined.
1286///
1287/// The default value for `n` is `1`.
1288pub fn REP(n: Option<u32>) -> ControlFunction<'static> {
1289    sequence!(06 / 02, numeric n, default 1)
1290}
1291
1292/// Reset Mode.
1293///
1294/// `RM` causes the modes of the receiving device to be reset as specified by the parameter values.
1295pub fn RM(v: Vec<Mode>) -> ControlFunction<'static> {
1296    sequence!(06 / 12, variadic selective v)
1297}
1298
1299/// Set Additional Character Representation.
1300///
1301/// `SACS` is used to establish extra inter-character escapement for subsequent text. The established extra escapement
1302/// remains in effect until the next occurrence of `SACS` or of SET REDUCED CHARACTER SEPARATION ([`SRCS`]) in the data
1303/// stream or until it is reset to the default value by a subsequent occurrence of CARRIAGE RETURN LINE FEED
1304/// ([`CR`][crate::c0::CR] [`LF`][crate::c0::LF]) or of NEXT LINE ([`NEL`][crate::c1::NEL]) in the data stream.
1305///
1306/// `n` specifies the number of units by which the inter-character escapement is enlarged.
1307///
1308/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
1309/// ([`SSU`]).
1310///
1311/// The default value for `n` is 0.
1312pub fn SACS(n: Option<u32>) -> ControlFunction<'static> {
1313    sequence!(02 / 00, 05 / 12, numeric n, default 0)
1314}
1315
1316/// Valid parameter values to the function [`SAPV`].
1317#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1318pub enum PresentationVariant {
1319    /// Default presentation (implementation-defined); cancels the effect of any preceding occurrence of [`SAPV`] in the
1320    /// data stream.
1321    #[default]
1322    Default = 0,
1323
1324    /// The decimal digits are presented by means of the graphic symbols used in the Latin script.
1325    LatinDecimals,
1326
1327    /// The decimal digits are presented by means of the graphic symbols used in the Arabic script, i.e. the Hindi
1328    /// symbols.
1329    ArabicDecimals,
1330
1331    /// When the direction of the character path is right-to-left, each of the graphic characters in the graphic
1332    /// character set(s) in use which is one of a left/right handed pair (parentheses, square brackets, curly brackets,
1333    /// greater-than/less-than signs, etc.) is presented as "mirrored", i.e. as the other member of the pair. For
1334    /// example, the coded graphic character given the name LEFT PARENTHESIS is presented as RIGHT PARENTHESIS, and
1335    /// vice versa.
1336    MirrorPairs,
1337
1338    /// When the direction of the character path is right-to-left, all graphic characters which represent operators and
1339    /// delimiters in mathematical formulae and which are not symmetrical about a vertical axis are presented as
1340    /// mirrored about that vertical axis.
1341    MirrorFormulae,
1342
1343    /// The following graphic character is presented in its isolated form.
1344    Isolated,
1345
1346    /// The following graphic character is presented in its initial form.
1347    Initial,
1348
1349    /// The following graphic character is presented in its medial form.
1350    Medial,
1351
1352    /// The following graphic character is presented in its final form.
1353    Final,
1354
1355    /// Where the bit combination `02/14` is intended to represent a decimal mark in a decimal number it shall be
1356    /// represented by means of the graphic symbol FULL STOP.
1357    DecimalFullStop,
1358
1359    /// Where the bit combination `02/14` is intended to represent a decimal mark in a decimal number it shall be
1360    /// represented by means of the graphic symbol COMMA.
1361    DecimalComma,
1362
1363    /// Vowels are presented above or below the preceding character.
1364    VowelAboveOrBelow,
1365
1366    /// Vowels are presented after the preceding character.
1367    VowelAfterPreceding,
1368
1369    /// Contextual shape determination of Arabic scripts, including the LAM-ALEPH ligature but excluding all other
1370    /// Arabic ligatures.
1371    ContextualShapeArabicScriptWithLamAleph,
1372
1373    /// Contextual shape determination of Arabic scripts, excluding all Arabic ligatures.
1374    ContextualShapeArabicScript,
1375
1376    /// Cancels the effect of [`PresentationVariant::MirrorPairs`] and [`PresentationVariant::MirrorFormulae`].
1377    NoMirroring,
1378
1379    /// Vowels are not presented.
1380    NoVowels,
1381
1382    /// When the string direction is right-to-left, the italicized characters are slanted to the left, when the string
1383    /// direction is left-to-right, the italicized characters are slanted to the right.
1384    SlantFollowsStringDirection,
1385
1386    /// Contextual shape determination of Arabic scripts is not used, the graphic characters - including the digits -
1387    /// are presented in the form they are stored (pass-through).
1388    NoContextualShapeArabicScript,
1389
1390    /// Contextual shape determination of Arabic scripts is not used, the graphic characters - excluding the digits -
1391    /// are presented in the form they are stored (pass-through).
1392    NoContextualShapeArabicScriptExceptDigits,
1393
1394    /// The graphic symbols used to present the decimal digits are device dependent.
1395    DeviceDependentDecimalDigits,
1396
1397    /// Establishes the effect of parameter values [`PresentationVariant::Isolated`], [`PresentationVariant::Initial`],
1398    /// [`PresentationVariant::Medial`], and [`PresentationVariant::Final`] for the following graphic characters until
1399    /// cancelled.
1400    PersistCharacterForm,
1401
1402    /// Cancels the effect of parameter value [`PresentationVariant::PersistCharacterForm`], i.e. re-establishes the
1403    /// effect of parameter values [`PresentationVariant::Isolated`], [`PresentationVariant::Initial`],
1404    /// [`PresentationVariant::Medial`], and [`PresentationVariant::Final`] for the next single graphic character only.
1405    DesistCharacterForm,
1406}
1407
1408/// Select Alternative Presentation Variants.
1409///
1410/// `SAPV` is used to specify one or more variants for the presentation of subsequent text.
1411///
1412/// The default value for `s` is [`PresentationVariant::Default`].
1413pub fn SAPV(s: Option<PresentationVariant>) -> ControlFunction<'static> {
1414    sequence!(02 / 00, 05 / 13, selective default s)
1415}
1416
1417/// Valid parameter values to the function [`SCO`].
1418#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1419pub enum CharacterOrientation {
1420    /// Rotate by 0°, normal orientation.
1421    #[default]
1422    Normal = 0,
1423
1424    /// Rotate by 45°.
1425    Rotate45,
1426
1427    /// Rotate by 90°.
1428    Rotate90,
1429
1430    /// Rotate by 135°.
1431    Rotate135,
1432
1433    /// Rotate by 180°.
1434    Rotate180,
1435
1436    /// Rotate by 225°.
1437    Rotate225,
1438
1439    /// Rotate by 270°.
1440    Rotate270,
1441
1442    /// Rotate by 315°.
1443    Rotate315,
1444}
1445
1446/// Select Character Orientation.
1447///
1448/// `SCO` is used to establish the amount of rotation of the graphic characters following in the data stream. The
1449/// established value remains in effect until the next occurrence of `SCO` in the data stream.
1450///
1451/// Rotation is positive, i.e. counter-clockwise and applies to the normal presentation of the graphic characters along
1452/// the character path. The centre of rotation of the affected graphic characters is not default.
1453///
1454/// The default value for `s` is [`CharacterOrientation::Normal`].
1455pub fn SCO(s: Option<CharacterOrientation>) -> ControlFunction<'static> {
1456    sequence!(02 / 00, 06 / 05, selective default s)
1457}
1458
1459/// Valid parameter values to the function [`SCP`].
1460#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1461pub enum CharacterPath {
1462    /// Left-to-right (in the case of horizontal line orientation), or top-to-bottom (in the case of vertical line
1463    /// orientation).
1464    LefToRight = 1,
1465
1466    /// Right-to-left (in the case of horizontal line orientation), or bottom-to-top (in the case of vertical line
1467    /// orientation).
1468    RightToLeft,
1469}
1470
1471/// Valid parameter values to the function [`SCP`].
1472#[derive(Debug, Clone, Copy, PartialEq, Eq)]
1473pub enum CharacterPathScope {
1474    /// Undefined, implementation specific.
1475    ///
1476    /// ## Note
1477    ///
1478    /// This may also permit the effect to take place after the next occurrence of [`CR`][crate::c0::CR],
1479    /// [`NEL`][crate::c1::NEL] or any control function which initiates an absolute movement of the active presentation
1480    /// position or the active data position.
1481    Undefined = 0,
1482
1483    /// The content of the active line in the presentation component (the line that contains the active presentation
1484    /// position) is updated to correspond to the content of the active line in the data component (the line that
1485    /// contains the active data position) according to the newly established character path characteristics in the
1486    /// presentation component; the active data position is moved to the first character position in the active line
1487    /// in the data component, the active presentation position in the presentation component is updated accordingly.
1488    InPresentationComponent,
1489
1490    /// The content of the active line in the data component (the line that contains the active data position) is
1491    /// updated to correspond to the content of the active line in the presentation component (the line that contains
1492    /// the active presentation position) according to the newly established character path characteristics of the
1493    /// presentation component; the active presentation position is moved to the first character position in the active
1494    /// line in the presentation component, the active data position in the data component is updated accordingly.
1495    InDataComponent,
1496}
1497
1498/// Select Character Path.
1499///
1500/// `SCP` is used to select the character path, relative to the line orientation, for the active line (the line that
1501/// contains the active presentation position) and subsequent lines in the presentation component. It is also used to
1502/// update the content of the active line in the presentation component and the content of the active line (the line
1503/// that contains the active data position) in the data component. This takes effect immediately.
1504pub fn SCP(s: CharacterPath, t: CharacterPathScope) -> ControlFunction<'static> {
1505    let (n, m) = ((s as u32), (t as u32));
1506    sequence!(02 / 00, 06 / 11, numeric n, numeric m)
1507}
1508
1509/// Set Character Spacing.
1510///
1511/// `SCS` is used to establish the character spacing for subsequent text. The established spacing remains in effect
1512/// until the next occurrence of `SCS`, or of SELECT CHARACTER SPACING ([`SHS`]) or of SPACING INCREMENT ([`SPI`]) in
1513/// the data stream.
1514///
1515/// `n` specifies the character spacing.
1516///
1517/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
1518/// ([`SSU`]).
1519pub fn SCS(n: u32) -> ControlFunction<'static> {
1520    sequence!(02 / 00, 06 / 07, numeric n)
1521}
1522
1523/// Scroll Down.
1524///
1525/// `SD` causes the data in the presentation component to be moved by `n` line positions if the line orientation is
1526/// horizontal, or by `n` character positions if the line orientation is vertical, such that the data appear to
1527/// move down.
1528///
1529/// The active presentation position is not affected by this control function.
1530///
1531/// The default value for `n` is `1`.
1532pub fn SD(n: Option<u32>) -> ControlFunction<'static> {
1533    sequence!(05 / 04, numeric n, default 1)
1534}
1535
1536/// Valid parameter values to the function [`SDS`].
1537#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1538pub enum StringDirection {
1539    /// End of a directed string; re-establish the previous direction.
1540    #[default]
1541    End = 0,
1542
1543    /// Start of a directed string, establish the direction left-to-right.
1544    StartLeftToRight,
1545
1546    /// Start of a directed string, establish the direction right-to-left.
1547    StartRightToLeft,
1548}
1549
1550/// Start Directed String.
1551///
1552/// `SDS` is used to establish in the data component the beginning and end of a string of characters as well as the
1553/// direction of the string. This direction may be different from that currently established. The indicated string
1554/// follows the preceding text. The established character progression is not affected.
1555///
1556/// The beginning of a directed string is indicated by `SDS` with a parameter value not equal to
1557/// [`StringDirection::End`]. A directed string may contain one or more nested strings. These nested strings may be
1558/// directed strings the beginning of which are indicated by `SDS` with a parameter value not equal to
1559/// [`StringDirection::End`], or reversed stings the beginning of which are indicated by START REVERSED STRING ([`SRS`])
1560/// with a parameter value of [`ReversedString::Start`]. Every beginning of such a string invokes the next deeper level
1561/// of nesting.
1562///
1563/// The standard does not define the location of the active data position within any such nested string.
1564///
1565/// The end of a directed string is indicated by `SDS` with a parameter value of [`StringDirection::End`]. Every such
1566/// end of such a string re-establishes the next higher level of nesting (the one in effect prior to the string just
1567/// ended). The direction is re-established to that in effect prior to the string just ended. The active data position
1568/// is moved to the character position following the characters of the string just ended.
1569///
1570/// The default value of `s` is [`StringDirection::End`].
1571///
1572/// ## Note 1
1573///
1574/// The effect of receiving a [`CVT`], [`HT`][crate::c0::HT], [`SCP`], [`SPD`], or [`VT`][crate::c0::VT] control
1575/// function within an `SDS` string is not defined.
1576///
1577/// ## Note 2
1578///
1579/// The control functions for area definitions ([`DAQ`], [`EPA`][crate::c1::EPA], [`SPA`][crate::c1::SPA],
1580/// [`SSA`][crate::c1::SPA]) should not be used within an `SDS` string.
1581pub fn SDS(s: Option<StringDirection>) -> ControlFunction<'static> {
1582    sequence!(05 / 13, selective default s)
1583}
1584
1585/// Valid parameter values to the function [`SEE`].
1586#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1587pub enum EditingExtend {
1588    /// The shifted part is limited to the active page in the presentation component.
1589    #[default]
1590    ActivePage = 0,
1591
1592    /// The shifted part is limited to the active line in the presentation component.
1593    ActiveLine,
1594
1595    /// The shifted part is limited to the active field in the presentation component.
1596    ActiveField,
1597
1598    /// The shifted part is limited to the active qualified area.
1599    QualifiedArea,
1600
1601    /// The shifted part consists of the relevant part of the entire presentation component.
1602    All,
1603}
1604
1605/// Select Editing Extent.
1606///
1607/// `SEE` is used to establish the editing extent for subsequent character or line insertion or deletion. The
1608/// established extent remains in effect until the next occurrence of `SEE` in the data stream. The editing extend
1609/// depends on the parameter value.
1610///
1611/// The default value for `s` is [`EditingExtend::ActivePage`].
1612pub fn SEE(s: Option<EditingExtend>) -> ControlFunction<'static> {
1613    sequence!(05 / 01, selective default s)
1614}
1615
1616/// Valid parameter values to the function [`SEF`].
1617#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1618#[repr(u32)]
1619pub enum Load {
1620    /// Eject sheet, no new sheet loaded
1621    #[default]
1622    None = 0,
1623
1624    /// Eject sheet and load another from the given bin.
1625    Bin(u32),
1626}
1627
1628/// Valid parameter values to the function [`SEF`].
1629#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1630#[repr(u32)]
1631pub enum Stack {
1632    /// Eject sheet, no stacker specified.
1633    #[default]
1634    None = 0,
1635
1636    /// Eject sheet into the specified stacker.
1637    Stacker(u32),
1638}
1639
1640/// Sheet Eject And Feed.
1641///
1642/// `SEF` causes a sheet of paper to be ejected from a printing device into a specified output stacker and another
1643/// sheet to be loaded into the printing device from a specified paper bin.
1644///
1645/// The default value for `l` is [`Load::None`].  
1646/// The default value for `s` is [`Stack::None`].
1647pub fn SEF(l: Option<Load>, s: Option<Stack>) -> ControlFunction<'static> {
1648    let n = match l.unwrap_or_default() {
1649        Load::None => 0,
1650        Load::Bin(bin) => bin,
1651    };
1652    let m = match s.unwrap_or_default() {
1653        Stack::None => 0,
1654        Stack::Stacker(stacker) => stacker,
1655    };
1656    sequence!(02 / 00, 05 / 09, numeric n, numeric m)
1657}
1658
1659/// Valid parameter values to the function [`SGR`].
1660#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1661pub enum GraphicRendition {
1662    /// Default rendition (implementation-defined), cancels the effect of any preceding occurrence of [`SGR`] in the
1663    /// data stream regardless of the setting of the GRAPHIC RENDITION COMBINATION MODE ([`GRCM`][crate::modes::GRCM]).
1664    #[default]
1665    Default = 0,
1666
1667    /// Bold or increased intensity.
1668    HighIntensity,
1669
1670    /// Faint, decreased intensity or second color.
1671    LowIntensity,
1672
1673    /// Italicized.
1674    Italicized,
1675
1676    /// Singly underlined.
1677    Underlined,
1678
1679    /// Slowly blinking (less than 150 per minute).
1680    SlowlyBlinking,
1681
1682    /// Rapidly blinking (more than 150 per minute).
1683    RapidlyBlinking,
1684
1685    /// Negative image.
1686    Negative,
1687
1688    /// Concealed characters.
1689    Concealed,
1690
1691    /// Crossed-out (characters still legible but marked as to be deleted).
1692    CrossedOut,
1693
1694    /// Primary (default) font.
1695    PrimaryFont,
1696
1697    /// First alternative font.
1698    FirstAlternativeFont,
1699
1700    /// Second alternative font.
1701    SecondAlternativeFont,
1702
1703    /// Third alternative font.
1704    ThirdAlternativeFont,
1705
1706    /// Forth alternative font.
1707    ForthAlternativeFont,
1708
1709    /// Fifth alternative font.
1710    FifthAlternativeFont,
1711
1712    /// Sixth alternative font.
1713    SixthAlternativeFont,
1714
1715    /// Seventh alternative font.
1716    SeventhAlternativeFont,
1717
1718    /// Eighth alternative font.
1719    EighthAlternativeFont,
1720
1721    /// Ninth alternative font.
1722    NinthAlternativeFont,
1723
1724    /// Fraktur (Gothic).
1725    Fraktur,
1726
1727    /// Doubly underlined.
1728    DoublyUnderlined,
1729
1730    /// Normal colour or normal intensity (neither bold nor faint).
1731    NormalIntensity,
1732
1733    /// Not italicized, not fraktur
1734    NormalStyle,
1735
1736    /// Not underlined (neither singly nor doubly).
1737    NotUnderlined,
1738
1739    /// Steady (not blinking).
1740    NotBlinking,
1741
1742    /// Positive Image.
1743    Positive = 27,
1744
1745    /// Revealed characters.
1746    Revealed,
1747
1748    /// Not crossed out.
1749    NotCrossedOut,
1750
1751    /// Black display.
1752    BlackForeground,
1753
1754    /// Red display.
1755    RedForeground,
1756
1757    /// Green display.
1758    GreenForeground,
1759
1760    /// Yellow display.
1761    YellowForeground,
1762
1763    /// Blue display.
1764    BlueForeground,
1765
1766    /// Magenta display.
1767    MagentaForeground,
1768
1769    /// Cyan display.
1770    CyanForeground,
1771
1772    /// White display.
1773    WhiteForeground,
1774
1775    /// Default display color (implementation specific).
1776    DefaultForeground = 39,
1777
1778    /// Black background.
1779    BlackBackground,
1780
1781    /// Red background.
1782    RedBackground,
1783
1784    /// Green Background.
1785    GreenBackground,
1786
1787    /// Yellow background.
1788    YellowBackground,
1789
1790    /// Blue background.
1791    BlueBackground,
1792
1793    /// Magenta background.
1794    MagentaBackground,
1795
1796    /// Cyan background.
1797    CyanBackground,
1798
1799    /// White background.
1800    WhiteBackground,
1801
1802    /// Default background color (implementation specific).
1803    DefaultBackground = 49,
1804
1805    /// Framed.
1806    Framed = 51,
1807
1808    /// Encircled.
1809    Encircled,
1810
1811    /// Overlined.
1812    Overlined,
1813
1814    /// Not framed, not encircled.
1815    NotFramed,
1816
1817    /// Not overlined,
1818    NotOverlined,
1819
1820    /// Ideogram underline or right side line.
1821    IdeogramUnderline = 60,
1822
1823    /// Ideogram double underline or double line on the right side.
1824    IdeogramDoubleUnderline,
1825
1826    /// Ideogram stress marking.
1827    IdeogramStressMarking,
1828
1829    /// Cancel Ideogram rendition settings.
1830    CancelIdeogramRendition,
1831}
1832
1833/// Select Graphic Rendition.
1834///
1835/// `SGR` is used to establish one or more graphic rendition aspects for subsequent text. The established aspects remain
1836/// in effect until the next occurrence of `SGR` in the data stream, depending on the setting of the GRAPHIC RENDITION
1837/// COMBINATION MODE ([`GRCM`][crate::modes::GRCM]). Each graphic rendition aspect is specified by a parameter value of
1838/// [`GraphicRendition`].
1839///
1840/// The default value for `s` is [`GraphicRendition::Default`].
1841///
1842/// ## Note
1843///
1844/// The usable combinations of parameter values are determined by the implementation.
1845pub fn SGR(s: Option<Vec<GraphicRendition>>) -> ControlFunction<'static> {
1846    let g = s.unwrap_or(vec![Default::default()]);
1847    sequence!(06 / 13, variadic selective g)
1848}
1849
1850/// Valid parameter values to the function [`SHS`].
1851#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1852pub enum CharacterSpacing {
1853    /// 10 characters per 25.4 mm.
1854    #[default]
1855    TenCharacters = 0,
1856
1857    /// 12 characters per 25.4 mm.
1858    TwelveCharacters,
1859
1860    /// 15 characters per 25.4 mm.
1861    FifteenCharacters,
1862
1863    /// 6 characters per 25.4 mm.
1864    SixCharacters,
1865
1866    /// 3 characters per 25.4 mm.
1867    ThreeCharacters,
1868
1869    /// 9 characters per 25.4 mm.
1870    NineCharacters,
1871
1872    /// 4 characters per 25.4 mm.
1873    FourCharacters,
1874}
1875
1876/// Select Character Spacing.
1877///
1878/// `SHS` is used to establish the character spacing for subsequent text. The established spacing remains in effect
1879/// until the next occurrence of `SHS` or of SET CHARACTER SPACING ([`SCS`]) or of SPACING INCREMENT ([`SPI`]) in the
1880/// data stream.
1881///
1882/// The default value for `s` is [`CharacterSpacing::TenCharacters`].
1883pub fn SHS(s: Option<CharacterSpacing>) -> ControlFunction<'static> {
1884    sequence!(02 / 00, 04 / 11, selective default s)
1885}
1886
1887/// Valid parameter values to the function [`SIMD`].
1888#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1889pub enum MovementDirection {
1890    /// The direction of implicit movement is the same as that of the character progression.
1891    #[default]
1892    Normal = 0,
1893
1894    /// The direction of implicit movement is opposite to that of the character progression.
1895    Opposite,
1896}
1897
1898/// Select Implicit Movement Direction.
1899///
1900/// `SIMD` is used to select the direction of implicit movement of the data position relative to the character
1901/// progression. The direction selected remains in effect until the next occurrence of [`SIMD`].
1902///
1903/// The default value of `s` is [`MovementDirection::Normal`].
1904pub fn SIMD(s: Option<MovementDirection>) -> ControlFunction<'static> {
1905    sequence!(05 / 14, selective default s)
1906}
1907
1908/// Scroll Left.
1909///
1910/// `SL` causes the data in the presentation component to be moved by `n` character positions if the line orientation
1911/// is horizontal, or by `n` line positions if the line orientation is vertical, such that the data appear to move
1912/// to the left.
1913///
1914/// The active presentation position is not affected by this control function.
1915///
1916/// The default value for `n` is `1`.
1917pub fn SL(n: Option<u32>) -> ControlFunction<'static> {
1918    sequence!(02 / 00, 04 / 00, numeric n, default 1)
1919}
1920
1921/// Set Line Home.
1922///
1923/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `SLH` is used to
1924/// establish at character position `n` in the active line (the line that contains the active presentation position) and
1925/// lines of subsequent text in the presentation component the position to which the active presentation position will
1926/// be moved by subsequent occurrences of CARRIAGE RETURN ([`CR`][crate::c0::CR]), DELETE LINE ([`DL`]), INSERT LINE
1927/// ([`IL`]) or NEXT LINE ([`NEL`][crate::c1::NEL]) in the data stream. In the case of a device without data component,
1928/// it is also the position ahead of which no implicit movement of the active presentation position shall occur.
1929///
1930/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SLH` is used to establish at
1931/// character position `n` in the active line (the line that contains the active data position) and lines of subsequent
1932/// text in the data component the position to which the active data position will be moved by subsequent occurrences of
1933/// CARRIAGE RETURN ([`CR`][crate::c0::CR]), DELETE LINE ([`DL`]), INSERT LINE ([`IL`]) or NEXT LINE
1934/// ([`NEL`][crate::c1::NEL]) in the data stream. It is also the position ahead of which no implicit movement of the
1935/// active data position shall occur.
1936///
1937/// The established position is called the line home position and remains in effect until the next occurrence of `SLH`
1938/// in the data stream.
1939pub fn SLH(n: u32) -> ControlFunction<'static> {
1940    sequence!(02 / 00, 05 / 05, numeric n)
1941}
1942
1943/// Set Line Limit.
1944///
1945/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `SLL` is used to
1946/// establish at character position `n` in the active line (the line that contains the active presentation position) and
1947/// lines of subsequent text in the presentation component the position to which the active presentation position will
1948/// be moved by subsequent occurrences of CARRIAGE RETURN ([`CR`][crate::c0::CR]), or NEXT LINE
1949/// ([`NEL`][crate::c1::NEL]) in the data stream if the parameter value of SELECT IMPLICIT MOVEMENT DIRECTION ([`SIMD`])
1950/// is equal to [`MovementDirection::Opposite`]. In the case of a device without data component, it is also the position
1951/// beyond which no implicit movement of the active presentation position shall occur.
1952///
1953/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SLL` is used to establish at
1954/// character position `n` in the active line (the line that contains the active data position) and lines of subsequent
1955/// text in the data component the position beyond which no implicit movement of the active data position shall occur.
1956/// It is also the position in the data component to which the active data position will be moved by subsequent
1957/// occurrences of [`CR`][crate::c0::CR] or [`NEL`][crate::c1::NEL] in the data stream, if the parameter value of
1958/// SELECT IMPLICIT MOVEMENT DIRECTION ([`SIMD`]) is equal to [`MovementDirection::Opposite`].
1959///
1960/// The established position is called the line limit position and remains in effect until the next occurrence of `SLL`
1961/// in the data stream.
1962pub fn SLL(n: u32) -> ControlFunction<'static> {
1963    sequence!(02 / 00, 05 / 06, numeric n)
1964}
1965
1966/// Set Line Spacing.
1967///
1968/// `SLS` is used to establish the line spacing for subsequent text. The established spacing remains in effect until the
1969/// next occurrence of `SLS` or of SELECT LINE SPACING ([`SVS`]) or of SPACING INCREMENT ([`SPI`]) in the data stream.
1970///
1971/// `n` specifies the line spacing.
1972///
1973/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
1974/// ([`SSU`]).
1975pub fn SLS(n: u32) -> ControlFunction<'static> {
1976    sequence!(02 / 00, 06 / 08, numeric n)
1977}
1978
1979/// Set Mode.
1980///
1981/// `SM` causes the modes of the receiving device to be set as specified by the parameter values.
1982pub fn SM(s: Vec<Mode>) -> ControlFunction<'static> {
1983    sequence!(06 / 08, variadic selective s)
1984}
1985
1986/// Valid parameter values to the function [`SPD`].
1987#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1988pub enum PresentationDirection {
1989    /// Horizontal line orientation, top-to-bottom line progression, left-to-right character path.
1990    #[default]
1991    HorizontalLinesTopToBottomLeftToRight = 0,
1992
1993    /// Vertical line orientation, right-to-left line progression, top-to-bottom character path.
1994    VerticalLinesRightToLeftTopToBottom,
1995
1996    /// Vertical line orientation, left-to-right line progression, top-to-bottom character path.
1997    VerticalLinesLeftToRightTopToBottom,
1998
1999    /// Horizontal line orientation, top-to-bottom line progression, right-to-left character path.
2000    HorizontalLinesTopToBottomRightToLeft,
2001
2002    /// Vertical line orientation, left-to-right line progression, bottom-to-top character path.
2003    VerticalLinesLeftToRightBottomToTop,
2004
2005    /// Horizontal line orientation, bottom-to-top line progression, right-to-left character path.
2006    HorizontalLinesBottomToTopRightToLeft,
2007
2008    /// Horizontal line orientation, bottom-to-top line progression, left-to-right character path.
2009    HorizontalLinesBottomToTopLefToRight,
2010
2011    /// Vertical line orientation, right to left line progression, bottom-to-top character path.
2012    VerticalLinesRightToLeftBottomToTop,
2013}
2014
2015/// Valid parameter values to the function [`SPD`].
2016#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2017pub enum PresentationDirectionScope {
2018    /// Undefined, implementation specific.
2019    ///
2020    /// ## Note
2021    ///
2022    /// This may also permit the effect to take place after the next occurrence of [`CR`][crate::c0::CR],
2023    /// [`NEL`][crate::c1::NEL] or any control function which initiates an absolute movement of the active presentation
2024    /// position or the active data position.
2025    #[default]
2026    Undefined = 0,
2027
2028    /// The content of the presentation component is updated to correspond to the content of the data component
2029    /// according to the newly established characteristics of the presentation component; the active data position is
2030    /// moved to the first character position in the first line in the data component, the active presentation position
2031    /// in the presentation component is updated accordingly.
2032    InPresentationComponent,
2033
2034    /// The content of the data component is updated to correspond to the content of the presentation component
2035    /// according to the newly established characteristics of the presentation component; the active presentation
2036    /// position is moved to the first character position in the first line in the presentation component, the active
2037    /// data position in the data component is updated accordingly.
2038    InDataComponent,
2039}
2040
2041/// Select Presentation Directions.
2042///
2043/// `SPD` is used to select the line orientation, the line progression, and the character path in the presentation
2044/// component. It is also used to update the content of the presentation component and the content of the data
2045/// component. This takes effect immediately.
2046///
2047/// `s` specifies the line orientation, the line progression and the character path.  
2048/// `t` specifies the effect on the content of the presentation component and the content of the data component.
2049///
2050/// The default value for `s` is [`PresentationDirection::HorizontalLinesTopToBottomLeftToRight`].  
2051/// The default value for `t` is [`PresentationDirectionScope::Undefined`].
2052pub fn SPD(
2053    s: Option<PresentationDirection>,
2054    t: Option<PresentationDirectionScope>,
2055) -> ControlFunction<'static> {
2056    sequence!(02 / 00, 05 / 03, selective default s, selective default t)
2057}
2058
2059/// Set Page Home.
2060///
2061/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `SPH` is used to
2062/// establish at line position `n` in the active page (the page that contains the active presentation position) and
2063/// subsequent pages in the presentation component the position to which the active presentation position will be moved
2064/// by subsequent occurrences of FORM FEED ([`FF`][crate::c0::FF]) in the data stream. In the case of a device without
2065/// data component, it is also the position ahead of which no implicit movement of the active presentation position
2066/// shall occur.
2067///
2068/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SPH` is used to establish at
2069/// line position `n` in the active page (the page that contains the active data position) and subsequent pages in the
2070/// data component the position to which the active data position will be moved by subsequent occurrences of FORM FEED
2071/// ([`FF`][crate::c0::FF]) in the data stream. It is also the position ahead of which no implicit movement of the
2072/// active presentation position shall occur.
2073///
2074/// The established position is called the page home position and remains in effect until the next occurrence of `SPH`
2075/// in the data stream.
2076pub fn SPH(n: u32) -> ControlFunction<'static> {
2077    sequence!(02 / 00, 06 / 09, numeric n)
2078}
2079
2080/// Spacing Increment.
2081///
2082/// `SPI` is used to establish the line spacing and the character spacing for subsequent text. The established line
2083/// spacing remains in effect until the next occurrence of `SPI` or of SET LINE SPACING ([`SLS`]) or of SELECT LINE
2084/// SPACING ([`SVS`]) in the data stream. The established character spacing remains in effect until the next occurrence
2085/// of SET CHARACTER SPACING ([`SCS`]) or of SELECT CHARACTER SPACING ([`SHS`]) in the data stream.
2086///
2087/// `l` specifies the line spacing.  
2088/// `c` specifies the character spacing.
2089///
2090/// The unit in which the parameter values are expressed is that established by the parameter value of SELECT SIZE UNIT
2091/// ([`SSU`]).
2092pub fn SPI(l: u32, c: u32) -> ControlFunction<'static> {
2093    sequence!(02 / 00, 04 / 07, numeric l, numeric c)
2094}
2095
2096/// Set Page Limit.
2097///
2098/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to PRESENTATION, `SPL` is used to
2099/// establish at line position `n` in the active page (the page that contains the active presentation position) and
2100/// pages of subsequent text in the presentation component the position beyond which the active presentation position
2101/// can normally not be moved. In the case of a device without data component, it is also the position beyond which no
2102/// implicit movement of the active presentation position shall occur.
2103///
2104/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SPL` is used to establish at
2105/// line position `n` in the active page (the page that contains the active data position) and pages of subsequent text
2106/// in the data component the position beyond which no implicit movement of the active data position shall occur.
2107///
2108/// The established position is called the page limit position and remains in effect until the next occurrence of `SPL`
2109/// in the data stream.
2110pub fn SPL(n: u32) -> ControlFunction<'static> {
2111    sequence!(02 / 00, 06 / 10, numeric n)
2112}
2113
2114/// Valid parameter values to the function [`SPQR`].
2115#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2116pub enum PrintQuality {
2117    /// Highest available print quality, low print speed
2118    #[default]
2119    HighQualityLowSpeed = 0,
2120
2121    /// Medium print quality, medium print speed.
2122    MediumQualityMediumSpeed,
2123
2124    /// Draft print quality, highest available print speed
2125    LowQualityHighSpeed,
2126}
2127
2128/// Select Print Quality and Rapidity.
2129///
2130/// `SPQR` is used to select the relative print quality and the print speed for devices where the output quality and
2131/// speed of are inversely related. The selected values remain in effect until the next occurrence of `SPQR` in the
2132/// data stream.
2133///
2134/// The default value of `s` is [`PrintQuality::HighQualityLowSpeed`].
2135pub fn SPQR(s: Option<PrintQuality>) -> ControlFunction<'static> {
2136    sequence!(02 / 00, 05 / 08, selective default s)
2137}
2138
2139/// Scroll Right.
2140///
2141/// `SR` causes the data in the presentation component to be moved by `n` character positions if the line orientation is
2142/// horizontal, or by `n` line positions if the line orientation is vertical, such that the data appear to move to the
2143/// right.
2144///
2145/// The active presentation position is not affected by this control function.
2146///
2147/// The default value for `n` is `1`.
2148pub fn SR(n: Option<u32>) -> ControlFunction<'static> {
2149    sequence!(02 / 00, 05 / 08, numeric n, default 1)
2150}
2151
2152/// Set Reduced Character Separation.
2153///
2154/// `SRCS` is used to establish reduced inter-character escapement for subsequent text. The established reduced
2155/// escapement remains in effect until the next occurrence of `SRCS` or of SET ADDITIONAL CHARACTER SEPARATION
2156/// ([`SACS`]) in the data stream or until it is reset to the default value by a subsequent occurrence of
2157/// CARRIAGE RETURN/LINE FEED ([`CR`][crate::c0::CR]/[`LF`][crate::c0::LF]) or of NEXT LINE ([`NEL`][crate::c1::NEL])
2158/// in the data stream.
2159///
2160/// `n` specifies the number of units by which the inter-character escapement is reduced.
2161///
2162/// The unit in which the parameter values are expressed is that established by the parameter value of SELECT SIZE UNIT
2163/// ([`SSU`]).
2164///
2165/// The default value of `n` is `0`.
2166pub fn SRCS(n: Option<u32>) -> ControlFunction<'static> {
2167    sequence!(02 / 00, 06 / 06, numeric n, default 0)
2168}
2169
2170/// Valid parameter values to the function [`SRS`].
2171#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2172pub enum ReversedString {
2173    /// End of a reversed string; re-establish the previous direction.
2174    #[default]
2175    End = 0,
2176
2177    /// Beginning of a reversed string; reverse the direction
2178    Start,
2179}
2180
2181/// Start Reversed String.
2182///
2183/// `SRS` is used to establish in the data component the beginning and the end of a string of characters as well as
2184/// the direction of the string. This direction is opposite to that currently established. The indicated string follows
2185/// the preceding text. The established character progression is not affected.
2186///
2187/// The beginning of a reversed string is indicated by `SRS` with a parameter value of [`ReversedString::Start`].
2188/// A reversed string may contain one or more nested strings. These nested strings may be reversed strings the
2189/// beginnings of which are indicated by `SRS` with a parameter value of [`ReversedString::Start`], or directed strings
2190/// the beginnings of which are indicated by START DIRECTED STRING ([`SDS`]) with a parameter value not equal to
2191/// [`StringDirection::End`]. Every beginning of such a string invokes the next deeper level of nesting.
2192///
2193/// This Standard does not define the location of the active data position within any such nested string.
2194///
2195/// The end of a reversed string is indicated by `SRS` with a parameter value of [`ReversedString::End`]. Every end of
2196/// such a string re-establishes the next higher level of nesting (the one in effect prior to the string just ended).
2197/// The direction is re-established to that in effect prior to the string just ended. The active data position is moved
2198/// to the character position following the characters of the string just ended.
2199///
2200/// Default value of `s` is [`ReversedString::End`].
2201///
2202/// ## Note 1
2203///
2204/// The effect of receiving a [`CVT`], [`HT`][crate::c0::HT], [`SCP`], [`SPD`], or [`VT`][crate::c0::VT] control
2205/// function within an `SRS` string is not defined.
2206///
2207/// ## Note 2
2208///
2209/// The control functions for area definition ([`DAQ`], [`EPA`][crate::c1::EPA], [`ESA`][crate::c1::ESA],
2210/// [`SPA`][crate::c1::SPA], [`SSA`][crate::c1::SSA]) should not be used within an `SRS` string.
2211pub fn SRS(s: Option<ReversedString>) -> ControlFunction<'static> {
2212    sequence!(05 / 11, selective default s)
2213}
2214
2215/// Valid parameter values to the function [`SSU`].
2216#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2217pub enum SizeUnit {
2218    /// The dimension of this unit are device-dependent.
2219    #[default]
2220    Character = 0,
2221
2222    /// Millimetre.
2223    Millimetre,
2224
2225    /// Computer Decipoint (0.03528 mm - 1/720 of 25.4 mm).
2226    ComputerDecipoint,
2227
2228    /// Decidot (0.03759 mm - 10/266 mm).
2229    Decidot,
2230
2231    /// Mil (0.0254 mm - 1/1000 of 25.4 mm).
2232    Mil,
2233
2234    /// Basic Measuring Unit (BMU) (0.02117 mm - 1/1200 of 25.4 mm).
2235    BasicMeasuringUnit,
2236
2237    /// Micrometer (0.001 mm).
2238    Micrometer,
2239
2240    /// Pixel. The smallest increment that can be specified in a device.
2241    Pixel,
2242
2243    /// Decipoint (0.03514mm - 35/996 mm).
2244    Decipoint,
2245}
2246
2247/// Select Size Unit.
2248///
2249/// `SSU` is used to establish the unit in which the numeric parameters of certain control functions are expressed. The
2250/// established unit remains in effect until the next occurrence of `SSU` in the data stream.
2251///
2252/// Default value of `s` is [`SizeUnit::Character`].
2253pub fn SSU(s: Option<SizeUnit>) -> ControlFunction<'static> {
2254    sequence!(02 / 00, 04 / 09, selective default s)
2255}
2256
2257/// Set Space Width.
2258///
2259/// `SSW` is used to establish for subsequent text the character escapement associated with the character `SPACE`. The
2260/// established escapement remains in effect until the next occurrence of `SSW` in the data stream or until it is reset
2261/// to the default value by a subsequent occurrence of CARRIAGE RETURN/LINE FEED
2262/// ([`CR`][crate::c0::CR]/[`LF`][crate::c0::LF]), CARRIAGE RETURN/FORM FEED
2263/// ([`CR`][crate::c0::CR]/[`FF`][crate::c0::FF]), or of NEXT LINE ([`NEL`][crate::c1::NEL]) in the data stream.
2264///
2265/// `n` specifies the escapement.
2266///
2267/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
2268/// ([`SSU`]).
2269///
2270/// The default character escapement of SPACE is specified by the most recent occurrence of SET CHARACTER SPACING
2271/// ([`SCS`]) or of SELECT CHARACTER SPACING ([`SHS`]) or of SELECT SPACING INCREMENT ([`SPI`]) in the data stream if
2272/// the current font has constant spacing, or is specified by the nominal width of the character `SPACE` in the current
2273/// font if that font has proportional spacing.
2274pub fn SSW(n: u32) -> ControlFunction<'static> {
2275    sequence!(02 / 00, 05 / 11, numeric n)
2276}
2277
2278/// Selective Tabulation.
2279///
2280/// `STAB` causes subsequent text in the presentation component to be aligned according to the position and the
2281/// properties of a tabulation stop which is selected from a list according to the value of the parameter `s`.
2282///
2283/// The use of this control function and means of specifying a list of tabulation stop to be referenced by the control
2284/// function are specified in other standards, for example ISO 8613-6.
2285pub fn STAB(s: u32) -> ControlFunction<'static> {
2286    sequence!(02 / 00, 05 / 14, numeric s)
2287}
2288
2289/// Scroll Up.
2290///
2291/// `SU` causes the data in the presentation component to be moved by `n` line positions if the line operation is
2292/// horizontal, or by `n` character positions if the line orientation is vertical, such that the data appear to move
2293/// up.
2294///
2295/// The active presentation position is not affected by this control function.
2296///
2297/// The default value for `n` is `1`.
2298pub fn SU(n: Option<u32>) -> ControlFunction<'static> {
2299    sequence!(05 / 03, numeric n, default 1)
2300}
2301
2302/// Valid parameter values to the function [`SLS`].
2303#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2304pub enum LineSpacing {
2305    /// Six lines per 25.4 mm.
2306    #[default]
2307    SixLinesPer25 = 0,
2308
2309    /// Four lines per 25.4 mm.
2310    FourLinesPer25,
2311
2312    /// Three lines per 25.4 mm.
2313    ThreeLinesPer25,
2314
2315    /// Twelve lines per 25.4 mm.
2316    TwelveLinesPer25,
2317
2318    /// Eight lines per 25.4 mm.
2319    EightLinesPer25,
2320
2321    /// Six lines per 30 mm.
2322    SixLinesPer30,
2323
2324    /// Four lines per 30 mm.
2325    FourLinesPer30,
2326
2327    /// Three lines per 30 mm.
2328    ThreeLinesPer30,
2329
2330    /// Twelve lines per 30 mm.
2331    TwelveLinesPer30,
2332
2333    /// Two lines per 25.4 mm.
2334    TwoLinesPer25,
2335}
2336
2337/// Select Line Spacing.
2338///
2339/// `SVS` is used to establish the line spacing for subsequent text. The established spacing remains in effect until the
2340/// next occurrence of `SVS` or of SET LINE SPACING ([`SLS`]) or of SPACING INCREMENT ([`SPI`]) in the data stream.
2341///
2342/// The default value for `s` is [`LineSpacing::SixLinesPer25`].
2343pub fn SVS(s: Option<LineSpacing>) -> ControlFunction<'static> {
2344    sequence!(02 / 00, 04 / 12, selective default s)
2345}
2346
2347/// Tabulation Aligned Centred.
2348///
2349/// `TAC` causes a character tabulation stop calling for centring to be set at character position `n` in the active
2350/// line (the line that contains the active presentation position) and lines of subsequent text in the presentation
2351/// component. `TAC` causes the replacement of any tabulation stop previously set at that character position, but does
2352/// not affect other tabulation stops.
2353///
2354/// A text string centred upon a tabulation stop set by `TAC` will be positioned so that the (trailing edge of the)
2355/// first graphic character and the (leading edge of the) last graphic character are at approximately equal distances
2356/// from the tabulation stop.
2357pub fn TAC(n: u32) -> ControlFunction<'static> {
2358    sequence!(02 / 00, 06 / 02, numeric n)
2359}
2360
2361/// Tabulation Aligned Leading Edge.
2362///
2363/// `TALE` causes a character tabulation stop calling for leading edge alignment to be set at character position `n` in
2364/// the active line (the line that contains the active presentation position) and lines of subsequent text in the
2365/// presentation component. `TALE` causes the replacement of any tabulation stop previously set at that character
2366/// position, but does not affect other tabulation stops.
2367///
2368/// A text string aligned with a tabulation stop set by `TALE` will be positioned so that the (leading edge of the) last
2369/// graphic character of the string is placed at the tabulation stop.
2370pub fn TALE(n: u32) -> ControlFunction<'static> {
2371    sequence!(02 / 00, 06 / 01, numeric n)
2372}
2373
2374/// Tabulation Aligned Trailing Edge.
2375///
2376/// `TATE` causes a character tabulation stop calling for trailing edge alignment to be set at character position `n`
2377/// in the active line (the line that contains the active presentation position) and lines of subsequent text in the
2378/// presentation component. `TATE` causes the replacement of any tabulation stop previously set at the character
2379/// position, but does not affect other tabulation stops.
2380///
2381/// A text string aligned with a tabulation stop set by `TATE` will be positioned so that the (trailing edge of the)
2382/// first graphic character of the string is placed at the tabulation stop.
2383pub fn TATE(n: u32) -> ControlFunction<'static> {
2384    sequence!(02 / 00, 06 / 00, numeric n)
2385}
2386
2387/// Valid parameter values to the function [`TBC`].
2388#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2389pub enum ClearTabulation {
2390    /// Clear the character tabulation stop at the active presentation position.
2391    #[default]
2392    CharacterTabulationStopActivePosition = 0,
2393
2394    /// Clear the line tabulation stop at the active line.
2395    LineTabulationStopActiveLine,
2396
2397    /// Clear all character tabulation stops at the active line.
2398    AllCharacterTabulationStopsActiveLine,
2399
2400    /// Clear all character tabulation stops.
2401    AllCharacterTabulationStops,
2402
2403    /// Clear all line tabulation stops.
2404    AllLineTabulationStops,
2405
2406    /// Clear all tabulation stops.
2407    AllTabulationStops,
2408}
2409
2410/// Tabulation Clear.
2411///
2412/// `TBC` causes one or more tabulation stops in the presentation component to be cleared, depending on the parameter
2413/// value `s`.
2414///
2415/// The default value for `s` is [`ClearTabulation::CharacterTabulationStopActivePosition`].
2416pub fn TBC(s: Option<ClearTabulation>) -> ControlFunction<'static> {
2417    sequence!(06 / 07, selective default s)
2418}
2419
2420/// Tabulation Centred on Character.
2421///
2422/// `TCC` causes a character tabulation stop calling for alignment of a target graphic character to be set at character
2423/// position `n` in the active line (the line that contains the active presentation position) and lines of subsequent
2424/// text in the presentation component, and the target character about which centring is to be performed is specified
2425/// by parameter `m`. `TCC` causes the replacement of any tabulation stop previously set at that character position, but
2426/// does not affect other tabulation stops.
2427///
2428/// The positioning of a text string aligned with a tabulation stop set by `TCC` will be determined by the first
2429/// occurrence in the string of the target graphic character; that character will be centred upon the tabulation stop.
2430/// If the target character does not occur within the string, then the trailing edge of the first character of the
2431/// string will be positioned at the tabulation stop.
2432///
2433/// The value of `m` indicates the code table position (binary value) of the target character in the currently invoked
2434/// code. For a 7-bit code, the permissible range of values is `32` to `127`; for an 8-bit code, the permissible range
2435/// of values is `32` to `127` and `160` to `255`.
2436///
2437/// The default value of `m` is `32`.
2438pub fn TCC(n: u32, m: Option<u32>) -> ControlFunction<'static> {
2439    let k = m.unwrap_or(32);
2440    sequence!(02 / 00, 06 / 03, numeric n, numeric k)
2441}
2442
2443/// Tabulation Stop Remove.
2444///
2445/// `TSR` causes any character tabulation stop at character position `n` in the active line (the line that contains the
2446/// active presentation position) and lines of subsequent text in the presentation component to be cleared, but does
2447/// not affect other tabulation stops.
2448///
2449pub fn TSR(n: u32) -> ControlFunction<'static> {
2450    sequence!(02 / 00, 06 /04, numeric n)
2451}
2452
2453/// Thin Space Specification.
2454///
2455/// `TSS` is used to establish the width of a thin space for subsequent text. The established width remains in effect
2456/// until the next occurrence of `TSS` in the data stream.
2457///
2458/// `n` specifies the width of the thin space.
2459///
2460/// The unit in which the parameter value is expressed is that established by the parameter value of SELECT SIZE UNIT
2461/// ([`SSU`]).
2462pub fn TSS(n: u32) -> ControlFunction<'static> {
2463    sequence!(02 / 00, 04 / 05, numeric n)
2464}
2465
2466/// Line Position Absolute.
2467///
2468/// `VPA` causes the active data position to be moved to line position `n` in the data component in a direction
2469/// parallel to the line progression.
2470///
2471/// The default value for `n` is `1`.
2472pub fn VPA(n: Option<u32>) -> ControlFunction<'static> {
2473    sequence!(06 / 04, numeric n, default 1)
2474}
2475
2476/// Line Position Backward.
2477///
2478/// `VPB` causes the active data position to be moved by `n` line positions in the data component in a direction
2479/// opposite to that of the line progression.
2480///
2481/// The default value for `n` is `1`.
2482pub fn VPB(n: Option<u32>) -> ControlFunction<'static> {
2483    sequence!(06 / 11, numeric n, default 1)
2484}
2485
2486/// Line Position Forward.
2487///
2488/// `VPR` causes the active data position to be moved `n` line positions in the data component in a direction parallel
2489/// to the line progression.
2490///
2491/// The default value for `n` is `1`.
2492pub fn VPR(n: Option<u32>) -> ControlFunction<'static> {
2493    sequence!(06 / 05, numeric n, default 1)
2494}