mirror of
https://github.com/lsd-rs/lsd
synced 2024-12-14 06:02:36 +00:00
Selected icons for special Unix file types
This commit is contained in:
parent
038d2c1537
commit
58a503505d
2 changed files with 30 additions and 4 deletions
30
src/icon.rs
30
src/icon.rs
|
@ -58,11 +58,37 @@ impl Icons {
|
||||||
|
|
||||||
let mut res = String::with_capacity(4 + ICON_SPACE.len()); // 4 == max icon size
|
let mut res = String::with_capacity(4 + ICON_SPACE.len()); // 4 == max icon size
|
||||||
|
|
||||||
// Check directory.
|
// Check file types
|
||||||
if let FileType::Directory { .. } = name.file_type() {
|
let file_type: FileType = name.file_type();
|
||||||
|
|
||||||
|
if let FileType::Directory { .. } = file_type {
|
||||||
res += self.default_folder_icon;
|
res += self.default_folder_icon;
|
||||||
res += ICON_SPACE;
|
res += ICON_SPACE;
|
||||||
return res;
|
return res;
|
||||||
|
} else if let FileType::SymLink = file_type {
|
||||||
|
res += "\u{e27c}"; // ""
|
||||||
|
res += ICON_SPACE;
|
||||||
|
return res;
|
||||||
|
} else if let FileType::Socket = file_type {
|
||||||
|
res += "\u{f6a7}"; // ""
|
||||||
|
res += ICON_SPACE;
|
||||||
|
return res;
|
||||||
|
} else if let FileType::Pipe = file_type {
|
||||||
|
res += "\u{f731}"; // ""
|
||||||
|
res += ICON_SPACE;
|
||||||
|
return res;
|
||||||
|
} else if let FileType::CharDevice = file_type {
|
||||||
|
res += "\u{e601}"; // ""
|
||||||
|
res += ICON_SPACE;
|
||||||
|
return res;
|
||||||
|
} else if let FileType::BlockDevice = file_type {
|
||||||
|
res += "\u{fc29}"; // "ﰩ"
|
||||||
|
res += ICON_SPACE;
|
||||||
|
return res;
|
||||||
|
} else if let FileType::Special = file_type {
|
||||||
|
res += "\u{f2dc}"; // ""
|
||||||
|
res += ICON_SPACE;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the known names.
|
// Check the known names.
|
||||||
|
|
|
@ -175,7 +175,7 @@ mod test {
|
||||||
let name = Name::new(&symlink_path, file_type);
|
let name = Name::new(&symlink_path, file_type);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Colour::Fixed(44).paint(" target.tmp"),
|
Colour::Fixed(44).paint(" target.tmp"),
|
||||||
name.render(&colors, &icons)
|
name.render(&colors, &icons)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ mod test {
|
||||||
let name = Name::new(&pipe_path, file_type);
|
let name = Name::new(&pipe_path, file_type);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Colour::Fixed(184).paint(" pipe.tmp"),
|
Colour::Fixed(184).paint(" pipe.tmp"),
|
||||||
name.render(&colors, &icons)
|
name.render(&colors, &icons)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue