use std::path::PathBuf;
use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Mode {
#[default]
Terminal,
Window,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Protocol {
#[default]
Auto,
Kitty,
Iterm2,
Sixel,
Halfblocks,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Backend {
#[default]
Auto,
Metal,
Vulkan,
Dx12,
Gl,
}
impl Backend {
pub fn backends(self) -> wgpu::Backends {
match self {
Backend::Auto => wgpu::Backends::PRIMARY | wgpu::Backends::GL,
Backend::Metal => wgpu::Backends::METAL,
Backend::Vulkan => wgpu::Backends::VULKAN,
Backend::Dx12 => wgpu::Backends::DX12,
Backend::Gl => wgpu::Backends::GL,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(missing_docs)]
pub struct Palette {
pub black: [u8; 3],
pub red: [u8; 3],
pub green: [u8; 3],
pub yellow: [u8; 3],
pub blue: [u8; 3],
pub magenta: [u8; 3],
pub cyan: [u8; 3],
pub gray: [u8; 3],
pub dark_gray: [u8; 3],
pub light_red: [u8; 3],
pub light_green: [u8; 3],
pub light_yellow: [u8; 3],
pub light_blue: [u8; 3],
pub light_magenta: [u8; 3],
pub light_cyan: [u8; 3],
pub white: [u8; 3],
pub foreground: [u8; 3],
pub background: [u8; 3],
}
impl Palette {
pub const DARK: Palette = Palette {
black: [0x12, 0x12, 0x14],
red: [0xe0, 0x5a, 0x5a],
green: [0x6c, 0xc6, 0x6c],
yellow: [0xe5, 0xc0, 0x5c],
blue: [0x5c, 0x8f, 0xe5],
magenta: [0xc6, 0x78, 0xdd],
cyan: [0x56, 0xc8, 0xd8],
gray: [0xb4, 0xb4, 0xb4],
dark_gray: [0x4a, 0x4a, 0x50],
light_red: [0xff, 0x7b, 0x7b],
light_green: [0x8e, 0xe0, 0x8e],
light_yellow: [0xff, 0xdc, 0x7c],
light_blue: [0x82, 0xaa, 0xff],
light_magenta: [0xe0, 0x9a, 0xf0],
light_cyan: [0x7c, 0xe0, 0xee],
white: [0xf0, 0xf0, 0xf0],
foreground: [0xd8, 0xd8, 0xd8],
background: [0x12, 0x12, 0x14],
};
pub const LIGHT: Palette = Palette {
black: [0x20, 0x20, 0x20],
red: [0xc0, 0x30, 0x30],
green: [0x2f, 0x8a, 0x2f],
yellow: [0x9a, 0x70, 0x00],
blue: [0x2a, 0x5d, 0xb8],
magenta: [0x95, 0x3c, 0xb0],
cyan: [0x1a, 0x80, 0x90],
gray: [0x60, 0x60, 0x60],
dark_gray: [0xc8, 0xc8, 0xcc],
light_red: [0xe0, 0x50, 0x50],
light_green: [0x40, 0xa0, 0x40],
light_yellow: [0xb0, 0x88, 0x10],
light_blue: [0x40, 0x78, 0xd8],
light_magenta: [0xb0, 0x58, 0xc8],
light_cyan: [0x20, 0x98, 0xa8],
white: [0x10, 0x10, 0x10],
foreground: [0x20, 0x20, 0x24],
background: [0xfa, 0xfa, 0xf7],
};
}
impl Default for Palette {
fn default() -> Self {
Palette::DARK
}
}
#[derive(Debug, Clone)]
pub struct Config {
pub mode: Mode,
pub backend: Backend,
pub protocol: Protocol,
pub mouse: bool,
pub title: String,
pub window_size: (f64, f64),
pub font_size: f64,
pub font: Option<PathBuf>,
pub palette: Palette,
pub idle_poll: Duration,
pub switch_key: Option<char>,
pub help_key: Option<char>,
pub input: crate::gesture::Input,
pub copy_key: Option<char>,
}
impl Default for Config {
fn default() -> Self {
Config {
mode: Mode::Terminal,
backend: Backend::Auto,
protocol: Protocol::Auto,
mouse: true,
title: "scopekit".into(),
window_size: (1280.0, 800.0),
font_size: 15.0,
font: None,
palette: Palette::DARK,
idle_poll: Duration::from_millis(250),
switch_key: None,
help_key: Some('?'),
input: crate::gesture::Input::default(),
copy_key: None,
}
}
}