use std::convert::From;
use std::fmt::{self, Debug, Display, Formatter};
use std::ops::{Index, IndexMut};
use unicode_width::UnicodeWidthChar;
use unicode_width::UnicodeWidthStr;
use zellij_utils::input::command::RunCommand;
use zellij_utils::{
data::{PaletteColor, Style},
vte::ParamsIter,
};
use crate::panes::alacritty_functions::parse_sgr_color;
pub const EMPTY_TERMINAL_CHARACTER: TerminalCharacter = TerminalCharacter {
character: ' ',
width: 1,
styles: RESET_STYLES,
};
pub const RESET_STYLES: CharacterStyles = 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),
link_anchor: Some(LinkAnchor::End),
};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AnsiCode {
On,
Reset,
NamedColor(NamedColor),
RgbCode((u8, u8, u8)),
ColorIndex(u8),
}
impl From<PaletteColor> for AnsiCode {
fn from(palette_color: PaletteColor) -> Self {
match palette_color {
PaletteColor::Rgb((r, g, b)) => AnsiCode::RgbCode((r, g, b)),
PaletteColor::EightBit(index) => AnsiCode::ColorIndex(index),
}
}
}
#[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 {
let v = match self {
NamedColor::Black => 30,
NamedColor::Red => 31,
NamedColor::Green => 32,
NamedColor::Yellow => 33,
NamedColor::Blue => 34,