diff options
| author | Denis Maximov <denismaximov98@gmail.com> | 2021-05-02 13:53:36 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-02 13:53:36 +0300 |
| commit | 98d9eacd2221162c60f71b73ea7f40ff7256e225 (patch) | |
| tree | bad162ac3c59a16723f75fcd32d6d0cc724be09e /src/client | |
| parent | docs(changelog): Improved Config Loading #423 (diff) | |
| parent | chore: remove unused dependency from zellij-tile (diff) | |
| download | sl0ppij-98d9eacd2221162c60f71b73ea7f40ff7256e225.tar.gz sl0ppij-98d9eacd2221162c60f71b73ea7f40ff7256e225.tar.xz sl0ppij-98d9eacd2221162c60f71b73ea7f40ff7256e225.zip | |
Merge pull request #239 from zellij-org/x-colors
X colors
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/boundaries.rs | 36 | ||||
| -rw-r--r-- | src/client/tab.rs | 13 |
2 files changed, 30 insertions, 19 deletions
diff --git a/src/client/boundaries.rs b/src/client/boundaries.rs index 28e01a11..4708ed6a 100644 --- a/src/client/boundaries.rs +++ b/src/client/boundaries.rs @@ -1,10 +1,10 @@ use crate::tab::Pane; -use ansi_term::Colour; +use crate::utils::shared::colors; +use ansi_term::Colour::RGB; use std::collections::HashMap; -use zellij_tile::data::InputMode; +use zellij_tile::data::{InputMode, Palette}; use std::fmt::{Display, Error, Formatter}; - pub mod boundary_type { pub const TOP_RIGHT: &str = "┐"; pub const VERTICAL: &str = "│"; @@ -19,12 +19,12 @@ pub mod boundary_type { pub const CROSS: &str = "┼"; } -pub mod colors { - use ansi_term::Colour::{self, Fixed}; - pub const GREEN: Colour = Fixed(154); - pub const GRAY: Colour = Fixed(238); - pub const ORANGE: Colour = Fixed(166); -} +// pub mod colors { +// use ansi_term::Colour::{self, Fixed}; +// pub const GREEN: Colour = Fixed(154); +// pub const GRAY: Colour = Fixed(238); +// pub const ORANGE: Colour = Fixed(166); +// } pub type BoundaryType = &'static str; // easy way to refer to boundary_type above @@ -32,7 +32,7 @@ pub type BoundaryType = &'static str; // easy way to refer to boundary_type abov pub struct BoundarySymbol { boundary_type: BoundaryType, invisible: bool, - color: Option<Colour>, + color: Option<(u8, u8, u8)>, } impl BoundarySymbol { @@ -47,7 +47,7 @@ impl BoundarySymbol { self.invisible = true; self } - pub fn color(&mut self, color: Option<Colour>) -> Self { + pub fn color(&mut self, color: Option<(u8, u8, u8)>) -> Self { self.color = color; *self } @@ -58,7 +58,11 @@ impl Display for BoundarySymbol { match self.invisible { true => write!(f, " "), false => match self.color { - Some(color) => write!(f, "{}", color.paint(self.boundary_type)), + Some(color) => write!( + f, + "{}", + RGB(color.0, color.1, color.2).paint(self.boundary_type) + ), None => write!(f, "{}", self.boundary_type), }, } @@ -764,11 +768,11 @@ impl Boundaries { boundary_characters: HashMap::new(), } } - pub fn add_rect(&mut self, rect: &dyn Pane, input_mode: InputMode, color: Option<Colour>) { - let color = match color.is_some() { + pub fn add_rect(&mut self, rect: &dyn Pane, input_mode: InputMode, palette: Option<Palette>) { + let color = match palette.is_some() { true => match input_mode { - InputMode::Normal | InputMode::Locked => Some(colors::GREEN), - _ => Some(colors::ORANGE), + InputMode::Normal | InputMode::Locked => Some(palette.unwrap().green), + _ => Some(palette.unwrap().orange), }, false => None, }; diff --git a/src/client/tab.rs b/src/client/tab.rs index f9bf7b57..b01e04e5 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -1,7 +1,6 @@ //! `Tab`s holds multiple panes. It tracks their coordinates (x/y) and size, //! as well as how they should be resized -use crate::boundaries::colors; use crate::client::pane_resizer::PaneResizer; use crate::common::{input::handler::parse_keys, AppInstruction, SenderWithContext}; use crate::layout::Layout; @@ -19,7 +18,7 @@ use std::{ collections::{BTreeMap, HashSet}, }; use std::{io::Write, sync::mpsc::channel}; -use zellij_tile::data::{Event, ModeInfo}; +use zellij_tile::data::{Event, InputMode, ModeInfo, Palette}; const CURSOR_HEIGHT_WIDTH_RATIO: usize = 4; // this is not accurate and kind of a magic number, TODO: look into this @@ -75,6 +74,8 @@ pub struct Tab { pub send_app_instructions: SenderWithContext<AppInstruction>, should_clear_display_before_rendering: bool, pub mode_info: ModeInfo, + pub input_mode: InputMode, + pub colors: Palette, } #[derive(Clone, Debug, Default, Serialize, Deserialize)] @@ -84,6 +85,8 @@ pub struct TabData { pub name: String, pub active: bool, pub mode_info: ModeInfo, + pub input_mode: InputMode, + pub colors: Palette, } // FIXME: Use a struct that has a pane_type enum, to reduce all of the duplication @@ -229,6 +232,8 @@ impl Tab { max_panes: Option<usize>, pane_id: Option<PaneId>, mode_info: ModeInfo, + input_mode: InputMode, + colors: Palette, ) -> Self { let panes = if let Some(PaneId::Terminal(pid)) = pane_id { let new_terminal = TerminalPane::new(pid, *full_screen_ws); @@ -260,6 +265,8 @@ impl Tab { send_plugin_instructions, should_clear_display_before_rendering: false, mode_info, + input_mode, + colors, } } @@ -743,7 +750,7 @@ impl Tab { match self.active_terminal.unwrap() == pane.pid() { true => { pane.set_active_at(Instant::now()); - boundaries.add_rect(pane.as_ref(), self.mode_info.mode, Some(colors::GREEN)) + boundaries.add_rect(pane.as_ref(), self.mode_info.mode, Some(self.colors)) } false => boundaries.add_rect(pane.as_ref(), self.mode_info.mode, None), } |
