use std::fmt::{Display, Formatter};
use crate::control::ControlSequence;
use crate::escape::{escape, EscapeSequence};
pub const BPH: EscapeSequence = escape('B');
pub const NBH: EscapeSequence = escape('C');
pub fn dimension_text(l: usize, c: usize) -> ControlSequence {
ControlSequence::new(&[&l.to_string(), &c.to_string()], " T")
}
pub fn select_font(font: Font) -> ControlSequence {
ControlSequence::new(&[&font.to_string(), "0"], " D")
}
#[derive(Copy, Clone, Debug)]
pub enum Font {
Primary,
Alternative1,
Alternative2,
Alternative3,
Alternative4,
Alternative5,
Alternative6,
Alternative7,
Alternative8,
Alternative9,
}
impl Display for Font {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
Font::Primary => "0",
Font::Alternative1 => "1",
Font::Alternative2 => "2",
Font::Alternative3 => "3",
Font::Alternative4 => "4",
Font::Alternative5 => "5",
Font::Alternative6 => "6",
Font::Alternative7 => "7",
Font::Alternative8 => "8",
Font::Alternative9 => "9"
})
}
}
pub fn character_combination(combination: Combination) -> ControlSequence {
ControlSequence::new(&[&combination.to_string()], " _")
}
#[derive(Copy, Clone, Debug)]
pub enum Combination {
Two,
Start,
End,
}
impl Display for Combination {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
Self::Two => "0",
Self::Start => "1",
Self::End => "2"
})
}
}
pub fn modify_size(height: usize, width: usize) -> ControlSequence {
ControlSequence::new(&[&height.to_string(), &width.to_string()], " B")
}
pub fn select_size(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " C")
}
pub fn justify(modes: &[JustifyMode]) -> ControlSequence {
let str_modes: Vec<String> = modes.iter()
.map(|mode| mode.to_string())
.collect();
let str_ref_modes: Vec<&str> = str_modes.iter()
.map(AsRef::as_ref)
.collect();
ControlSequence::new(&str_ref_modes, " F")
}
#[derive(Copy, Clone, Debug)]
pub enum JustifyMode {
None,
WordFill,
WordSpace,
LetterSpace,
Hyphen,
FlushHome,
Center,
FlushLimit,
ItalianHyphen,
}
impl Display for JustifyMode {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
JustifyMode::None => "0",
JustifyMode::WordFill => "1",
JustifyMode::WordSpace => "2",
JustifyMode::LetterSpace => "3",
JustifyMode::Hyphen => "4",
JustifyMode::FlushHome => "5",
JustifyMode::Center => "6",
JustifyMode::FlushLimit => "7",
JustifyMode::ItalianHyphen => "8",
})
}
}
pub fn expand_or_condense(expansion: Expansion) -> ControlSequence {
ControlSequence::new(&[&expansion.to_string()], " Z")
}
#[derive(Copy, Clone, Debug)]
pub enum Expansion {
Normal,
Expanded,
Condensed,
}
impl Display for Expansion {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
Self::Normal => "0",
Self::Expanded => "1",
Self::Condensed => "2"
})
}
}
pub fn select_page_format(page_format: PageFormat) -> ControlSequence {
ControlSequence::new(&[&page_format.to_string()], " J")
}
#[derive(Copy, Clone, Debug)]
pub enum PageFormat {
TallText,
WideText,
TallA4,
WideA4,
TallLetter,
WideLetter,
TallExtA4,
WideExtA4,
TallLegal,
WideLegal,
A4ShortLines,
A4LongLines,
B5ShortLines,
B5LongLines,
B4ShortLines,
B4LongLines,
}
impl Display for PageFormat {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
PageFormat::TallText => "0",
PageFormat::WideText => "1",
PageFormat::TallA4 => "2",
PageFormat::WideA4 => "3",
PageFormat::TallLetter => "4",
PageFormat::WideLetter => "5",
PageFormat::TallExtA4 => "6",
PageFormat::WideExtA4 => "7",
PageFormat::TallLegal => "8",
PageFormat::WideLegal => "9",
PageFormat::A4ShortLines => "10",
PageFormat::A4LongLines => "11",
PageFormat::B5ShortLines => "12",
PageFormat::B5LongLines => "13",
PageFormat::B4ShortLines => "14",
PageFormat::B4LongLines => "15",
})
}
}
pub fn parallel_texts(text_delimiter: TextDelimiter) -> ControlSequence {
ControlSequence::new(&[&text_delimiter.to_string()], "\\")
}
#[derive(Copy, Clone, Debug)]
pub enum TextDelimiter {
End,
BeginPrincipal,
BeginSupplementary,
BeginSupplementaryPhoneticJapanese,
BeginSupplementaryPhoneticChinese,
EndPhonetic,
}
impl Display for TextDelimiter {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
TextDelimiter::End => "0",
TextDelimiter::BeginPrincipal => "1",
TextDelimiter::BeginSupplementary => "2",
TextDelimiter::BeginSupplementaryPhoneticJapanese => "3",
TextDelimiter::BeginSupplementaryPhoneticChinese => "4",
TextDelimiter::EndPhonetic => "5",
})
}
}
pub fn quad(layouts: &[Layout]) -> ControlSequence {
let str_layouts: Vec<String> = layouts.iter()
.map(|mode| mode.to_string())
.collect();
let str_ref_modes: Vec<&str> = str_layouts.iter()
.map(AsRef::as_ref)
.collect();
ControlSequence::new(&str_ref_modes, " H")
}
#[derive(Copy, Clone, Debug)]
pub enum Layout {
FlushHome,
FlushHomeAndFill,
Center,
CenterAndFill,
FlushLimit,
FlushLimitAndFill,
FlushBoth,
}
impl Display for Layout {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
Layout::FlushHome => "0",
Layout::FlushHomeAndFill => "1",
Layout::Center => "2",
Layout::CenterAndFill => "3",
Layout::FlushLimit => "4",
Layout::FlushLimitAndFill => "5",
Layout::FlushBoth => "6",
})
}
}
pub fn repeat(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], "b")
}
pub fn add_separation(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " \\")
}
pub fn select_alternative() -> PresentationVariant {
PresentationVariant::new()
}
#[derive(Clone)]
pub struct PresentationVariant {
modes: Vec<String>,
}
impl PresentationVariant {
pub fn new() -> Self { Self { modes: vec![] } }
pub fn default(&mut self) -> &mut Self { self.add("0") }
pub fn latin_decimal(&mut self) -> &mut Self { self.add("1") }
pub fn arabic_decimal(&mut self) -> &mut Self { self.add("2") }
pub fn mirror_horizontal(&mut self) -> &mut Self { self.add("3") }
pub fn mirror_vertical(&mut self) -> &mut Self { self.add("4") }
pub fn character_isolate(&mut self) -> &mut Self { self.add("5") }
pub fn character_initial(&mut self) -> &mut Self { self.add("6") }
pub fn character_medial(&mut self) -> &mut Self { self.add("7") }
pub fn character_final(&mut self) -> &mut Self { self.add("8") }
pub fn decimal_stop(&mut self) -> &mut Self { self.add("9") }
pub fn decimal_comma(&mut self) -> &mut Self { self.add("10") }
pub fn vowel_above_or_below(&mut self) -> &mut Self { self.add("11") }
pub fn vowel_after(&mut self) -> &mut Self { self.add("12") }
pub fn arabic_ligature_aleph(&mut self) -> &mut Self { self.add("13") }
pub fn arabic_ligature_none(&mut self) -> &mut Self { self.add("14") }
pub fn no_mirror(&mut self) -> &mut Self { self.add("15") }
pub fn no_vowel(&mut self) -> &mut Self { self.add("16") }
pub fn italic_direction(&mut self) -> &mut Self { self.add("17") }
pub fn arabic_no_context_with_digit(&mut self) -> &mut Self { self.add("18") }
pub fn arabic_no_context(&mut self) -> &mut Self { self.add("19") }
pub fn device_digit(&mut self) -> &mut Self { self.add("20") }
pub fn character_establish(&mut self) -> &mut Self { self.add("21") }
pub fn character_cancel(&mut self) -> &mut Self { self.add("22") }
pub fn get(&self) -> ControlSequence {
ControlSequence::new(&self.modes.iter().map(|s| s.as_str()).collect::<Vec<_>>(), " ]")
}
fn add(&mut self, s: &str) -> &mut Self {
self.modes.push(s.to_string());
self
}
}
impl Display for PresentationVariant {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.get())
}
}
pub fn character_orientation(orientation: Orientation) -> ControlSequence {
ControlSequence::new(&[&orientation.to_string()], " e")
}
#[derive(Copy, Clone, Debug)]
pub enum Orientation {
North,
NorthWest,
West,
SouthWest,
South,
SouthEast,
East,
NorthEast,
}
impl Display for Orientation {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
Orientation::North => "0",
Orientation::NorthWest => "1",
Orientation::West => "2",
Orientation::SouthWest => "3",
Orientation::South => "4",
Orientation::SouthEast => "5",
Orientation::East => "6",
Orientation::NorthEast => "7",
})
}
}
pub fn character_path(character_path: CharacterPath, path_effect: PathEffect) -> ControlSequence {
ControlSequence::new(&[&character_path.to_string(), &path_effect.to_string()], " k")
}
#[derive(Copy, Clone, Debug)]
pub enum CharacterPath {
LeftToRight,
RightToLeft,
}
impl Display for CharacterPath {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
CharacterPath::LeftToRight => "1",
CharacterPath::RightToLeft => "2",
})
}
}
#[derive(Copy, Clone, Debug)]
pub enum PathEffect {
Undefined,
UpdatePresentation,
UpdateData,
}
impl Display for PathEffect {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
PathEffect::Undefined => "0",
PathEffect::UpdatePresentation => "1",
PathEffect::UpdateData => "2",
})
}
}
pub fn directed(string_direction: StringDirection) -> ControlSequence {
ControlSequence::new(&[&string_direction.to_string()], "]")
}
#[derive(Copy, Clone, Debug)]
pub enum StringDirection {
End,
StartLeftToRight,
StartRightToLeft,
}
impl Display for StringDirection {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
StringDirection::End => "0",
StringDirection::StartLeftToRight => "1",
StringDirection::StartRightToLeft => "2",
})
}
}
pub fn select_implicit(movement_direction: MovementDirection) -> ControlSequence {
ControlSequence::new(&[&movement_direction.to_string()], "^")
}
#[derive(Copy, Clone, Debug)]
pub enum MovementDirection {
Same,
Opposite,
}
impl Display for MovementDirection {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
MovementDirection::Same => "0",
MovementDirection::Opposite => "1",
})
}
}
pub fn select_graphic() -> GraphicSelection {
GraphicSelection::new()
}
#[derive(Clone)]
pub struct GraphicSelection {
modes: Vec<String>,
}
impl GraphicSelection {
pub fn new() -> Self { Self { modes: vec![] } }
pub fn default(&mut self) -> &mut Self { self.add("0") }
pub fn bold(&mut self) -> &mut Self { self.add("1") }
pub fn faint(&mut self) -> &mut Self { self.add("2") }
pub fn italic(&mut self) -> &mut Self { self.add("3") }
pub fn underline(&mut self) -> &mut Self { self.add("4") }
pub fn slow_blink(&mut self) -> &mut Self { self.add("5") }
pub fn fast_blink(&mut self) -> &mut Self { self.add("6") }
pub fn negative(&mut self) -> &mut Self { self.add("7") }
pub fn conceal(&mut self) -> &mut Self { self.add("8") }
pub fn cross(&mut self) -> &mut Self { self.add("9") }
pub fn primary_font(&mut self) -> &mut Self { self.add("10") }
pub fn alter1_font(&mut self) -> &mut Self { self.add("11") }
pub fn alter2_font(&mut self) -> &mut Self { self.add("12") }
pub fn alter3_font(&mut self) -> &mut Self { self.add("13") }
pub fn alter4_font(&mut self) -> &mut Self { self.add("14") }
pub fn alter5_font(&mut self) -> &mut Self { self.add("15") }
pub fn alter6_font(&mut self) -> &mut Self { self.add("16") }
pub fn alter7_font(&mut self) -> &mut Self { self.add("17") }
pub fn alter8_font(&mut self) -> &mut Self { self.add("18") }
pub fn alter9_font(&mut self) -> &mut Self { self.add("19") }
pub fn gothic_font(&mut self) -> &mut Self { self.add("20") }
pub fn double_underline(&mut self) -> &mut Self { self.add("21") }
pub fn not_bold_or_faint(&mut self) -> &mut Self { self.add("22") }
pub fn not_italic(&mut self) -> &mut Self { self.add("23") }
pub fn not_underline(&mut self) -> &mut Self { self.add("24") }
pub fn not_blink(&mut self) -> &mut Self { self.add("25") }
pub fn not_negative(&mut self) -> &mut Self { self.add("27") }
pub fn not_conceal(&mut self) -> &mut Self { self.add("28") }
pub fn not_cross(&mut self) -> &mut Self { self.add("29") }
pub fn fg_black(&mut self) -> &mut Self { self.add("30") }
pub fn fg_red(&mut self) -> &mut Self { self.add("31") }
pub fn fg_green(&mut self) -> &mut Self { self.add("32") }
pub fn fg_yellow(&mut self) -> &mut Self { self.add("33") }
pub fn fg_blue(&mut self) -> &mut Self { self.add("34") }
pub fn fg_magenta(&mut self) -> &mut Self { self.add("35") }
pub fn fg_cyan(&mut self) -> &mut Self { self.add("36") }
pub fn fg_gray(&mut self) -> &mut Self { self.add("37") }
pub fn fg_color(&mut self) -> &mut Self { self.add("38") }
pub fn fg_default(&mut self) -> &mut Self { self.add("39") }
pub fn bg_black(&mut self) -> &mut Self { self.add("40") }
pub fn bg_red(&mut self) -> &mut Self { self.add("41") }
pub fn bg_green(&mut self) -> &mut Self { self.add("42") }
pub fn bg_yellow(&mut self) -> &mut Self { self.add("43") }
pub fn bg_blue(&mut self) -> &mut Self { self.add("44") }
pub fn bg_magenta(&mut self) -> &mut Self { self.add("45") }
pub fn bg_cyan(&mut self) -> &mut Self { self.add("46") }
pub fn bg_gray(&mut self) -> &mut Self { self.add("47") }
pub fn bg_color(&mut self) -> &mut Self { self.add("48") }
pub fn bg_default(&mut self) -> &mut Self { self.add("49") }
pub fn frame(&mut self) -> &mut Self { self.add("51") }
pub fn encircle(&mut self) -> &mut Self { self.add("52") }
pub fn overline(&mut self) -> &mut Self { self.add("53") }
pub fn not_frame_not_encircle(&mut self) -> &mut Self { self.add("54") }
pub fn not_overline(&mut self) -> &mut Self { self.add("55") }
pub fn ideogram_underline(&mut self) -> &mut Self { self.add("60") }
pub fn ideogram_double_underline(&mut self) -> &mut Self { self.add("61") }
pub fn ideogram_overline(&mut self) -> &mut Self { self.add("62") }
pub fn ideogram_double_overline(&mut self) -> &mut Self { self.add("63") }
pub fn ideogram_stress_marking(&mut self) -> &mut Self { self.add("64") }
pub fn ideogram_cancel(&mut self) -> &mut Self { self.add("65") }
pub fn get(&self) -> ControlSequence {
ControlSequence::new(&self.modes.iter().map(|s| s.as_str()).collect::<Vec<_>>(), "m")
}
fn add(&mut self, s: &str) -> &mut Self {
self.modes.push(s.to_string());
self
}
}
impl Display for GraphicSelection {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.get())
}
}
pub fn format_str(str: &str, format: &GraphicSelection) -> String {
format!("{}{}{}", format, str, select_graphic().default())
}
pub fn select_spacing(character_spacing: CharacterSpacing) -> ControlSequence {
ControlSequence::new(&[&character_spacing.to_string()], " K")
}
#[derive(Copy, Clone, Debug)]
pub enum CharacterSpacing {
Per25mm10Chars,
Per25mm12Chars,
Per25mm15Chars,
Per25mm16Chars,
Per25mm3Chars,
Per50mm9Chars,
Per25mm4Chars,
}
impl Display for CharacterSpacing {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
CharacterSpacing::Per25mm10Chars => "0",
CharacterSpacing::Per25mm12Chars => "1",
CharacterSpacing::Per25mm15Chars => "2",
CharacterSpacing::Per25mm16Chars => "3",
CharacterSpacing::Per25mm3Chars => "4",
CharacterSpacing::Per50mm9Chars => "5",
CharacterSpacing::Per25mm4Chars => "6",
})
}
}
pub fn line_home(c: usize) -> ControlSequence {
ControlSequence::new(&[&c.to_string()], " U")
}
pub fn line_limit(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " V")
}
pub fn line_spacing(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " h")
}
pub fn select_directions(
line_orientation: LineOrientation,
line_progression: CharacterPath,
character_path: CharacterPath,
path_effect: PathEffect,
) -> ControlSequence {
ControlSequence::new(&[&spd_ps1(line_orientation, line_progression, character_path).to_string(), &path_effect.to_string()], " S")
}
#[derive(Copy, Clone, Debug)]
pub enum LineOrientation {
Horizontal,
Vertical,
}
fn spd_ps1(line_orientation: LineOrientation, line_progression: CharacterPath, character_path: CharacterPath) -> usize {
match line_orientation {
LineOrientation::Horizontal => {
match line_progression {
CharacterPath::LeftToRight => {
match character_path {
CharacterPath::LeftToRight => 0,
CharacterPath::RightToLeft => 3,
}
}
CharacterPath::RightToLeft => {
match character_path {
CharacterPath::LeftToRight => 6,
CharacterPath::RightToLeft => 5,
}
}
}
}
LineOrientation::Vertical => {
match line_progression {
CharacterPath::LeftToRight => {
match character_path {
CharacterPath::LeftToRight => 2,
CharacterPath::RightToLeft => 4,
}
}
CharacterPath::RightToLeft => {
match character_path {
CharacterPath::LeftToRight => 1,
CharacterPath::RightToLeft => 7,
}
}
}
}
}
}
pub fn page_home(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " i")
}
pub fn spacing_increment(line_spacing: usize, character_spacing: usize) -> ControlSequence {
ControlSequence::new(&[&line_spacing.to_string(), &character_spacing.to_string()], " G")
}
pub fn page_limit(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " j")
}
pub fn print_quality(print_quality: PrintQuality) -> ControlSequence {
ControlSequence::new(&[&print_quality.to_string()], " X")
}
#[derive(Copy, Clone, Debug)]
pub enum PrintQuality {
Highest,
Medium,
Draft,
}
impl Display for PrintQuality {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
PrintQuality::Highest => "0",
PrintQuality::Medium => "1",
PrintQuality::Draft => "2",
})
}
}
pub fn reduce_separation(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " f")
}
pub fn reversed(string_reversion: StringReversion) -> ControlSequence {
ControlSequence::new(&[&string_reversion.to_string()], "[")
}
#[derive(Copy, Clone, Debug)]
pub enum StringReversion {
End,
BeginReverse,
}
impl Display for StringReversion {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
Self::End => "0",
Self::BeginReverse => "1",
})
}
}
pub fn select_size_unit(size_unit: SizeUnit) -> ControlSequence {
ControlSequence::new(&[&size_unit.to_string()], " I")
}
#[derive(Copy, Clone, Debug)]
pub enum SizeUnit {
Character,
Millimeter,
ComputerDeciPoint,
DeciDidot,
Mil,
BasicMeasuringUnit,
Micrometer,
Pixel,
DeciPoint,
}
impl Display for SizeUnit {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
SizeUnit::Character => "0",
SizeUnit::Millimeter => "1",
SizeUnit::ComputerDeciPoint => "2",
SizeUnit::DeciDidot => "3",
SizeUnit::Mil => "4",
SizeUnit::BasicMeasuringUnit => "5",
SizeUnit::Micrometer => "6",
SizeUnit::Pixel => "7",
SizeUnit::DeciPoint => "8",
})
}
}
pub fn space_width(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " [")
}
pub fn select_tabulation(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " ^")
}
pub fn select_line_spacing(line_spacing: LineSpacing) -> ControlSequence {
ControlSequence::new(&[&line_spacing.to_string()], " L")
}
#[derive(Copy, Clone, Debug)]
pub enum LineSpacing {
Per25mm6Lines,
Per25mm4Lines,
Per25mm3Lines,
Per25mm12Lines,
Per25mm8Lines,
Per30mm6Lines,
Per30mm4Lines,
Per30mm3Lines,
Per30mm12Lines,
Per25mm2Lines,
}
impl Display for LineSpacing {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", match self {
LineSpacing::Per25mm6Lines => "0",
LineSpacing::Per25mm4Lines => "1",
LineSpacing::Per25mm3Lines => "2",
LineSpacing::Per25mm12Lines => "3",
LineSpacing::Per25mm8Lines => "4",
LineSpacing::Per30mm6Lines => "5",
LineSpacing::Per30mm4Lines => "6",
LineSpacing::Per30mm3Lines => "7",
LineSpacing::Per30mm12Lines => "8",
LineSpacing::Per25mm2Lines => "9",
})
}
}
pub fn align_center(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " b")
}
pub fn align_leading(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " a")
}
pub fn align_trailing(n: usize) -> ControlSequence {
ControlSequence::new(&[&n.to_string()], " `")
}
pub fn tabulation_center_on_char(l: usize, ascii: usize) -> ControlSequence {
ControlSequence::new(&[&l.to_string(), &ascii.to_string()], " c")
}
pub fn specify_thin_space(width: usize) -> ControlSequence {
ControlSequence::new(&[&width.to_string()], " E")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_space_width() {
let cs = space_width(5);
assert_eq!(cs.to_string(), "\x1b[5 [");
}
#[test]
fn test_select_tabulation() {
let cs = select_tabulation(3);
assert_eq!(cs.to_string(), "\x1b[3 ^");
}
#[test]
fn test_select_line_spacing() {
let cs = select_line_spacing(LineSpacing::Per25mm6Lines);
assert_eq!(cs.to_string(), "\x1b[0 L");
let cs = select_line_spacing(LineSpacing::Per30mm12Lines);
assert_eq!(cs.to_string(), "\x1b[8 L");
}
#[test]
fn test_line_spacing_display() {
let ls = LineSpacing::Per25mm4Lines;
assert_eq!(ls.to_string(), "1");
let ls = LineSpacing::Per30mm3Lines;
assert_eq!(ls.to_string(), "7");
}
#[test]
fn test_align_center() {
let cs = align_center(10);
assert_eq!(cs.to_string(), "\x1b[10 b");
}
#[test]
fn test_align_leading() {
let cs = align_leading(15);
assert_eq!(cs.to_string(), "\x1b[15 a");
}
#[test]
fn test_align_trailing() {
let cs = align_trailing(20);
assert_eq!(cs.to_string(), "\x1b[20 `");
}
#[test]
fn test_tabulation_center_on_char() {
let cs = tabulation_center_on_char(25, 65);
assert_eq!(cs.to_string(), "\x1b[25;65 c");
}
#[test]
fn test_specify_thin_space() {
let cs = specify_thin_space(2);
assert_eq!(cs.to_string(), "\x1b[2 E");
}
}