1use f00_core::{Entry, EntryKind};
2
3pub fn icon_for(entry: &Entry) -> &'static str {
5 if entry.is_dir_header {
6 return "";
7 }
8
9 match entry.kind {
10 EntryKind::Directory => return "📁",
11 EntryKind::Symlink => return "🔗",
12 EntryKind::Other => return "📄",
13 EntryKind::File => {}
14 }
15
16 match entry.extension().map(|e| e.to_ascii_lowercase()).as_deref() {
17 Some("rs") => "🦀",
18 Some("go") => "🐹",
19 Some("py") => "🐍",
20 Some("js" | "mjs" | "cjs") => "🟨",
21 Some("ts" | "tsx") => "🔷",
22 Some("json") => "📋",
23 Some("toml" | "yaml" | "yml" | "ini" | "cfg") => "⚙️",
24 Some("md" | "markdown" | "txt" | "rst") => "📝",
25 Some("html" | "htm" | "css" | "scss") => "🌐",
26 Some("png" | "jpg" | "jpeg" | "gif" | "webp" | "svg" | "ico") => "🖼️",
27 Some("mp3" | "wav" | "flac" | "ogg" | "m4a") => "🎵",
28 Some("mp4" | "mkv" | "webm" | "mov" | "avi") => "🎬",
29 Some("zip" | "tar" | "gz" | "bz2" | "xz" | "7z" | "rar") => "📦",
30 Some("pdf") => "📕",
31 Some("sh" | "bash" | "zsh" | "fish") => "💻",
32 Some("lock") => "🔒",
33 Some("git") => "🌱",
34 _ => {
35 match entry.name.as_str() {
37 "Cargo.toml" | "Cargo.lock" => "📦",
38 "Makefile" | "Dockerfile" => "🛠️",
39 "LICENSE" | "LICENSE.md" | "COPYING" => "📜",
40 "README" | "README.md" => "📖",
41 _ => "📄",
42 }
43 }
44 }
45}
46
47pub fn icon_prefix(entry: &Entry, enabled: bool) -> String {
49 if !enabled || entry.is_dir_header {
50 return String::new();
51 }
52 format!("{} ", icon_for(entry))
53}