Skip to content

Commit

Permalink
Add support for RGB and indexed colors (#193)
Browse files Browse the repository at this point in the history
- Add support for RGB and indexed colors
- Fix all clippy warnings
- Update color-parser-tui with optional field
- Remove MacchinaColor entirely
  • Loading branch information
uttarayan21 authored Nov 7, 2021
1 parent 9342ec2 commit de08704
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 169 deletions.
102 changes: 60 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ serde = { version = "1.0.130", features = ["derive"] }
dirs = "4.0"
toml = "0.5.8"
serde_json = "1.0.68"
color-to-tui = "0.1.2"
strum = "0.22.0"

[build-dependencies]
vergen = { version = "5.1.16", default-features = false, features = ["build", "cargo", "git", "rustc"] }
Expand Down
17 changes: 10 additions & 7 deletions src/data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::cli::Opt;
use crate::theme::theme::Theme;
use crate::theme::Theme;
use clap::arg_enum;
use libmacchina::traits::ShellFormat;
use libmacchina::traits::{ReadoutError, ShellKind};
Expand Down Expand Up @@ -66,8 +66,11 @@ fn create_bar<'a>(theme: &Theme, blocks: usize) -> Spans<'a> {
if theme.bar.are_delimiters_hidden() {
let mut span_vector = vec![Span::raw(""), Span::raw("")];

let glyph = theme.bar.get_glyph().clone();
let glyphs = colored_glyphs(&glyph, blocks);
// This clone is useless since we can't really clone a &str
// this just clones the reference to the str
// let glyph = theme.bar.get_glyph().clone();
let glyph = theme.bar.get_glyph();
let glyphs = colored_glyphs(glyph, blocks);

if blocks == 10 {
span_vector[0].content = Cow::from(glyphs);
Expand All @@ -76,7 +79,7 @@ fn create_bar<'a>(theme: &Theme, blocks: usize) -> Spans<'a> {
}
span_vector[0].style = Style::default().fg(theme.get_key_color());

span_vector[1].content = Cow::from(colored_glyphs(&glyph, 10 - blocks));
span_vector[1].content = Cow::from(colored_glyphs(glyph, 10 - blocks));
if theme.get_key_color() == Color::White {
span_vector[1].content = Cow::from(span_vector[1].content.replace(&glyph, " "));
}
Expand All @@ -90,8 +93,8 @@ fn create_bar<'a>(theme: &Theme, blocks: usize) -> Spans<'a> {
Span::raw(format!(" {}", theme.bar.get_symbol_close())),
];

let glyph = theme.bar.get_glyph().clone();
let glyphs = colored_glyphs(&glyph, blocks);
let glyph = theme.bar.get_glyph();
let glyphs = colored_glyphs(glyph, blocks);

if blocks == 10 {
span_vector[1].content = Cow::from(glyphs);
Expand All @@ -100,7 +103,7 @@ fn create_bar<'a>(theme: &Theme, blocks: usize) -> Spans<'a> {
}
span_vector[1].style = Style::default().fg(theme.get_key_color());

span_vector[2].content = Cow::from(colored_glyphs(&glyph, 10 - blocks));
span_vector[2].content = Cow::from(colored_glyphs(glyph, 10 - blocks));
if theme.get_key_color() == Color::White {
span_vector[2].content = Cow::from(span_vector[2].content.replace(&glyph, " "));
}
Expand Down
Loading

0 comments on commit de08704

Please sign in to comment.