use super::EditorStatusLine;
use ratatui_core::style::{Color, Style};
use ratatui_widgets::block::Block;
pub struct EditorTheme<'a> {
pub base: Style,
pub cursor_style: Style,
pub selection_style: Style,
pub block: Option<Block<'a>>,
pub status_line: Option<EditorStatusLine>,
pub line_numbers_style: Style,
}
impl Default for EditorTheme<'_> {
fn default() -> Self {
Self {
base: Style::default().bg(BLACK).fg(WHITE),
block: None,
cursor_style: Style::default().bg(WHITE).fg(BLACK),
selection_style: Style::default().bg(YELLOW).fg(BLACK),
status_line: Some(EditorStatusLine::default()),
line_numbers_style: Style::default().bg(BLACK).fg(GRAY),
}
}
}
impl<'a> EditorTheme<'a> {
#[must_use]
pub fn base(mut self, base: Style) -> Self {
self.base = base;
self
}
#[must_use]
pub fn base_style(&self) -> Style {
self.base
}
#[must_use]
pub fn block(mut self, block: Block<'a>) -> Self {
self.block = Some(block);
self
}
#[must_use]
pub fn cursor_style(mut self, style: Style) -> Self {
self.cursor_style = style;
self
}
#[must_use]
pub fn hide_cursor(mut self) -> Self {
self.cursor_style = self.base;
self
}
#[must_use]
pub fn selection_style(mut self, style: Style) -> Self {
self.selection_style = style;
self
}
#[must_use]
pub fn status_line(mut self, status_line: EditorStatusLine) -> Self {
self.status_line = Some(status_line);
self
}
#[must_use]
pub fn hide_status_line(mut self) -> Self {
self.status_line = None;
self
}
#[must_use]
pub fn line_numbers_style(mut self, style: Style) -> Self {
self.line_numbers_style = style;
self
}
}
pub(crate) const WHITE: Color = Color::Rgb(255, 255, 255);
pub(crate) const BLACK: Color = Color::Rgb(0, 0, 0);
pub(crate) const DARK_GRAY: Color = Color::Rgb(16, 17, 22);
pub(crate) const YELLOW: Color = Color::Rgb(250, 204, 21);
pub(crate) const GRAY: Color = Color::Rgb(100, 100, 100);