mod first_line;
mod second_line;
mod tip;
use ansi_term::{
ANSIString,
Colour::{Fixed, RGB},
Style,
};
use std::fmt::{Display, Error, Formatter};
use zellij_tile::prelude::actions::Action;
use zellij_tile::prelude::*;
use zellij_tile_utils::{palette_match, style};
use first_line::first_line;
use second_line::{
floating_panes_are_visible, fullscreen_panes_to_hide, keybinds,
locked_floating_panes_are_visible, locked_fullscreen_panes_to_hide, system_clipboard_error,
text_copied_hint,
};
use tip::utils::get_cached_tip_name;
// for more of these, copy paste from: https://en.wikipedia.org/wiki/Box-drawing_character
static ARROW_SEPARATOR: &str = "";
static MORE_MSG: &str = " ... ";
/// Shorthand for `Action::SwitchToMode(InputMode::Normal)`.
const TO_NORMAL: Action = Action::SwitchToMode(InputMode::Normal);
#[derive(Default)]
struct State {
tabs: Vec<TabInfo>,
tip_name: String,
mode_info: ModeInfo,
text_copy_destination: Option<CopyDestination>,
display_system_clipboard_failure: bool,
}
register_plugin!(State);
#[derive(Default)]
pub struct LinePart {
part: String,
len: usize,
}
impl Display for LinePart {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
write!(f, "{}", self.part)
}
}
#[derive(Clone, Copy)]
pub struct ColoredElements {
pub selected: SegmentStyle,
pub unselected: SegmentStyle,
pub unselected_alternate: SegmentStyle,
pub disabled: SegmentStyle,
// superkey
pub superkey_prefix: Style,
pub superkey_suffix_separator: Style,
}
#[derive(Clone, Copy)]
pub struct SegmentStyle {
pub prefix_separator: Style,
pub char_left_separator: Style,
pub char_shortcut: Style,
pub char_right_separator: Style,
pub styled_text: Style,
pub suffix_separator: Style,
}
// I really hate this, but I can't come up with a good solution for this,
// we need different colors from palette for the default theme
// plus here we can add new sources in the future, like Theme
// that can be defined in the config perhaps
fn color_elements(palette: Palette, different_color_alternates: bool) -> ColoredElements {
let background = match palette.theme_hue {
ThemeHue::Dark => palette.black,
ThemeHue::Light => palette.white,
};
let foreground = match palette.theme_hue {
ThemeHue::Dark => palette.white,
ThemeHue::Light => palette.black,
};
let alternate_background_color = if different_color_alternates {
match palette.theme_hue {
ThemeHue::Dark => palette.white,
ThemeHue::Light => palette.black,
}
} else {
palette.fg
};
match palette.source {
PaletteSource::Default => ColoredElements {
selected: SegmentStyle {
prefix_separator: style!(background, palette.green),
char_left_separator: style!(background, palette.green).bold(),
char_shortcut: style!(palette.red, palette.