refactor: colors.rs -> ui/colors.rs

This commit is contained in:
graelo 2021-03-19 23:07:08 +01:00
parent d119ce6b0d
commit 748da3ae72
4 changed files with 11 additions and 9 deletions

View file

@ -4,7 +4,6 @@ use std::path;
use std::str::FromStr; use std::str::FromStr;
pub mod alphabets; pub mod alphabets;
pub mod colors;
pub mod error; pub mod error;
pub mod model; pub mod model;
pub mod output_destination; pub mod output_destination;
@ -98,7 +97,7 @@ pub struct CliOpt {
unique_hint: bool, unique_hint: bool,
#[clap(flatten)] #[clap(flatten)]
colors: colors::UiColors, colors: ui::colors::UiColors,
/// Align hint with its match. /// Align hint with its match.
#[clap(long, arg_enum, default_value = "leading")] #[clap(long, arg_enum, default_value = "leading")]
@ -187,12 +186,12 @@ impl CliOpt {
self.unique_hint = value.parse::<bool>()?; self.unique_hint = value.parse::<bool>()?;
} }
"@copyrat-match-fg" => self.colors.match_fg = colors::parse_color(value)?, "@copyrat-match-fg" => self.colors.match_fg = ui::colors::parse_color(value)?,
"@copyrat-match-bg" => self.colors.match_bg = colors::parse_color(value)?, "@copyrat-match-bg" => self.colors.match_bg = ui::colors::parse_color(value)?,
"@copyrat-focused-fg" => self.colors.focused_fg = colors::parse_color(value)?, "@copyrat-focused-fg" => self.colors.focused_fg = ui::colors::parse_color(value)?,
"@copyrat-focused-bg" => self.colors.focused_bg = colors::parse_color(value)?, "@copyrat-focused-bg" => self.colors.focused_bg = ui::colors::parse_color(value)?,
"@copyrat-hint-fg" => self.colors.hint_fg = colors::parse_color(value)?, "@copyrat-hint-fg" => self.colors.hint_fg = ui::colors::parse_color(value)?,
"@copyrat-hint-bg" => self.colors.hint_bg = colors::parse_color(value)?, "@copyrat-hint-bg" => self.colors.hint_bg = ui::colors::parse_color(value)?,
"@copyrat-hint-alignment" => { "@copyrat-hint-alignment" => {
self.hint_alignment = ui::HintAlignment::from_str(&value)? self.hint_alignment = ui::HintAlignment::from_str(&value)?

View file

@ -17,6 +17,8 @@
//! - toggle the output destination (tmux buffer or clipboard) //! - toggle the output destination (tmux buffer or clipboard)
//! //!
pub mod colors;
mod vc; mod vc;
pub use vc::ViewController; pub use vc::ViewController;
pub use vc::{HintAlignment, HintStyle}; pub use vc::{HintAlignment, HintStyle};

View file

@ -7,8 +7,9 @@ use clap::Clap;
use sequence_trie::SequenceTrie; use sequence_trie::SequenceTrie;
use termion::{self, color, cursor, event, style}; use termion::{self, color, cursor, event, style};
use super::colors::UiColors;
use crate::error::ParseError; use crate::error::ParseError;
use crate::{colors::UiColors, model, output_destination::OutputDestination, selection::Selection}; use crate::{model, output_destination::OutputDestination, selection::Selection};
pub struct ViewController<'a> { pub struct ViewController<'a> {
model: &'a mut model::Model<'a>, model: &'a mut model::Model<'a>,