diff options
author | qkzk <qu3nt1n@gmail.com> | 2023-11-02 07:52:13 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2023-11-02 07:52:13 +0100 |
commit | 6fdbccecd83f573e43e874a59713680451d9b991 (patch) | |
tree | 5901868d8cadedbd07aa18ea07c1d30441d3fe5d /src/tree.rs | |
parent | 75f487d879adb12d906ab88bd70e372fe03b0f74 (diff) |
Only store a color and an effect in trees instead of a full attr.
Diffstat (limited to 'src/tree.rs')
-rw-r--r-- | src/tree.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/tree.rs b/src/tree.rs index e6818b8..a659191 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -1,9 +1,8 @@ use std::path::Path; use anyhow::{Context, Result}; -use tuikit::attr::Attr; -use crate::fileinfo::{fileinfo_attr, files_collection, FileInfo, FileKind}; +use crate::fileinfo::{files_collection, ColorEffect, FileInfo, FileKind}; use crate::filter::FilterKind; use crate::preview::ColoredTriplet; use crate::sort::SortKind; @@ -16,14 +15,18 @@ pub struct ColoredString { /// A text to be printed. In most case, it should be a filename. pub text: String, /// A tuikit::attr::Attr (fg, bg, effect) to enhance the text. - pub attr: Attr, + pub color_effect: ColorEffect, /// The complete path of this string. pub path: std::path::PathBuf, } impl ColoredString { - fn new(text: String, attr: Attr, path: std::path::PathBuf) -> Self { - Self { text, attr, path } + fn new(text: String, color_effect: ColorEffect, path: std::path::PathBuf) -> Self { + Self { + text, + color_effect, + path, + } } fn from_node(current_node: &Node) -> Self { @@ -36,7 +39,7 @@ impl ColoredString { } else { current_node.filename() }; - Self::new(text, current_node.attr(), current_node.filepath()) + Self::new(text, current_node.color_effect(), current_node.filepath()) } } @@ -63,8 +66,8 @@ impl Node { self.fileinfo.path.to_owned() } - fn attr(&self) -> Attr { - fileinfo_attr(&self.fileinfo) + fn color_effect(&self) -> ColorEffect { + ColorEffect::new(&self.fileinfo) } fn select(&mut self) { |