#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PromptStyle {
Lean,
Lean8,
Classic,
Rainbow,
Pure,
}
impl PromptStyle {
pub fn template_name(self) -> &'static str {
match self {
PromptStyle::Lean => "lean",
PromptStyle::Lean8 => "lean-8colors",
PromptStyle::Classic => "classic",
PromptStyle::Rainbow => "rainbow",
PromptStyle::Pure => "pure",
}
}
}
#[derive(Debug, Clone)]
pub struct WizardSettings {
pub style: PromptStyle,
pub mode: String,
pub icon_padding: String,
pub color: u8,
pub num_lines: u8,
pub empty_line: bool,
pub left_frame: bool,
pub right_frame: bool,
pub transient_prompt: bool,
pub instant_prompt: String,
pub gap_char: String,
pub prompt_char: String,
pub left_sep: String,
pub right_sep: String,
pub left_subsep: String,
pub right_subsep: String,
pub left_head: String,
pub right_head: String,
pub left_tail: String,
pub right_tail: String,
pub time: Option<String>,
pub extra_icons: [String; 3],
pub prefixes: [String; 2],
pub frame_color: [i32; 4],
pub cap_diamond: bool,
pub cap_python: bool,
pub cap_debian: bool,
pub cap_lock: bool,
pub cap_arrow: bool,
pub pure_use_rprompt: bool,
pub branch_icon: String,
pub has_truecolor: bool,
pub options: Vec<String>,
}
impl WizardSettings {
pub fn for_style(style: PromptStyle) -> Self {
WizardSettings {
style,
mode: String::new(),
icon_padding: "moderate".to_string(), color: 1, num_lines: 2, empty_line: false,
left_frame: true, right_frame: true,
transient_prompt: false,
instant_prompt: "verbose".to_string(), gap_char: " ".to_string(), prompt_char: "❯".to_string(), left_sep: String::new(),
right_sep: String::new(),
left_subsep: String::new(),
right_subsep: String::new(),
left_head: String::new(),
right_head: String::new(),
left_tail: String::new(),
right_tail: String::new(),
time: None,
extra_icons: [String::new(), String::new(), String::new()], prefixes: [String::new(), String::new()], frame_color: [244, 242, 240, 238], cap_diamond: false,
cap_python: false,
cap_debian: false,
cap_lock: false,
cap_arrow: false,
pure_use_rprompt: false,
branch_icon: "\u{f126}".to_string(), has_truecolor: false,
options: Vec::new(),
}
}
pub fn pure_color(&self, name: &str) -> &'static str {
if self.has_truecolor {
match name {
"grey" => "242",
"red" => "#FF5C57",
"yellow" => "#F3F99D",
"blue" => "#57C7FF",
"magenta" => "#FF6AC1",
"cyan" => "#9AEDFE",
"white" => "#F1F1F0",
_ => "242",
}
} else {
match name {
"grey" => "242",
"red" => "1",
"yellow" => "3",
"blue" => "4",
"magenta" => "5",
"cyan" => "6",
"white" => "7",
_ => "242",
}
}
}
}