Compare commits
5 Commits
138e15c763
...
v0.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 32682a2d08 | |||
| d1caad00cc | |||
| 6b81631b85 | |||
| 2010dabf57 | |||
| c285678d26 |
@@ -1,7 +1,7 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ansi"
|
name = "ansi-control-codes"
|
||||||
description = "This library contains all ANSI Escape Codes that are defined in the ISO 6429 Standard"
|
description = "This library contains all ANSI Escape Codes that are defined in the ISO 6429 Standard"
|
||||||
version = "0.1.0"
|
version = "0.0.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
authors = ["Frank Zechert <rust.frank@zechert.net>"]
|
authors = ["Frank Zechert <rust.frank@zechert.net>"]
|
||||||
@@ -9,8 +9,9 @@ repository = "https://git.zechert.net/fzechert/ansi.git"
|
|||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
# crates.io
|
# crates.io
|
||||||
publish = false
|
publish = true
|
||||||
keywords = ["ansi", "escape codes", "ISO 6429", "ECMA 48", "ANSI X3.64"]
|
keywords = ["ansi", "escape-codes", "ISO-6429", "ECMA-48", "ANSI-X364"]
|
||||||
categories = ["command-line-interface"]
|
categories = ["command-line-interface"]
|
||||||
|
include = ["**/*.rs", "Cargo.toml"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
//! For example, designate the C0 set, then ring the bell.
|
//! For example, designate the C0 set, then ring the bell.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use ansi::c0::{ANNOUNCER_SEQUENCE, BEL};
|
//! use ansi_control_codes::c0::{ANNOUNCER_SEQUENCE, BEL};
|
||||||
//! println!("{}{}", ANNOUNCER_SEQUENCE, BEL);
|
//! println!("{}{}", ANNOUNCER_SEQUENCE, BEL);
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
//! For example, designate the C1 set, then set a character tabulation stop.
|
//! For example, designate the C1 set, then set a character tabulation stop.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use ansi::c1::{ANNOUNCER_SEQUENCE, HTS};
|
//! use ansi_control_codes::c1::{ANNOUNCER_SEQUENCE, HTS};
|
||||||
//! println!("{}{}", ANNOUNCER_SEQUENCE, HTS);
|
//! println!("{}{}", ANNOUNCER_SEQUENCE, HTS);
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
//! For example, move the cursor to line 5, character 13:
|
//! For example, move the cursor to line 5, character 13:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use ansi::control_sequences::CUP;
|
//! use ansi_control_codes::control_sequences::CUP;
|
||||||
//! print!("{}", CUP(Some(5), Some(13)));
|
//! print!("{}", CUP(Some(5), Some(13)));
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
@@ -566,7 +566,7 @@ pub fn EA(s: Option<EraseArea>) -> ControlFunction {
|
|||||||
/// Whether the character positions of protected areas are put into the erased state, or the character positions of
|
/// Whether the character positions of protected areas are put into the erased state, or the character positions of
|
||||||
/// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
|
/// unprotected areas only, depends on the setting of the ERASURE MODE ([`ERM`][crate::modes::ERM]).
|
||||||
///
|
///
|
||||||
/// The default value for `n` is `1´.
|
/// The default value for `n` is `1`.
|
||||||
pub fn ECH(n: Option<u32>) -> ControlFunction {
|
pub fn ECH(n: Option<u32>) -> ControlFunction {
|
||||||
sequence!(05 / 08, numeric n, default 1)
|
sequence!(05 / 08, numeric n, default 1)
|
||||||
}
|
}
|
||||||
@@ -1526,7 +1526,7 @@ pub fn SCS(n: u32) -> ControlFunction {
|
|||||||
///
|
///
|
||||||
/// The active presentation position is not affected by this control function.
|
/// The active presentation position is not affected by this control function.
|
||||||
///
|
///
|
||||||
/// The default value for `n` is `1´.
|
/// The default value for `n` is `1`.
|
||||||
pub fn SD(n: Option<u32>) -> ControlFunction {
|
pub fn SD(n: Option<u32>) -> ControlFunction {
|
||||||
sequence!(05 / 04, numeric n, default 1)
|
sequence!(05 / 04, numeric n, default 1)
|
||||||
}
|
}
|
||||||
@@ -2062,12 +2062,12 @@ pub fn SPD(
|
|||||||
/// shall occur.
|
/// shall occur.
|
||||||
///
|
///
|
||||||
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SPH` is used to establish at
|
/// If the DEVICE COMPONENT SELECT MODE ([`DCSM`][crate::modes::DCSM]) is set to DATA, `SPH` is used to establish at
|
||||||
/// line position `n´ in the active page (the page that contains the active data position) and subsequent pages in the
|
/// line position `n` in the active page (the page that contains the active data position) and subsequent pages in the
|
||||||
/// data component the position to which the active data position will be moved by subsequent occurrences of FORM FEED
|
/// data component the position to which the active data position will be moved by subsequent occurrences of FORM FEED
|
||||||
/// ([`FF`][crate::c0::FF]) in the data stream. It is also the position ahead of which no implicit movement of the
|
/// ([`FF`][crate::c0::FF]) in the data stream. It is also the position ahead of which no implicit movement of the
|
||||||
/// active presentation position shall occur.
|
/// active presentation position shall occur.
|
||||||
///
|
///
|
||||||
/// The established position is called the page home position and remains in effect until the next occurrence of ´SPH`
|
/// The established position is called the page home position and remains in effect until the next occurrence of `SPH`
|
||||||
/// in the data stream.
|
/// in the data stream.
|
||||||
pub fn SPH(n: u32) -> ControlFunction {
|
pub fn SPH(n: u32) -> ControlFunction {
|
||||||
sequence!(02 / 00, 06 / 09, numeric n)
|
sequence!(02 / 00, 06 / 09, numeric n)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
//! For example, to disable manual input:
|
//! For example, to disable manual input:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use ansi::independent_control_functions::DMI;
|
//! use ansi_control_codes::independent_control_functions::DMI;
|
||||||
//! println!("{}", DMI);
|
//! println!("{}", DMI);
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|||||||
24
src/lib.rs
24
src/lib.rs
@@ -28,14 +28,14 @@
|
|||||||
//! The control functions can be put into normal strings. For example, to ring the bell:
|
//! The control functions can be put into normal strings. For example, to ring the bell:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use ansi::c0::BEL;
|
//! use ansi_control_codes::c0::BEL;
|
||||||
//! println!("Let's ring the bell {}", BEL);
|
//! println!("Let's ring the bell {}", BEL);
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! Or to move the cursor to line 5, column 13:
|
//! Or to move the cursor to line 5, column 13:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use ansi::control_sequences::CUP;
|
//! use ansi_control_codes::control_sequences::CUP;
|
||||||
//! print!("{}", CUP(5.into(), 13.into()));
|
//! print!("{}", CUP(5.into(), 13.into()));
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
//! This is possible by invoking one of the announcer sequences.
|
//! This is possible by invoking one of the announcer sequences.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use ansi::c1::{ANNOUNCER_SEQUENCE, NEL};
|
//! use ansi_control_codes::c1::{ANNOUNCER_SEQUENCE, NEL};
|
||||||
//! // announce the C1 control function set, then move to the next line.
|
//! // announce the C1 control function set, then move to the next line.
|
||||||
//! print!("{}{}", ANNOUNCER_SEQUENCE, NEL);
|
//! print!("{}{}", ANNOUNCER_SEQUENCE, NEL);
|
||||||
//! ```
|
//! ```
|
||||||
@@ -65,7 +65,6 @@
|
|||||||
//! [ecma-48]: https://www.ecma-international.org/publications-and-standards/standards/ecma-48/
|
//! [ecma-48]: https://www.ecma-international.org/publications-and-standards/standards/ecma-48/
|
||||||
//! [iso-6429]: https://www.iso.org/standard/12782.html
|
//! [iso-6429]: https://www.iso.org/standard/12782.html
|
||||||
//! [wikipedia-ansi]: https://en.wikipedia.org/wiki/ANSI_escape_code
|
//! [wikipedia-ansi]: https://en.wikipedia.org/wiki/ANSI_escape_code
|
||||||
#![allow(dead_code)]
|
|
||||||
|
|
||||||
use std::{fmt, str};
|
use std::{fmt, str};
|
||||||
|
|
||||||
@@ -139,15 +138,6 @@ enum ControlFunctionType {
|
|||||||
///
|
///
|
||||||
/// The independent control functions are defined in the module [independent_control_functions].
|
/// The independent control functions are defined in the module [independent_control_functions].
|
||||||
IndependentControlFunction,
|
IndependentControlFunction,
|
||||||
|
|
||||||
/// Control Strings.
|
|
||||||
///
|
|
||||||
/// A control string is a string of bit combinations which may occur in the data stream as a logical entity for
|
|
||||||
/// control purposes. A control string consists of an opening delimiter, a command string or character string, and
|
|
||||||
/// a terminating delimiter, the String Terminator ([`ST`][c1::ST]).
|
|
||||||
///
|
|
||||||
/// The control strings are defined in the module [control_strings].
|
|
||||||
ControlString,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for ControlFunctionType {
|
impl fmt::Debug for ControlFunctionType {
|
||||||
@@ -159,7 +149,6 @@ impl fmt::Debug for ControlFunctionType {
|
|||||||
ControlFunctionType::IndependentControlFunction => {
|
ControlFunctionType::IndependentControlFunction => {
|
||||||
write!(f, "Independent Control Function")
|
write!(f, "Independent Control Function")
|
||||||
}
|
}
|
||||||
ControlFunctionType::ControlString => write!(f, "Control String"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,9 +230,6 @@ impl fmt::Display for ControlFunction {
|
|||||||
ControlFunctionType::IndependentControlFunction => {
|
ControlFunctionType::IndependentControlFunction => {
|
||||||
write!(f, "{}{}", c0::ESC, self.value)
|
write!(f, "{}{}", c0::ESC, self.value)
|
||||||
}
|
}
|
||||||
ControlFunctionType::ControlString => {
|
|
||||||
write!(f, "{}", self.value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,10 +282,6 @@ mod tests {
|
|||||||
format!("{:?}", ControlFunctionType::IndependentControlFunction),
|
format!("{:?}", ControlFunctionType::IndependentControlFunction),
|
||||||
"Independent Control Function"
|
"Independent Control Function"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
|
||||||
format!("{:?}", ControlFunctionType::ControlString),
|
|
||||||
"Control String"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test the debug format of [`ControlFunction`][crate::ControlFunction].
|
/// Test the debug format of [`ControlFunction`][crate::ControlFunction].
|
||||||
|
|||||||
Reference in New Issue
Block a user