mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-13 16:06:30 +00:00
9b24649d68
This commit adds many traits, all named ‘Colours’, to the code. Each one asks for a colour needed to render a cell: the number of links asks for colours for the number and the multi-link-file special case; the file size asks for number, unit, punctuation, and device ID colours, or it can do a scale with its own colours, however it wants. This is a step towards LS_COLORS compatibility, believe it or not. If a text cell in a column doesn’t depend on Colours to render itself, then the source of the colours is open-ended. I am glad to have not needed any test changes here.
29 lines
542 B
Rust
29 lines
542 B
Rust
use ansi_term::Style;
|
|
|
|
use output::cell::TextCell;
|
|
use fs::fields as f;
|
|
|
|
|
|
impl f::Inode {
|
|
pub fn render(&self, style: Style) -> TextCell {
|
|
TextCell::paint(style, self.0.to_string())
|
|
}
|
|
}
|
|
|
|
|
|
#[cfg(test)]
|
|
pub mod test {
|
|
use output::cell::TextCell;
|
|
use fs::fields as f;
|
|
|
|
use ansi_term::Colour::*;
|
|
|
|
|
|
#[test]
|
|
fn blocklessness() {
|
|
let io = f::Inode(1414213);
|
|
let expected = TextCell::paint_str(Cyan.underline(), "1414213");
|
|
assert_eq!(expected, io.render(Cyan.underline()).into());
|
|
}
|
|
}
|