chore: update code structure for better readability and maintainability
fixes: fixt rendedring of icons and swe texts
This commit is contained in:
@@ -49,6 +49,35 @@ impl FileEntry {
|
||||
}
|
||||
}
|
||||
|
||||
/// ASCII fallback icons for terminals that don't support emoji (e.g. SSH with limited fonts)
|
||||
pub fn icon_ascii(&self) -> &'static str {
|
||||
match &self.file_type {
|
||||
FileType::Directory => "[/]",
|
||||
FileType::Symlink => "[~]",
|
||||
FileType::File => {
|
||||
let ext = self
|
||||
.name
|
||||
.rsplit('.')
|
||||
.next()
|
||||
.unwrap_or("")
|
||||
.to_lowercase();
|
||||
match ext.as_str() {
|
||||
"rs" | "py" | "js" | "ts" | "c" | "cpp" | "h" | "hpp"
|
||||
| "sh" | "bash" | "zsh" | "fish" => "[s]",
|
||||
"png" | "jpg" | "jpeg" | "gif" | "bmp" | "svg" | "webp" | "ico" => "[i]",
|
||||
"mp4" | "mkv" | "avi" | "mov" | "webm" => "[v]",
|
||||
"mp3" | "flac" | "ogg" | "wav" | "aac" => "[a]",
|
||||
"zip" | "tar" | "gz" | "bz2" | "xz" | "7z" | "rar" => "[z]",
|
||||
"pdf" => "[p]",
|
||||
"txt" | "md" | "log" => "[t]",
|
||||
"json" | "yaml" | "yml" | "toml" | "xml" => "[c]",
|
||||
"exe" | "bin" | "out" | "run" => "[x]",
|
||||
_ => "[ ]",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_dir(&self) -> bool {
|
||||
self.file_type == FileType::Directory
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user