use ansi_term::{
ANSIStrings,
Color::{Fixed, RGB},
Style,
};
use zellij_tile::prelude::*;
use crate::{
tip::{data::TIPS, TipFn},
LinePart, MORE_MSG,
};
#[derive(Clone, Copy)]
enum StatusBarTextColor {
White,
Green,
Orange,
}
#[derive(Clone, Copy)]
enum StatusBarTextBoldness {
Bold,
NotBold,
}
fn full_length_shortcut(
is_first_shortcut: bool,
letter: &str,
description: &str,
palette: Palette,
) -> LinePart {
let white_color = match palette.white {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
let green_color = match palette.green {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
let separator = if is_first_shortcut { " " } else { " / " };
let separator = Style::new().fg(white_color).paint(separator);
let shortcut_len = letter.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
let shortcut_left_separator = Style::new().fg(white_color).paint("<");
let shortcut = Style::new().fg(green_color).bold().paint(letter);
let shortcut_right_separator = Style::new().fg(white_color).paint("> ");
let description_len = description.chars().count();
let description = Style::new().fg(white_color).bold().paint(description);
let len = shortcut_len + description_len + separator.chars().count();
LinePart {
part: ANSIStrings(&[
separator,
shortcut_left_separator,
shortcut,
shortcut_right_separator,
description,
])
.to_string(),
len,
}
}
fn first_word_shortcut(
is_first_shortcut: bool,
letter: &str,
description: &str,
palette: Palette,
) -> LinePart {
let white_color = match palette.white {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
let green_color = match palette.green {
PaletteColor::Rgb((r, g, b)) => RGB(r, g, b),
PaletteColor::EightBit(color) => Fixed(color),
};
let separator = if is_first_shortcut { " " } else { " / " };
let separator = Style::new().fg(white_color).paint(separator);
let shortcut_len = letter.chars().count() + 3; // 2 for <>'s around shortcut, 1 for the space
let shortcut_left_separator = Style::new().fg(white_color).paint("<");
let shortcut = Style::new().fg(green_color).bold().paint(letter);
let shortcut_right_separator = Style::new().fg(white_color).paint("> ");
let description_first_word = description.split(' ').next().unwrap_or("");
let description_first_word_length = description_first_word.chars().count();
let description_first_word = Style::new()
.fg(white_color)
.bold()
.paint(description_first_word);
let len = shortcut_len + description_first_word_length + separator.chars().count();
LinePart {