use unicode_width::UnicodeWidthChar;
use std::convert::TryFrom;
use std::fmt::{self, Debug, Display, Formatter};
use std::ops::{Index, IndexMut};
use vte::ParamsIter;
use zellij_utils::logging::debug_log_to_file;
pub const EMPTY_TERMINAL_CHARACTER: TerminalCharacter = TerminalCharacter {
character: ' ',
styles: CharacterStyles {
foreground: Some(AnsiCode::Reset),
background: Some(AnsiCode::Reset),
strike: Some(AnsiCode::Reset),
hidden: Some(AnsiCode::Reset),
reverse: Some(AnsiCode::Reset),
slow_blink: Some(AnsiCode::Reset),
fast_blink: Some(AnsiCode::Reset),
underline: Some(AnsiCode::Reset),
bold: Some(AnsiCode::Reset),
dim: Some(AnsiCode::Reset),
italic: Some(AnsiCode::Reset),
},
};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AnsiCode {
On,
Reset,
NamedColor(NamedColor),
RgbCode((u8, u8, u8)),
ColorIndex(u8),
}
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
pub enum NamedColor {
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
White,
BrightBlack,
BrightRed,
BrightGreen,
BrightYellow,
BrightBlue,
BrightMagenta,
BrightCyan,
BrightWhite,
}
impl NamedColor {
fn to_foreground_ansi_code(self) -> String {
match self {
NamedColor::Black => format!("{}", 30),
NamedColor::Red => format!("{}", 31),
NamedColor::Green => format!("{}", 32),
NamedColor::Yellow => format!("{}", 33),
NamedColor::Blue => format!("{}", 34),
NamedColor::Magenta => format!("{}", 35),
NamedColor::Cyan => format!("{}", 36),
NamedColor::White => format!("{}", 37),
NamedColor::BrightBlack => format!("{}", 90),
NamedColor::BrightRed => format!("{}", 91),
NamedColor::BrightGreen => format!("{}", 92),
NamedColor::BrightYellow => format!("{}", 93),
NamedColor::BrightBlue => format!("{}", 94),
NamedColor::BrightMagenta => format!("{}", 95),
NamedColor::BrightCyan => format!("{}", 96),
NamedColor::BrightWhite => format!("{}", 97),
}
}
fn to_background_ansi_code(self) -> String {
match self {
NamedColor::Black => format!("{}", 40),
NamedColor::Red => format!("{}", 41),
NamedColor::Green => format!