From 7ed5ad78db20b9bf7f57745b4611d358864a1c76 Mon Sep 17 00:00:00 2001 From: Frank Zechert Date: Sat, 8 Apr 2023 01:59:10 +0200 Subject: [PATCH] adds categories of control functions --- src/categories.rs | 90 +++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 11 ++++++ 2 files changed, 101 insertions(+) create mode 100644 src/categories.rs diff --git a/src/categories.rs b/src/categories.rs new file mode 100644 index 0000000..b78d128 --- /dev/null +++ b/src/categories.rs @@ -0,0 +1,90 @@ +//! This module re-exports categories of control functions. + +/// All Control Functions that are Categorized as Delimiters. +pub mod delimiters { + pub use crate::c1::{APC, DCS, OSC, PM, SOS, ST}; + pub use crate::independent_control_functions::CMD; +} + +/// All Control Functions that are Categorized as Introducers. +pub mod introducers { + pub use crate::c0::ESC; + pub use crate::c1::{CSI, SCI}; +} + +/// All Control Functions that are Categorized as Shift Functions. +pub mod shift_functions { + pub use crate::c0::{LS0, LS1, SI, SO}; + pub use crate::c1::{SS2, SS3}; + pub use crate::independent_control_functions::{LS1R, LS2, LS2R, LS3, LS3R}; +} + +/// All Control Functions that are Categorized as Format Effectors. +pub mod format_effectors { + pub use crate::c0::{BS, CR, FF, HT, LF, VT}; + pub use crate::c1::{HTJ, HTS, NEL, PLD, PLU, RI, VTS}; + pub use crate::control_sequences::{ + HPA, HPB, HPR, HVP, PPA, PPB, PPR, TBC, TSR, VPA, VPB, VPR, + }; +} + +/// All Control Functions that are Categorized as Presentation Control Functions. +pub mod presentation_control_functions { + pub use crate::c1::{BPH, NBH}; + pub use crate::control_sequences::{ + DTA, FNT, GCC, GSM, GSS, JFY, PEC, PFS, PTX, QUAD, SACS, SAPV, SCO, SCP, SCS, SDS, SGR, + SHS, SIMD, SLH, SLL, SLS, SPD, SPH, SPI, SPL, SPQR, SRCS, SRS, SSU, SSW, STAB, SVS, TAC, + TALE, TATE, TCC, TSS, + }; +} + +/// All Control Functions that are Categorized as Editor Functions. +pub mod editor_functions { + pub use crate::control_sequences::{DCH, DL, EA, ECH, ED, EF, EL, ICH, IL}; +} + +/// All Control Functions that are Categorized as Cursor Control Functions. +pub mod cursor_control_functions { + pub use crate::control_sequences::{ + CBT, CHA, CHT, CNL, CPL, CTC, CUB, CUD, CUF, CUP, CUU, CVT, + }; +} + +/// All Control Functions that are Categorized as Display Control Functions. +pub mod display_control_functions { + pub use crate::control_sequences::{NP, PP, SD, SL, SR, SU}; +} + +/// All Control Functions that are Categorized as Device Control Functions. +pub mod device_control_functions { + pub use crate::c0::{DC1, DC2, DC3, DC4}; +} + +/// All Control Functions that are Categorized as Information Separators. +pub mod information_separators { + pub use crate::c0::{IS1, IS2, IS3, IS4}; +} + +/// All Control Functions that are Categorized as Area Definition Functions. +pub mod area_definition_functions { + pub use crate::c1::{EPA, ESA, SPA, SSA}; + pub use crate::control_sequences::DAQ; +} + +/// All Control Functions that are Categorized as Mode Setting Functions. +pub mod mode_setting_functions { + pub use crate::control_sequences::{RM, SM}; +} + +/// All Control Functions that are Categorized as Transmission Control Functions. +pub mod transmission_control_functions { + pub use crate::c0::{ACK, DLE, ENQ, EOT, ETB, ETX, NAK, SOH, STX, SYN}; +} + +/// All Control Functions that are Categorized as Miscellaneous Control Functions. +pub mod miscellaneous_control_functions { + pub use crate::c0::{BEL, CAN, EM, NUL, SUB}; + pub use crate::c1::{CCH, MW, PU1, PU2, STS}; + pub use crate::control_sequences::{CPR, DA, DSR, FNK, IDCS, IGS, MC, REP, SEE, SEF}; + pub use crate::independent_control_functions::{DMI, EMI, INT, RIS}; +} diff --git a/src/lib.rs b/src/lib.rs index d14b199..6e08b40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,6 +48,16 @@ //! print!("{}{}", ANNOUNCER_SEQUENCE, NEL); //! ``` //! +//! ## Categories of control functions +//! +//! Most control functions are categorized into different groups. They can be accessed from the module +//! [categories]. +//! +//! ``` +//! use ansi_control_codes::categories::format_effectors::{CR, LF}; +//! println!("line1{}{}line2", CR, LF); +//! ``` +//! //! ## High-Level Functions //! //! For your convenience and ease-of-use of the ansi control codes, some functionality is exposed in wrapper functions. @@ -266,6 +276,7 @@ impl From for String { pub mod c0; pub mod c1; +pub mod categories; pub mod control_sequences; pub mod control_strings; pub mod independent_control_functions;