Skip to content

Commit

Permalink
display: 🎨 delete tree color and apply review
Browse files Browse the repository at this point in the history
Signed-off-by: zwPapEr <[email protected]>
  • Loading branch information
zwpaper committed Mar 12, 2021
1 parent 729feaa commit f19a9b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ impl Colors {
m.insert(Elem::Links { valid: true }, Colour::Fixed(13));
m.insert(Elem::Links { valid: false }, Colour::Fixed(245));

m.insert(Elem::TreeEdge, Colour::Fixed(44)); // DarkTurquoise
// TODO add this after we can use file to configure theme
// m.insert(Elem::TreeEdge, Colour::Fixed(44)); // DarkTurquoise
m
}
}
32 changes: 15 additions & 17 deletions src/display.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::color::{ColoredString, Colors, Elem};
use crate::color::{ColoredString, Colors};
use crate::flags::{Block, Display, Flags, Layout};
use crate::icon::Icons;
use crate::meta::name::DisplayOption;
Expand Down Expand Up @@ -42,6 +42,7 @@ pub fn tree(metas: &[Meta], flags: &Flags, colors: &Colors, icons: &Icons) -> St
for (i, block) in flags.blocks.0.iter().enumerate() {
if let Block::Name = block {
index = i;
break;
}
}

Expand Down Expand Up @@ -163,7 +164,7 @@ fn inner_display_tree(
icons: &Icons,
tree_depth_prefix: (usize, &str),
padding_rules: &HashMap<Block, usize>,
target_index: usize,
tree_index: usize,
) -> Vec<Cell> {
let mut cells = Vec::new();
let last_idx = metas.len();
Expand All @@ -187,7 +188,7 @@ fn inner_display_tree(
&flags,
&DisplayOption::FileName,
&padding_rules,
(target_index, &current_prefix),
(tree_index, &current_prefix),
) {
let block_str = block.to_string();

Expand Down Expand Up @@ -216,7 +217,7 @@ fn inner_display_tree(
icons,
(tree_depth_prefix.0 + 1, &new_prefix),
padding_rules,
target_index,
tree_index,
));
}
}
Expand Down Expand Up @@ -262,7 +263,9 @@ fn get_output<'a>(
let mut strings: Vec<ANSIString> = Vec::new();
for (i, block) in flags.blocks.0.iter().enumerate() {
let mut block_vec = if Layout::Tree == flags.layout && tree.0 == i {
vec![colors.colorize(ANSIString::from(tree.1).to_string(), &Elem::TreeEdge)]
// TODO: add color after we have theme configuration
// vec![colors.colorize(ANSIString::from(tree.1).to_string(), &Elem::TreeEdge)]
vec![ANSIString::from(tree.1)]
} else {
Vec::new()
};
Expand All @@ -289,18 +292,13 @@ fn get_output<'a>(
Block::SizeValue => block_vec.push(meta.size.render_value(colors, flags)),
Block::Date => block_vec.push(meta.date.render(colors, &flags)),
Block::Name => {
if flags.no_symlink.0 || flags.dereference.0 || flags.layout == Layout::Grid {
block_vec.extend(vec![
meta.name.render(colors, icons, &display_option),
meta.indicator.render(&flags),
])
} else {
block_vec.extend(vec![
meta.name.render(colors, icons, &display_option),
meta.indicator.render(&flags),
meta.symlink.render(colors, &flags),
])
};
block_vec.extend(vec![
meta.name.render(colors, icons, &display_option),
meta.indicator.render(&flags),
]);
if !(flags.no_symlink.0 || flags.dereference.0 || flags.layout == Layout::Grid) {
block_vec.push(meta.symlink.render(colors, &flags))
}
}
};
strings.push(ColoredString::from(ANSIStrings(&block_vec).to_string()));
Expand Down

0 comments on commit f19a9b4

Please sign in to comment.