chore: cleanup, fix: the tests finally pass
This commit is contained in:
parent
eabecde90b
commit
f85822972a
14 changed files with 140 additions and 98 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -2254,6 +2254,7 @@ dependencies = [
|
||||||
name = "zellij-tile"
|
name = "zellij-tile"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"ansi_term 0.12.1",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"strum",
|
"strum",
|
||||||
|
|
|
||||||
|
|
@ -119,19 +119,6 @@ impl ColoredElements {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! rgb {
|
|
||||||
($a:expr) => {
|
|
||||||
RGB($a.0, $a.1, $a.2)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! style {
|
|
||||||
($a:expr, $b:expr) => {
|
|
||||||
Style::new()
|
|
||||||
.fg(RGB($a.0, $a.1, $a.2))
|
|
||||||
.on(RGB($b.0, $b.1, $b.2))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// I really hate this, but I can't come up with a good solution for this,
|
// 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
|
// we need different colors from palette for the default theme
|
||||||
// plus here we can add new sources in the future, like Theme
|
// plus here we can add new sources in the future, like Theme
|
||||||
|
|
|
||||||
|
|
@ -223,13 +223,25 @@ fn quicknav_short(palette: Palette) -> LinePart {
|
||||||
part: format!(
|
part: format!(
|
||||||
"{}{}{}{}{}{}{}{}",
|
"{}{}{}{}{}{}{}{}",
|
||||||
text_first_part,
|
text_first_part,
|
||||||
Style::new().fg(RGB(palette.orange.0, palette.orange.1, palette.orange.2)).bold().paint(alt),
|
Style::new()
|
||||||
|
.fg(RGB(palette.orange.0, palette.orange.1, palette.orange.2))
|
||||||
|
.bold()
|
||||||
|
.paint(alt),
|
||||||
text_second_part,
|
text_second_part,
|
||||||
Style::new().fg(RGB(palette.green.0, palette.green.1, palette.green.2)).bold().paint(new_pane_shortcut),
|
Style::new()
|
||||||
|
.fg(RGB(palette.green.0, palette.green.1, palette.green.2))
|
||||||
|
.bold()
|
||||||
|
.paint(new_pane_shortcut),
|
||||||
text_third_part,
|
text_third_part,
|
||||||
Style::new().fg(RGB(palette.green.0, palette.green.1, palette.green.2)).bold().paint(brackets_navigation),
|
Style::new()
|
||||||
|
.fg(RGB(palette.green.0, palette.green.1, palette.green.2))
|
||||||
|
.bold()
|
||||||
|
.paint(brackets_navigation),
|
||||||
text_fifth_part,
|
text_fifth_part,
|
||||||
Style::new().fg(RGB(palette.green.0, palette.green.1, palette.green.2)).bold().paint(hjkl_navigation),
|
Style::new()
|
||||||
|
.fg(RGB(palette.green.0, palette.green.1, palette.green.2))
|
||||||
|
.bold()
|
||||||
|
.paint(hjkl_navigation),
|
||||||
),
|
),
|
||||||
len,
|
len,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,7 @@
|
||||||
use ansi_term::{ANSIStrings, Color::RGB, Style};
|
use ansi_term::ANSIStrings;
|
||||||
|
|
||||||
use crate::{LinePart, ARROW_SEPARATOR};
|
use crate::{LinePart, ARROW_SEPARATOR};
|
||||||
use zellij_tile::data::{colors::*, Palette};
|
use zellij_tile::prelude::*;
|
||||||
|
|
||||||
macro_rules! style {
|
|
||||||
($a:expr, $b:expr) => {
|
|
||||||
Style::new()
|
|
||||||
.fg(RGB($a.0, $a.1, $a.2))
|
|
||||||
.on(RGB($b.0, $b.1, $b.2))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_current_title_len(current_title: &[LinePart]) -> usize {
|
fn get_current_title_len(current_title: &[LinePart]) -> usize {
|
||||||
current_title
|
current_title
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ impl ZellijPlugin for State {
|
||||||
t.active,
|
t.active,
|
||||||
t.position,
|
t.position,
|
||||||
t.is_sync_panes_active,
|
t.is_sync_panes_active,
|
||||||
self.mode_info.palette
|
self.mode_info.palette,
|
||||||
);
|
);
|
||||||
all_tabs.push(tab);
|
all_tabs.push(tab);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,6 @@
|
||||||
use crate::{LinePart, ARROW_SEPARATOR};
|
use crate::{LinePart, ARROW_SEPARATOR};
|
||||||
use ansi_term::{ANSIStrings, Color::RGB, Style};
|
use ansi_term::{ANSIStrings, Color::RGB, Style};
|
||||||
use zellij_tile::data::Palette;
|
use zellij_tile::prelude::*;
|
||||||
|
|
||||||
macro_rules! style {
|
|
||||||
($a:expr, $b:expr) => {
|
|
||||||
Style::new()
|
|
||||||
.fg(RGB($a.0, $a.1, $a.2))
|
|
||||||
.on(RGB($b.0, $b.1, $b.2))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn active_tab(text: String, palette: Palette) -> LinePart {
|
pub fn active_tab(text: String, palette: Palette) -> LinePart {
|
||||||
let left_separator = style!(palette.bg, palette.green).paint(ARROW_SEPARATOR);
|
let left_separator = style!(palette.bg, palette.green).paint(ARROW_SEPARATOR);
|
||||||
|
|
@ -49,7 +41,7 @@ pub fn tab_style(
|
||||||
is_active_tab: bool,
|
is_active_tab: bool,
|
||||||
position: usize,
|
position: usize,
|
||||||
is_sync_panes_active: bool,
|
is_sync_panes_active: bool,
|
||||||
palette: Palette
|
palette: Palette,
|
||||||
) -> LinePart {
|
) -> LinePart {
|
||||||
let mut tab_text = if text.is_empty() {
|
let mut tab_text = if text.is_empty() {
|
||||||
format!("Tab #{}", position + 1)
|
format!("Tab #{}", position + 1)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use super::actions::Action;
|
use super::actions::Action;
|
||||||
use super::keybinds::Keybinds;
|
use super::keybinds::Keybinds;
|
||||||
use crate::common::input::config::Config;
|
use crate::common::{input::config::Config};
|
||||||
use crate::common::{AppInstruction, SenderWithContext, OPENCALLS};
|
use crate::common::{AppInstruction, SenderWithContext, OPENCALLS};
|
||||||
use crate::errors::ContextType;
|
use crate::errors::ContextType;
|
||||||
use crate::os_input_output::OsApi;
|
use crate::os_input_output::OsApi;
|
||||||
|
|
@ -11,9 +11,8 @@ use crate::screen::ScreenInstruction;
|
||||||
use crate::wasm_vm::PluginInstruction;
|
use crate::wasm_vm::PluginInstruction;
|
||||||
use crate::CommandIsExecuting;
|
use crate::CommandIsExecuting;
|
||||||
|
|
||||||
use crate::common::utils::shared::load_palette;
|
|
||||||
use termion::input::{TermRead, TermReadEventsAndRaw};
|
use termion::input::{TermRead, TermReadEventsAndRaw};
|
||||||
use zellij_tile::data::{Event, InputMode, Key, ModeInfo};
|
use zellij_tile::data::{Event, InputMode, Key, ModeInfo, Palette};
|
||||||
|
|
||||||
/// Handles the dispatching of [`Action`]s according to the current
|
/// Handles the dispatching of [`Action`]s according to the current
|
||||||
/// [`InputMode`], and keep tracks of the current [`InputMode`].
|
/// [`InputMode`], and keep tracks of the current [`InputMode`].
|
||||||
|
|
@ -132,11 +131,14 @@ impl InputHandler {
|
||||||
self.send_plugin_instructions
|
self.send_plugin_instructions
|
||||||
.send(PluginInstruction::Update(
|
.send(PluginInstruction::Update(
|
||||||
None,
|
None,
|
||||||
Event::ModeUpdate(get_mode_info(mode)),
|
Event::ModeUpdate(get_mode_info(mode, self.os_input.load_palette())),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
self.send_screen_instructions
|
self.send_screen_instructions
|
||||||
.send(ScreenInstruction::ChangeMode(get_mode_info(mode)))
|
.send(ScreenInstruction::ChangeMode(get_mode_info(
|
||||||
|
mode,
|
||||||
|
self.os_input.load_palette(),
|
||||||
|
)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
self.send_screen_instructions
|
self.send_screen_instructions
|
||||||
.send(ScreenInstruction::Render)
|
.send(ScreenInstruction::Render)
|
||||||
|
|
@ -285,9 +287,8 @@ impl InputHandler {
|
||||||
/// Creates a [`Help`] struct indicating the current [`InputMode`] and its keybinds
|
/// Creates a [`Help`] struct indicating the current [`InputMode`] and its keybinds
|
||||||
/// (as pairs of [`String`]s).
|
/// (as pairs of [`String`]s).
|
||||||
// TODO this should probably be automatically generated in some way
|
// TODO this should probably be automatically generated in some way
|
||||||
pub fn get_mode_info(mode: InputMode) -> ModeInfo {
|
pub fn get_mode_info(mode: InputMode, palette: Palette) -> ModeInfo {
|
||||||
let mut keybinds: Vec<(String, String)> = vec![];
|
let mut keybinds: Vec<(String, String)> = vec![];
|
||||||
let palette = load_palette();
|
|
||||||
match mode {
|
match mode {
|
||||||
InputMode::Normal | InputMode::Locked => {}
|
InputMode::Normal | InputMode::Locked => {}
|
||||||
InputMode::Resize => {
|
InputMode::Resize => {
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ use os_input_output::OsApi;
|
||||||
use pty_bus::{PtyBus, PtyInstruction};
|
use pty_bus::{PtyBus, PtyInstruction};
|
||||||
use screen::{Screen, ScreenInstruction};
|
use screen::{Screen, ScreenInstruction};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use utils::{consts::ZELLIJ_IPC_PIPE, shared::load_palette};
|
use utils::consts::ZELLIJ_IPC_PIPE;
|
||||||
use wasm_vm::{wasi_read_string, wasi_write_object, zellij_exports, PluginEnv, PluginInstruction};
|
use wasm_vm::{wasi_read_string, wasi_write_object, zellij_exports, PluginEnv, PluginInstruction};
|
||||||
use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value};
|
use wasmer::{ChainableNamedResolver, Instance, Module, Store, Value};
|
||||||
use wasmer_wasi::{Pipe, WasiState};
|
use wasmer_wasi::{Pipe, WasiState};
|
||||||
|
|
@ -267,7 +267,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
|
||||||
let send_plugin_instructions = send_plugin_instructions.clone();
|
let send_plugin_instructions = send_plugin_instructions.clone();
|
||||||
let send_app_instructions = send_app_instructions.clone();
|
let send_app_instructions = send_app_instructions.clone();
|
||||||
let max_panes = opts.max_panes;
|
let max_panes = opts.max_panes;
|
||||||
let colors = load_palette();
|
let colors = os_input.load_palette();
|
||||||
// debug_log_to_file(format!("{:?}", colors));
|
// debug_log_to_file(format!("{:?}", colors));
|
||||||
move || {
|
move || {
|
||||||
let mut screen = Screen::new(
|
let mut screen = Screen::new(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::panes::PositionAndSize;
|
use crate::panes::PositionAndSize;
|
||||||
|
use crate::utils::shared::{colors, detect_theme, hex_to_rgb};
|
||||||
use nix::fcntl::{fcntl, FcntlArg, OFlag};
|
use nix::fcntl::{fcntl, FcntlArg, OFlag};
|
||||||
use nix::pty::{forkpty, Winsize};
|
use nix::pty::{forkpty, Winsize};
|
||||||
use nix::sys::signal::{kill, Signal};
|
use nix::sys::signal::{kill, Signal};
|
||||||
|
|
@ -12,6 +13,8 @@ use std::os::unix::io::RawFd;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::{Child, Command};
|
use std::process::{Child, Command};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use xrdb::Colors;
|
||||||
|
use zellij_tile::data::{Palette, PaletteSource, Theme};
|
||||||
|
|
||||||
use signal_hook::{consts::signal::*, iterator::Signals};
|
use signal_hook::{consts::signal::*, iterator::Signals};
|
||||||
|
|
||||||
|
|
@ -191,6 +194,7 @@ pub trait OsApi: Send + Sync {
|
||||||
/// Returns a [`Box`] pointer to this [`OsApi`] struct.
|
/// Returns a [`Box`] pointer to this [`OsApi`] struct.
|
||||||
fn box_clone(&self) -> Box<dyn OsApi>;
|
fn box_clone(&self) -> Box<dyn OsApi>;
|
||||||
fn receive_sigwinch(&self, cb: Box<dyn Fn()>);
|
fn receive_sigwinch(&self, cb: Box<dyn Fn()>);
|
||||||
|
fn load_palette(&self) -> Palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OsApi for OsInputOutput {
|
impl OsApi for OsInputOutput {
|
||||||
|
|
@ -261,6 +265,48 @@ impl OsApi for OsInputOutput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn load_palette(&self) -> Palette {
|
||||||
|
let palette = match Colors::new("xresources") {
|
||||||
|
Some(palette) => {
|
||||||
|
let fg = hex_to_rgb(&palette.fg);
|
||||||
|
let bg = hex_to_rgb(&palette.bg);
|
||||||
|
let colors: Vec<(u8, u8, u8)> =
|
||||||
|
palette.colors.iter().map(|c| hex_to_rgb(c)).collect();
|
||||||
|
let theme = detect_theme(bg);
|
||||||
|
Palette {
|
||||||
|
source: PaletteSource::Xresources,
|
||||||
|
theme,
|
||||||
|
fg,
|
||||||
|
bg,
|
||||||
|
black: colors[0],
|
||||||
|
red: colors[1],
|
||||||
|
green: colors[2],
|
||||||
|
yellow: colors[3],
|
||||||
|
blue: colors[4],
|
||||||
|
magenta: colors[5],
|
||||||
|
cyan: colors[6],
|
||||||
|
white: colors[7],
|
||||||
|
orange: colors[9],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => Palette {
|
||||||
|
source: PaletteSource::Default,
|
||||||
|
theme: Theme::Dark,
|
||||||
|
fg: colors::BRIGHT_GRAY,
|
||||||
|
bg: colors::GRAY,
|
||||||
|
black: colors::BLACK,
|
||||||
|
red: colors::RED,
|
||||||
|
green: colors::GREEN,
|
||||||
|
yellow: colors::GRAY,
|
||||||
|
blue: colors::GRAY,
|
||||||
|
magenta: colors::GRAY,
|
||||||
|
cyan: colors::GRAY,
|
||||||
|
white: colors::WHITE,
|
||||||
|
orange: colors::ORANGE,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
palette
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for Box<dyn OsApi> {
|
impl Clone for Box<dyn OsApi> {
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ use std::{iter, str::from_utf8};
|
||||||
use strip_ansi_escapes::strip;
|
use strip_ansi_escapes::strip;
|
||||||
|
|
||||||
use colors_transform::{Color, Rgb};
|
use colors_transform::{Color, Rgb};
|
||||||
use xrdb::Colors;
|
use zellij_tile::data::{Theme};
|
||||||
use zellij_tile::data::{Palette, PaletteSource, Theme};
|
|
||||||
|
|
||||||
fn ansi_len(s: &str) -> usize {
|
fn ansi_len(s: &str) -> usize {
|
||||||
from_utf8(&strip(s.as_bytes()).unwrap())
|
from_utf8(&strip(s.as_bytes()).unwrap())
|
||||||
|
|
@ -40,7 +39,7 @@ pub mod colors {
|
||||||
pub const GRAY: (u8, u8, u8) = (68, 68, 68);
|
pub const GRAY: (u8, u8, u8) = (68, 68, 68);
|
||||||
pub const BRIGHT_GRAY: (u8, u8, u8) = (138, 138, 138);
|
pub const BRIGHT_GRAY: (u8, u8, u8) = (138, 138, 138);
|
||||||
pub const RED: (u8, u8, u8) = (135, 0, 0);
|
pub const RED: (u8, u8, u8) = (135, 0, 0);
|
||||||
pub const ORANGE: (u8, u8, u8) = (215,95,0);
|
pub const ORANGE: (u8, u8, u8) = (215, 95, 0);
|
||||||
pub const BLACK: (u8, u8, u8) = (0, 0, 0);
|
pub const BLACK: (u8, u8, u8) = (0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -65,45 +64,3 @@ pub fn detect_theme(bg: (u8, u8, u8)) -> Theme {
|
||||||
false => Theme::Dark,
|
false => Theme::Dark,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_palette() -> Palette {
|
|
||||||
let palette = match Colors::new("xresources") {
|
|
||||||
Some(palette) => {
|
|
||||||
let fg = hex_to_rgb(&palette.fg);
|
|
||||||
let bg = hex_to_rgb(&palette.bg);
|
|
||||||
let colors: Vec<(u8, u8, u8)> = palette.colors.iter().map(|c| hex_to_rgb(c)).collect();
|
|
||||||
let theme = detect_theme(bg);
|
|
||||||
Palette {
|
|
||||||
source: PaletteSource::Xresources,
|
|
||||||
theme,
|
|
||||||
fg,
|
|
||||||
bg,
|
|
||||||
black: colors[0],
|
|
||||||
red: colors[1],
|
|
||||||
green: colors[2],
|
|
||||||
yellow: colors[3],
|
|
||||||
blue: colors[4],
|
|
||||||
magenta: colors[5],
|
|
||||||
cyan: colors[6],
|
|
||||||
white: colors[7],
|
|
||||||
orange: colors[9]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => Palette {
|
|
||||||
source: PaletteSource::Default,
|
|
||||||
theme: Theme::Dark,
|
|
||||||
fg: colors::BRIGHT_GRAY,
|
|
||||||
bg: colors::GRAY,
|
|
||||||
black: colors::BLACK,
|
|
||||||
red: colors::RED,
|
|
||||||
green: colors::GREEN,
|
|
||||||
yellow: colors::GRAY,
|
|
||||||
blue: colors::GRAY,
|
|
||||||
magenta: colors::GRAY,
|
|
||||||
cyan: colors::GRAY,
|
|
||||||
white: colors::WHITE,
|
|
||||||
orange: colors::ORANGE
|
|
||||||
},
|
|
||||||
};
|
|
||||||
palette
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use crate::os_input_output::OsApi;
|
use crate::os_input_output::OsApi;
|
||||||
use crate::tests::possible_tty_inputs::{get_possible_tty_inputs, Bytes};
|
use crate::tests::possible_tty_inputs::{get_possible_tty_inputs, Bytes};
|
||||||
|
use crate::utils::shared::colors;
|
||||||
|
use zellij_tile::data::{Palette, PaletteSource, Theme};
|
||||||
|
|
||||||
use crate::tests::utils::commands::{QUIT, SLEEP};
|
use crate::tests::utils::commands::{QUIT, SLEEP};
|
||||||
|
|
||||||
|
|
@ -73,6 +75,7 @@ pub struct FakeInputOutput {
|
||||||
last_snapshot_time: Arc<Mutex<Instant>>,
|
last_snapshot_time: Arc<Mutex<Instant>>,
|
||||||
should_trigger_sigwinch: Arc<(Mutex<bool>, Condvar)>,
|
should_trigger_sigwinch: Arc<(Mutex<bool>, Condvar)>,
|
||||||
sigwinch_event: Option<PositionAndSize>,
|
sigwinch_event: Option<PositionAndSize>,
|
||||||
|
palette: Arc<Mutex<Palette>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FakeInputOutput {
|
impl FakeInputOutput {
|
||||||
|
|
@ -81,6 +84,21 @@ impl FakeInputOutput {
|
||||||
let last_snapshot_time = Arc::new(Mutex::new(Instant::now()));
|
let last_snapshot_time = Arc::new(Mutex::new(Instant::now()));
|
||||||
let stdout_writer = FakeStdoutWriter::new(last_snapshot_time.clone());
|
let stdout_writer = FakeStdoutWriter::new(last_snapshot_time.clone());
|
||||||
win_sizes.insert(0, winsize); // 0 is the current terminal
|
win_sizes.insert(0, winsize); // 0 is the current terminal
|
||||||
|
let palette: Palette = Palette {
|
||||||
|
source: PaletteSource::Default,
|
||||||
|
theme: Theme::Dark,
|
||||||
|
fg: colors::BRIGHT_GRAY,
|
||||||
|
bg: colors::GRAY,
|
||||||
|
black: colors::BLACK,
|
||||||
|
red: colors::RED,
|
||||||
|
green: colors::GREEN,
|
||||||
|
yellow: colors::GRAY,
|
||||||
|
blue: colors::GRAY,
|
||||||
|
magenta: colors::GRAY,
|
||||||
|
cyan: colors::GRAY,
|
||||||
|
white: colors::WHITE,
|
||||||
|
orange: colors::ORANGE,
|
||||||
|
};
|
||||||
FakeInputOutput {
|
FakeInputOutput {
|
||||||
read_buffers: Arc::new(Mutex::new(HashMap::new())),
|
read_buffers: Arc::new(Mutex::new(HashMap::new())),
|
||||||
stdin_writes: Arc::new(Mutex::new(HashMap::new())),
|
stdin_writes: Arc::new(Mutex::new(HashMap::new())),
|
||||||
|
|
@ -93,6 +111,7 @@ impl FakeInputOutput {
|
||||||
possible_tty_inputs: get_possible_tty_inputs(),
|
possible_tty_inputs: get_possible_tty_inputs(),
|
||||||
should_trigger_sigwinch: Arc::new((Mutex::new(false), Condvar::new())),
|
should_trigger_sigwinch: Arc::new((Mutex::new(false), Condvar::new())),
|
||||||
sigwinch_event: None,
|
sigwinch_event: None,
|
||||||
|
palette: Arc::new(Mutex::new(palette)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn with_tty_inputs(mut self, tty_inputs: HashMap<u16, Bytes>) -> Self {
|
pub fn with_tty_inputs(mut self, tty_inputs: HashMap<u16, Bytes>) -> Self {
|
||||||
|
|
@ -235,4 +254,22 @@ impl OsApi for FakeInputOutput {
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn load_palette(&self) -> Palette {
|
||||||
|
let palette: Palette = Palette {
|
||||||
|
source: PaletteSource::Default,
|
||||||
|
theme: Theme::Dark,
|
||||||
|
fg: colors::BRIGHT_GRAY,
|
||||||
|
bg: colors::GRAY,
|
||||||
|
black: colors::BLACK,
|
||||||
|
red: colors::RED,
|
||||||
|
green: colors::GREEN,
|
||||||
|
yellow: colors::GRAY,
|
||||||
|
blue: colors::GRAY,
|
||||||
|
magenta: colors::GRAY,
|
||||||
|
cyan: colors::GRAY,
|
||||||
|
white: colors::WHITE,
|
||||||
|
orange: colors::ORANGE,
|
||||||
|
};
|
||||||
|
palette
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ description = "A small client-side library for writing Zellij plugins"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
ansi_term = "0.12.1"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
strum = "0.20.0"
|
strum = "0.20.0"
|
||||||
|
|
|
||||||
|
|
@ -67,13 +67,13 @@ impl Default for InputMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||||
pub enum Theme {
|
pub enum Theme {
|
||||||
Light,
|
Light,
|
||||||
Dark,
|
Dark,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||||
pub enum PaletteSource {
|
pub enum PaletteSource {
|
||||||
Default,
|
Default,
|
||||||
Xresources,
|
Xresources,
|
||||||
|
|
@ -84,11 +84,11 @@ pub mod colors {
|
||||||
pub const GRAY: (u8, u8, u8) = (68, 68, 68);
|
pub const GRAY: (u8, u8, u8) = (68, 68, 68);
|
||||||
pub const BRIGHT_GRAY: (u8, u8, u8) = (138, 138, 138);
|
pub const BRIGHT_GRAY: (u8, u8, u8) = (138, 138, 138);
|
||||||
pub const RED: (u8, u8, u8) = (135, 0, 0);
|
pub const RED: (u8, u8, u8) = (135, 0, 0);
|
||||||
pub const ORANGE: (u8, u8, u8) = (215,95,0);
|
pub const ORANGE: (u8, u8, u8) = (215, 95, 0);
|
||||||
pub const BLACK: (u8, u8, u8) = (0, 0, 0);
|
pub const BLACK: (u8, u8, u8) = (0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||||
pub struct Palette {
|
pub struct Palette {
|
||||||
pub source: PaletteSource,
|
pub source: PaletteSource,
|
||||||
pub theme: Theme,
|
pub theme: Theme,
|
||||||
|
|
@ -102,7 +102,7 @@ pub struct Palette {
|
||||||
pub magenta: (u8, u8, u8),
|
pub magenta: (u8, u8, u8),
|
||||||
pub cyan: (u8, u8, u8),
|
pub cyan: (u8, u8, u8),
|
||||||
pub white: (u8, u8, u8),
|
pub white: (u8, u8, u8),
|
||||||
pub orange: (u8, u8, u8)
|
pub orange: (u8, u8, u8),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Palette {
|
impl Default for Palette {
|
||||||
|
|
@ -120,7 +120,7 @@ impl Default for Palette {
|
||||||
magenta: colors::GRAY,
|
magenta: colors::GRAY,
|
||||||
cyan: colors::GRAY,
|
cyan: colors::GRAY,
|
||||||
white: colors::WHITE,
|
white: colors::WHITE,
|
||||||
orange: colors::ORANGE
|
orange: colors::ORANGE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,3 +39,19 @@ macro_rules! register_plugin {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! rgb {
|
||||||
|
($a:expr) => {
|
||||||
|
ansi_term::Color::RGB($a.0, $a.1, $a.2)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! style {
|
||||||
|
($a:expr, $b:expr) => {
|
||||||
|
ansi_term::Style::new()
|
||||||
|
.fg(ansi_term::Color::RGB($a.0, $a.1, $a.2))
|
||||||
|
.on(ansi_term::Color::RGB($b.0, $b.1, $b.2))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue